├── .hgignore ├── FreeBSD └── 386 │ ├── bin │ ├── iyacc │ └── mk │ └── include │ ├── fpuctl.h │ └── lib9.h ├── INSTALL ├── Linux ├── 386 │ ├── bin │ │ ├── iyacc │ │ └── mk │ └── include │ │ ├── fpuctl.h │ │ └── lib9.h └── power │ ├── bin │ ├── iyacc │ └── mk │ └── include │ ├── fpuctl.h │ └── lib9.h ├── MacOSX ├── 386 │ ├── bin │ │ ├── iyacc │ │ └── mk │ └── include │ │ ├── fpuctl.h │ │ └── lib9.h └── power │ ├── bin │ ├── iyacc │ └── mk │ └── include │ ├── fpuctl.h │ └── lib9.h ├── NOT.READY ├── NOTICE ├── NetBSD └── 386 │ ├── bin │ ├── iyacc │ └── mk │ └── include │ ├── fpuctl.h │ └── lib9.h ├── Nt └── 386 │ ├── bin │ ├── cp.exe │ ├── echo.exe │ ├── gzip.exe │ ├── mk.exe │ ├── mkdir.exe │ ├── mv.exe │ ├── rcsh.exe │ ├── rm.exe │ ├── sed.exe │ ├── test.exe │ ├── tr.exe │ └── yacc.exe │ └── include │ └── lib9.h ├── Plan9 └── 386 │ └── include │ ├── lib9.h │ └── u.h ├── README.md ├── Solaris └── sparc │ ├── bin │ ├── iyacc │ └── mk │ └── include │ ├── fpuctl.h │ └── lib9.h ├── TODO ├── TODO.REBUILD ├── configure ├── doc ├── acid.ms ├── acid.pdf ├── acid.ps ├── acidpaper.ms ├── acidpaper.pdf ├── acidpaper.ps ├── acidtut.ms ├── acidtut.pdf ├── acidtut.ps ├── asm.ms ├── asm.pdf ├── asm.ps ├── comp.ms ├── compiler.ms ├── compiler.pdf ├── compiler.ps ├── lex.pdf ├── mk.ms ├── mk.pdf ├── mk.ps └── yacc.pdf ├── etc ├── compilers ├── mkconfig.txt ├── os.arch.dlist ├── os.arch.dlist.sh └── os.dlist ├── include ├── a.out.h ├── ar.h ├── bio.h ├── fcall.h ├── mach.h ├── mathi.h ├── rdbg.h └── regexp.h ├── lib ├── lex.ncform ├── rcmain ├── yaccpar └── yaccpars ├── man └── 1 │ ├── 8a │ ├── 8c │ ├── 8l │ ├── cpp │ ├── iyacc │ ├── ksize │ └── kstrip ├── mkconfig ├── mkfile ├── mkfiles ├── mkfile-FreeBSD-386 ├── mkfile-Linux-386 ├── mkfile-Linux-arm ├── mkfile-Linux-power ├── mkfile-Linux-spim ├── mkfile-MacOSX-386 ├── mkfile-MacOSX-power ├── mkfile-NetBSD-386 ├── mkfile-Nt-386 ├── mkfile-OpenBSD-386 ├── mkfile-Plan9-386 ├── mkfile-Plan9-68020 ├── mkfile-Plan9-amd64 ├── mkfile-Plan9-mips ├── mkfile-Plan9-power ├── mkfile-Plan9-sparc ├── mkfile-Solaris-386 ├── mkfile-Solaris-sparc ├── mkhost-FreeBSD ├── mkhost-Linux ├── mkhost-MacOSX ├── mkhost-NetBSD ├── mkhost-Nt ├── mkhost-OpenBSD ├── mkhost-Plan9 ├── mkhost-Solaris ├── mklibsubdirs ├── mkone-nt ├── mkone-rc ├── mkone-sh ├── mksubdirs ├── mksyslib-nt ├── mksyslib-rc └── mksyslib-sh └── src ├── cmd ├── 5a │ ├── a.h │ ├── a.y │ ├── lex.c │ └── mkfile ├── 5c │ ├── 5.out.h │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── 5coff │ ├── 5coff.c │ ├── NOTICE │ ├── auxi.c │ ├── auxi.h │ ├── coff.c │ ├── mkfile │ └── readcoff.c ├── 5cv │ ├── 5cv.c │ └── mkfile ├── 5l │ ├── asm.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ ├── pass.c │ ├── span.c │ └── thumb.c ├── 6a │ ├── a.h │ ├── a.y │ ├── lex.c │ └── mkfile ├── 6c │ ├── 6.out.h │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── machcap.c │ ├── mkfile │ ├── mkfile_o │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── 6l │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── asm.c │ ├── bits.c │ ├── compat.c │ ├── l.h │ ├── list.c │ ├── mem.h │ ├── mkfile │ ├── mkfile_o │ ├── obj.c │ ├── optab.c │ ├── pass.c │ └── span.c ├── 7a │ ├── a.h │ ├── a.y │ ├── lex.c │ └── mkfile ├── 7c │ ├── 7.out.h │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── machcap.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── 7l │ ├── asm.c │ ├── asmout.c │ ├── bits.c │ ├── cnam.c │ ├── dyn.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ └── span.c ├── 8a │ ├── a.h │ ├── a.y │ ├── l.s │ ├── lex.c │ └── mkfile ├── 8c │ ├── 8.out.h │ ├── cgen.c │ ├── cgen64.c │ ├── div.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── machcap.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── 8l │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── asm.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── obj.c │ ├── optab.c │ ├── pass.c │ └── span.c ├── acid │ ├── 386 │ ├── B.sh │ ├── acid.h │ ├── arm │ ├── builtin.c │ ├── dbg.y │ ├── dot.c │ ├── exec.c │ ├── expr.c │ ├── lex.c │ ├── list.c │ ├── main.c │ ├── mips │ ├── mkfile │ ├── os-Nt.c │ ├── os-Plan9.c │ ├── os-Posix.c │ ├── port │ ├── print.c │ ├── proc.c │ ├── rdebug.c │ ├── sparc │ └── util.c ├── cat │ ├── cat.c │ └── mkfile ├── cc │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── acid.c │ ├── bits.c │ ├── cc.h │ ├── cc.y │ ├── com.c │ ├── com64.c │ ├── dcl.c │ ├── dpchk.c │ ├── funct.c │ ├── lex.c │ ├── lexbody │ ├── mac.c │ ├── macbody │ ├── mkfile │ ├── mpatof.c │ ├── omachcap.c │ ├── pgen.c │ ├── pickle.c │ ├── pswt.c │ ├── scon.c │ └── sub.c ├── cp │ ├── cp.c │ └── mkfile ├── cpp │ ├── LICENSE.gpl │ ├── cpp.c │ ├── cpp.h │ ├── eval.c │ ├── hideset.c │ ├── include.c │ ├── lex.c │ ├── macro.c │ ├── mkfile │ ├── nlist.c │ ├── test.c │ └── tokens.c ├── echo │ ├── echo.c │ └── mkfile ├── iar │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── ar.c │ └── mkfile ├── iyacc │ ├── mkfile │ ├── yacc.c │ └── yaccpar ├── ka │ ├── a.h │ ├── a.y │ ├── l.s │ ├── lex.c │ ├── mkfile │ └── note ├── kc │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── k.out.h │ ├── list.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── kl │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── asm.c │ ├── foo.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ ├── pass.c │ ├── sched.c │ └── span.c ├── kprof │ ├── kprof.c │ └── mkfile ├── ksize │ ├── ksize.c │ └── mkfile ├── kstrip │ ├── kstrip.c │ └── mkfile ├── ld │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── Upd │ ├── elf.c │ ├── elf.h │ ├── falloc.c │ ├── ld.h │ ├── mkcname │ ├── mod.c │ ├── pass.c │ ├── pobj.c │ └── sub.c ├── mk │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── README │ ├── arc.c │ ├── archive.c │ ├── bufblock.c │ ├── env.c │ ├── file.c │ ├── fns.h │ ├── graph.c │ ├── job.c │ ├── lex.c │ ├── main.c │ ├── match.c │ ├── mk.c │ ├── mk.h │ ├── mkfile │ ├── mkfile-Nt │ ├── mkfile-Plan9 │ ├── mkfile-Posix │ ├── parse.c │ ├── rc.c │ ├── recipe.c │ ├── rule.c │ ├── run.c │ ├── sh.c │ ├── shprint.c │ ├── symtab.c │ ├── var.c │ ├── varsub.c │ └── word.c ├── mkfile ├── mkppcimage │ ├── mkfile │ └── mkppcimage.c ├── ms2 │ ├── mkfile │ └── ms2.c ├── mv │ ├── mkfile │ └── mv.c ├── nm │ ├── mkfile │ └── nm.c ├── qa │ ├── Ins │ ├── a.h │ ├── a.y │ ├── branch │ ├── lex.c │ └── mkfile ├── qc │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── machcap.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── q.out.h │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── ql │ ├── asm.c │ ├── asmout.c │ ├── cnam.c │ ├── l.h │ ├── list.c │ ├── mkcname │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ ├── pass.c │ ├── sched.c │ └── span.c ├── rcsh │ ├── Nt.c │ ├── code.c │ ├── exec.c │ ├── glob.c │ ├── here.c │ ├── io.c │ ├── lex.c │ ├── main.c │ ├── mkfile │ ├── pcmd.c │ ├── pfnc.c │ ├── rc.h │ ├── rcmain │ ├── rcpath │ ├── simple.c │ ├── syn.y │ ├── trap.c │ ├── tree.c │ ├── var.c │ └── word.c ├── retired │ ├── 0a │ │ ├── a.h │ │ ├── a.y │ │ ├── l.s │ │ ├── lex.c │ │ └── mkfile │ ├── 0c │ │ ├── cgen.c │ │ ├── enam.c │ │ ├── gc.h │ │ ├── list.c │ │ ├── mkenam │ │ ├── mkfile │ │ ├── mul.c │ │ ├── peep.c │ │ ├── reg.c │ │ ├── sgen.c │ │ ├── swt.c │ │ ├── txt.c │ │ └── v.out.h │ ├── 0l │ │ ├── Nt.c │ │ ├── Plan9.c │ │ ├── Posix.c │ │ ├── asm.c │ │ ├── enam.c │ │ ├── l.h │ │ ├── list.c │ │ ├── mkfile │ │ ├── noop.c │ │ ├── obj.c │ │ ├── optab.c │ │ ├── pass.c │ │ ├── sched.c │ │ └── span.c │ ├── 1a │ │ ├── a.h │ │ ├── a.y │ │ ├── l.s │ │ ├── lex.c │ │ └── mkfile │ ├── 1c │ │ ├── cgen.c │ │ ├── enam.c │ │ ├── gc.h │ │ ├── list.c │ │ ├── mkfile │ │ ├── mul.c │ │ ├── peep.c │ │ ├── reg.c │ │ ├── sgen.c │ │ ├── swt.c │ │ └── txt.c │ ├── 1l │ │ ├── Nt.c │ │ ├── Plan9.c │ │ ├── Posix.c │ │ ├── asm.c │ │ ├── l.h │ │ ├── list.c │ │ ├── mkfile │ │ ├── obj.c │ │ ├── optab.c │ │ ├── pass.c │ │ └── span.c │ ├── 2a │ │ ├── a.h │ │ ├── a.y │ │ ├── l.s │ │ ├── lex.c │ │ └── mkfile │ ├── 2c │ │ ├── 2.out.h │ │ ├── Update │ │ ├── cgen.c │ │ ├── enam.c │ │ ├── gc.h │ │ ├── list.c │ │ ├── mkfile │ │ ├── mul.c │ │ ├── peep.c │ │ ├── reg.c │ │ ├── sgen.c │ │ ├── swt.c │ │ └── txt.c │ └── 2l │ │ ├── Nt.c │ │ ├── Plan9.c │ │ ├── Posix.c │ │ ├── asm.c │ │ ├── l.h │ │ ├── list.c │ │ ├── mkfile │ │ ├── obj.c │ │ ├── optab.c │ │ ├── pass.c │ │ └── span.c ├── rm │ ├── mkfile │ └── rm-Nt.c ├── sqz │ ├── NOTICE │ ├── mkfile │ ├── squeeze.h │ ├── sqz.c │ └── zqs.c ├── srclist │ ├── Nt.c │ ├── Plan9.c │ ├── Posix.c │ ├── mkfile │ └── srclist.c ├── tc │ ├── 5.out.h │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ └── txt.c ├── test │ ├── mkfile │ └── test-Nt.c ├── tl │ ├── asm.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ ├── pass.c │ ├── span.c │ └── thumb.c ├── va │ ├── a.h │ ├── a.y │ ├── l.s │ ├── lex.c │ ├── mkfile │ └── note ├── vc │ ├── cgen.c │ ├── enam.c │ ├── gc.h │ ├── list.c │ ├── mkenam │ ├── mkfile │ ├── mul.c │ ├── peep.c │ ├── reg.c │ ├── sgen.c │ ├── swt.c │ ├── txt.c │ └── v.out.h └── vl │ ├── asm.c │ ├── compat.c │ ├── l.h │ ├── list.c │ ├── mkfile │ ├── noop.c │ ├── obj.c │ ├── optab.c │ ├── pass.c │ ├── sched.c │ └── span.c ├── lib9 ├── NOTICE ├── argv0.c ├── charstod.c ├── cistrcmp.c ├── cistrncmp.c ├── cistrstr.c ├── cleanname.c ├── convD2M.c ├── convM2D.c ├── convM2S.c ├── convS2M.c ├── create.c ├── dirstat-Nt.c ├── dirstat-posix.c ├── dirwstat.c ├── dofmt.c ├── dorfmt.c ├── errfmt.c ├── errstr-Nt.c ├── errstr-Plan9.c ├── errstr-posix.c ├── exits.c ├── fcallfmt.c ├── fltfmt.c ├── fmt.c ├── fmtdef.h ├── fmtfd.c ├── fmtlock.c ├── fmtprint.c ├── fmtquote.c ├── fmtrune.c ├── fmtstr.c ├── fmtvprint.c ├── fprint.c ├── getcallerpc-FreeBSD-386.S ├── getcallerpc-Hp-s800.s ├── getcallerpc-Irix-mips.s ├── getcallerpc-Linux-386.S ├── getcallerpc-Linux-arm.S ├── getcallerpc-MacOSX-386.s ├── getcallerpc-MacOSX-power.s ├── getcallerpc-Solaris-386.s ├── getcallerpc-Solaris-sparc.s ├── getcallerpc-Unixware-386.s ├── getfields.c ├── getuser-Nt.c ├── getuser-posix.c ├── getwd-Nt.c ├── getwd-posix.c ├── lock-Hp-s800.s ├── lock-Irix-mips.s ├── lock-MacOSX-power.s ├── lock-Nt-386.c ├── lock-Solaris-386.s ├── lock-Solaris-sparc.s ├── lock-Unixware-386.s ├── lock.c ├── mkfile ├── mkfile-Nt ├── mkfile-Plan9 ├── mkfile-Posix ├── nulldir.c ├── pow10.c ├── print.c ├── qsort.c ├── readn.c ├── rerrstr.c ├── rune.c ├── runeseprint.c ├── runesmprint.c ├── runesnprint.c ├── runestrlen.c ├── runevseprint.c ├── sbrk-posix.c ├── seek.c ├── seprint.c ├── setbinmode-Nt.c ├── smprint.c ├── snprint.c ├── sprint.c ├── strdup.c ├── strecpy.c ├── strtoll.c ├── sysfatal.c ├── tokenize.c ├── u16.c ├── u32.c ├── u64.c ├── utfecpy.c ├── utflen.c ├── utfnlen.c ├── utfrrune.c ├── utfrune.c ├── vfprint.c ├── vseprint.c ├── vsmprint.c └── vsnprint.c ├── libbio ├── NOTICE ├── bbuffered.c ├── bfildes.c ├── bflush.c ├── bgetc.c ├── bgetd.c ├── bgetrune.c ├── binit.c ├── boffset.c ├── bprint.c ├── bputc.c ├── bputrune.c ├── brdline.c ├── brdstr.c ├── bread.c ├── bseek.c ├── bvprint.c ├── bwrite.c └── mkfile ├── libmach ├── 4.c ├── 5.c ├── 5db.c ├── 5obj.c ├── 6.c ├── 6obj.c ├── 8.c ├── 8db.c ├── 8obj.c ├── 9.c ├── 9obj.c ├── NOTICE ├── access.c ├── bootexec.h ├── elf.h ├── executable.c ├── k.c ├── kdb.c ├── kobj.c ├── machdata.c ├── map.c ├── mkfile ├── obj.c ├── obj.h ├── q.c ├── qdb.c ├── qobj.c ├── retired │ ├── 2.c │ ├── 2db.c │ ├── 2obj.c │ ├── t.c │ ├── tdb.c │ ├── tobj.c │ ├── ureg2.h │ └── uregt.h ├── setmach.c ├── swap.c ├── sym.c ├── ureg4.h ├── ureg5.h ├── ureg6.h ├── ureg8.h ├── ureg9.h ├── uregk.h ├── uregq.h ├── uregv.h ├── v.c ├── vcodas.c ├── vdb.c └── vobj.c ├── libmath ├── FPcontrol-DragonFly.c ├── FPcontrol-FreeBSD.c ├── FPcontrol-Hp.c ├── FPcontrol-Inferno.c ├── FPcontrol-Irix.c ├── FPcontrol-Linux.c ├── FPcontrol-MacOSX.c ├── FPcontrol-NetBSD.c ├── FPcontrol-Nt.c ├── FPcontrol-OpenBSD.c ├── FPcontrol-Plan9.c ├── FPcontrol-Solaris.c ├── FPcontrol-Unixware.c ├── NOTICE ├── bin │ ├── fdlibm-stubs │ ├── unif_dtoa │ └── unif_fdlibm ├── blas.c ├── dtoa.c ├── fdim.c ├── fdlibm │ ├── e_acos.c │ ├── e_acosh.c │ ├── e_asin.c │ ├── e_atan2.c │ ├── e_atanh.c │ ├── e_cosh.c │ ├── e_exp.c │ ├── e_fmod.c │ ├── e_hypot.c │ ├── e_j0.c │ ├── e_j1.c │ ├── e_jn.c │ ├── e_lgamma_r.c │ ├── e_log.c │ ├── e_log10.c │ ├── e_pow.c │ ├── e_rem_pio2.c │ ├── e_remainder.c │ ├── e_sinh.c │ ├── e_sqrt.c │ ├── fdlibm.h │ ├── k_cos.c │ ├── k_rem_pio2.c │ ├── k_sin.c │ ├── k_tan.c │ ├── readme │ ├── s_asinh.c │ ├── s_atan.c │ ├── s_cbrt.c │ ├── s_ceil.c │ ├── s_copysign.c │ ├── s_cos.c │ ├── s_erf.c │ ├── s_expm1.c │ ├── s_fabs.c │ ├── s_finite.c │ ├── s_floor.c │ ├── s_ilogb.c │ ├── s_isnan.c │ ├── s_log1p.c │ ├── s_modf.c │ ├── s_nextafter.c │ ├── s_rint.c │ ├── s_scalbn.c │ ├── s_sin.c │ ├── s_tan.c │ └── s_tanh.c ├── g_fmt.c ├── gemm.c ├── gfltconv.c ├── mkfile └── pow10.c └── libregexp ├── mkfile ├── regaux.c ├── regcomp.c ├── regcomp.h ├── regerror.c ├── regexec.c ├── regsub.c ├── rregexec.c └── rregsub.c /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | *.[8qkv596o] 3 | [8qkv965o].out 4 | [8qkv965o].emu 5 | y.output 6 | y.tab.[ch] 7 | y.debug 8 | *.a 9 | emu/*/*.root.[ch] 10 | emu/*/errstr.h 11 | 12 | syntax: regexp 13 | ^appl/.*.dis 14 | ^appl/.*.sbl 15 | ^fonts/lucida/.* 16 | ^fonts/lucidasans/.* 17 | ^fonts/lucm/.* 18 | ^tmp/.* 19 | ^contrib/.* 20 | ^fonts/lucida/.* 21 | ^usr/\.* 22 | ^grid/.* 23 | ^libinterp/cryptmod.h 24 | ^libinterp/ipintsmod.h 25 | ^libinterp/keyringif.h 26 | -------------------------------------------------------------------------------- /FreeBSD/386/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/FreeBSD/386/bin/iyacc -------------------------------------------------------------------------------- /FreeBSD/386/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/FreeBSD/386/bin/mk -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Installation 3 | 4 | These notes employ the name 'ken-cc' for "the directory containing 5 | this file". 6 | 7 | (!) See TODO.REBUILD for need to rebuild yacc to complete the install. 8 | 9 | 10 | On unixen including linuxen and macosen the configure script will 11 | generate 'mkconfig' and 'env' 12 | 13 | In this directory... 14 | 15 | ./configure # (write 'ken-cc/mkconfig' && link 'ken-cc/bin') 16 | . ./env # (prepend 'ken-cc/bin' to path per session) 17 | mk # (build tools for host platform) 18 | mk install # (install tools into 'ken-cc/bin') 19 | 20 | 21 | On Windows 22 | 23 | * Add the directory 'ken-cc/Nt/386/bin' to your PATH 24 | 25 | * Create the text file 'ken-cc/mkconfig' using the template from 26 | 27 | ken-cc/etc/mkconfig.txt 28 | 29 | * Then 'mk' && 'mk install' 30 | 31 | (installs into 'ken-cc/Nt/386/bin'). 32 | 33 | 34 | See also... 35 | 36 | docs/mk.pdf 37 | 38 | -------------------------------------------------------------------------------- /Linux/386/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Linux/386/bin/iyacc -------------------------------------------------------------------------------- /Linux/386/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Linux/386/bin/mk -------------------------------------------------------------------------------- /Linux/power/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Linux/power/bin/iyacc -------------------------------------------------------------------------------- /Linux/power/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Linux/power/bin/mk -------------------------------------------------------------------------------- /MacOSX/386/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/MacOSX/386/bin/iyacc -------------------------------------------------------------------------------- /MacOSX/386/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/MacOSX/386/bin/mk -------------------------------------------------------------------------------- /MacOSX/power/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/MacOSX/power/bin/iyacc -------------------------------------------------------------------------------- /MacOSX/power/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/MacOSX/power/bin/mk -------------------------------------------------------------------------------- /NOT.READY: -------------------------------------------------------------------------------- 1 | See TODO 2 | -------------------------------------------------------------------------------- /NetBSD/386/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/NetBSD/386/bin/iyacc -------------------------------------------------------------------------------- /NetBSD/386/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/NetBSD/386/bin/mk -------------------------------------------------------------------------------- /Nt/386/bin/cp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/cp.exe -------------------------------------------------------------------------------- /Nt/386/bin/echo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/echo.exe -------------------------------------------------------------------------------- /Nt/386/bin/gzip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/gzip.exe -------------------------------------------------------------------------------- /Nt/386/bin/mk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/mk.exe -------------------------------------------------------------------------------- /Nt/386/bin/mkdir.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/mkdir.exe -------------------------------------------------------------------------------- /Nt/386/bin/mv.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/mv.exe -------------------------------------------------------------------------------- /Nt/386/bin/rcsh.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/rcsh.exe -------------------------------------------------------------------------------- /Nt/386/bin/rm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/rm.exe -------------------------------------------------------------------------------- /Nt/386/bin/sed.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/sed.exe -------------------------------------------------------------------------------- /Nt/386/bin/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/test.exe -------------------------------------------------------------------------------- /Nt/386/bin/tr.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/tr.exe -------------------------------------------------------------------------------- /Nt/386/bin/yacc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Nt/386/bin/yacc.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Highly portable C compiler suite, including supporting tools, originally developed for Plan 9 from Bell Labs and later also used for Inferno. 2 | 3 | It targets x86, amd64, SPARC, MIPS, ARM, and PowerPC. ARM64 will shortly be added. 4 | 5 | The 680x0 and Alpha suites have been retired, but the source is still available for study. 6 | 7 | It is small and fast. It includes a stripped-down preprocessor. 8 | 9 | Because all components are written portably, it is easy to use as a cross-compiler. (On Plan 9 itself, a cross-compiler is made simply by compiling a target compiler with the host compiler. There are no extra configuration files.) 10 | 11 | The suite is pleasant to port, partly because the distribution of effort across the components is unusual. 12 | 13 | The source code of the compiler suite is included in both Plan 9 and Inferno distributions, but this provides an independent source that might be used by other projects. 14 | 15 | The project contains the source of the assemblers, compilers and loaders; supporting commands such as ar, nm, size etc.; the Acid debugger; supporting libraries; and the portable build environment, including mk. -------------------------------------------------------------------------------- /Solaris/sparc/bin/iyacc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Solaris/sparc/bin/iyacc -------------------------------------------------------------------------------- /Solaris/sparc/bin/mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/Solaris/sparc/bin/mk -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | -*-outline-*- 2 | 3 | * Need to recompile yacc for platforms not listed in REBUILD 4 | ** Run 'mk', fails at src/cmd/cc/cc.y 5 | ** cd src/cmd/yacc && mk install 6 | ** cd ../../../ && mk clean && mk install 7 | 8 | * src/cmd/6{a,c,l} 9 | ** amd64 10 | 11 | * src/cmd/7{a,c,l} 12 | ** alpha 13 | 14 | * Test all 15 | 16 | * src/cmd/cc/mkfile 17 | ** -DCPP="/bin/cpp" 18 | 19 | * #pragma src ? 20 | ** eg, $ROOT/include/bio.h 21 | ** =>? #pragma src $ROOT/include/bio.h 22 | 23 | * src/cmd/mk/Nt.c 24 | ** defines for 25 | *** char* rootdir 26 | *** char* shell 27 | 28 | * Examine all Nt.c Posix.c and Plan9.c for common shared code 29 | 30 | -------------------------------------------------------------------------------- /TODO.REBUILD: -------------------------------------------------------------------------------- 1 | # Completed rebuild of yacc 2 | # See also TODO 3 | Solaris/sparc 4 | Linux/386 5 | MacOSX/power 6 | -------------------------------------------------------------------------------- /doc/acid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/acid.pdf -------------------------------------------------------------------------------- /doc/acidpaper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/acidpaper.pdf -------------------------------------------------------------------------------- /doc/acidtut.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/acidtut.pdf -------------------------------------------------------------------------------- /doc/asm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/asm.pdf -------------------------------------------------------------------------------- /doc/compiler.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/compiler.pdf -------------------------------------------------------------------------------- /doc/lex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/lex.pdf -------------------------------------------------------------------------------- /doc/mk.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/mk.pdf -------------------------------------------------------------------------------- /doc/yacc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangguiyang/plan9-cc/e4be30417d351d7bd8a2ba494178554e16a1f089/doc/yacc.pdf -------------------------------------------------------------------------------- /etc/compilers: -------------------------------------------------------------------------------- 1 | # See *c/gc.h 2 | # and doc/compiler.{ps,pdf} 3 | 0:mips4000 4 | 1:mot68000 5 | 2:mot68020 6 | 5:arm 7 | 6:amd64 8 | 7:arm64 9 | 8:386 10 | k:sparc 11 | q:power 12 | v:mips3000 13 | -------------------------------------------------------------------------------- /etc/mkconfig.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Set the following three variables. 3 | 4 | # 5 | # Path to this directory 6 | # 7 | # On Nt systems, the ROOT path MUST be of the form `drive:/path' 8 | # 9 | ROOT=/usr/local/ken-cc 10 | 11 | # 12 | # Build system OS type (eg, MacOSX, Linux, Nt, Solaris, FreeBSD, NetBSD, Plan9) 13 | # 14 | SYSHOST=Linux 15 | 16 | # 17 | # Target system object type (eg, 386, arm, mips, power, sparc) 18 | # 19 | OBJTYPE=386 20 | 21 | 22 | # 23 | # No changes required beyond this point 24 | # 25 | SYSTARG=$SYSHOST 26 | OBJDIR=$SYSTARG/$OBJTYPE 27 | 28 | <$ROOT/mkfiles/mkhost-$SYSHOST # variables appropriate for host system 29 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE # variables used to build target object type 30 | 31 | -------------------------------------------------------------------------------- /etc/os.arch.dlist: -------------------------------------------------------------------------------- 1 | FreeBSD/386 2 | Irix/mips 3 | Linux/386 4 | Linux/power 5 | MacOSX/386 6 | MacOSX/power 7 | NetBSD/386 8 | Nt/386 9 | Plan9/386 10 | Solaris/sparc 11 | -------------------------------------------------------------------------------- /etc/os.arch.dlist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wd=$(dirname $0) 4 | wd=$(cd $wd; pwd) 5 | rd=$(dirname $wd) 6 | 7 | for os in $(cat ${wd}/os.dlist ); do for arch in $(ls ${rd}/${os}); do echo $os/$arch; done; done 8 | 9 | -------------------------------------------------------------------------------- /etc/os.dlist: -------------------------------------------------------------------------------- 1 | FreeBSD 2 | Linux 3 | MacOSX 4 | NetBSD 5 | Nt 6 | Plan9 7 | Solaris 8 | -------------------------------------------------------------------------------- /include/ar.h: -------------------------------------------------------------------------------- 1 | #define ARMAG "!\n" 2 | #define SARMAG 8 3 | 4 | #define ARFMAG "`\n" 5 | #define SARNAME 16 6 | 7 | struct ar_hdr 8 | { 9 | char name[SARNAME]; 10 | char date[12]; 11 | char uid[6]; 12 | char gid[6]; 13 | char mode[8]; 14 | char size[10]; 15 | char fmag[2]; 16 | }; 17 | #define SAR_HDR (SARNAME+44) 18 | -------------------------------------------------------------------------------- /include/rdbg.h: -------------------------------------------------------------------------------- 1 | /* Remote kernel debug protocol */ 2 | enum 3 | { 4 | Terr='0', /* not sent */ 5 | Rerr, 6 | Tmget, 7 | Rmget, 8 | Tmput, 9 | Rmput, 10 | 11 | Tspid, /* obsolete */ 12 | Rspid, /* obsolete */ 13 | Tproc, 14 | Rproc, 15 | Tstatus, 16 | Rstatus, 17 | Trnote, 18 | Rrnote, 19 | 20 | Tstartstop, 21 | Rstartstop, 22 | Twaitstop, 23 | Rwaitstop, 24 | Tstart, 25 | Rstart, 26 | Tstop, 27 | Rstop, 28 | Tkill, 29 | Rkill, 30 | 31 | Tcondbreak, 32 | Rcondbreak, 33 | 34 | RDBMSGLEN = 10 /* tag byte, 9 data bytes */ 35 | }; 36 | -------------------------------------------------------------------------------- /lib/rcmain: -------------------------------------------------------------------------------- 1 | # rcmain: 9pm version 2 | if(~ $#home 0) home=/ 3 | if(~ $#ifs 0) ifs=' 4 | ' 5 | switch($#prompt){ 6 | case 0 7 | case 1 8 | prompt=('% ' ' ') 9 | } 10 | if(~ $rcname v.out) prompt=('broken! ' ' ') 11 | if(! ~ $#cflag 0){ 12 | if(flag l && test -r $home/lib/profile) . $home/lib/profile 13 | status='' 14 | eval $cflag 15 | } 16 | if not if(flag i){ 17 | if(flag l && test -r $home/lib/profile) . $home/lib/profile 18 | status='' 19 | if(! ~ $#* 0) . $* 20 | if not . -i 'stdin$' 21 | } 22 | if not { 23 | if(~ $#* 0) . 'stdin$' 24 | if not{ 25 | status='' 26 | . $* 27 | } 28 | } 29 | exit $status 30 | -------------------------------------------------------------------------------- /man/1/ksize: -------------------------------------------------------------------------------- 1 | .TH KSIZE 10.1 2 | .SH NAME 3 | ksize \- print size of kernel images 4 | .SH SYNOPSIS 5 | .B ksize 6 | [ 7 | .I file ... 8 | ] 9 | .SH DESCRIPTION 10 | .I Ksize 11 | prints the size of the segments for each of the argument executable files 12 | (default 13 | .BR 8.out ). 14 | The format is 15 | .IP 16 | .IB textsize t 17 | + 18 | .IB datasize d 19 | + 20 | .IB bsssize b 21 | = 22 | .I total 23 | .PP 24 | where the numbers are in bytes. 25 | .SH SOURCE 26 | .B /utils/ksize 27 | .SH "SEE ALSO 28 | .IR kstrip (10.1), 29 | .IR a.out (10.6) 30 | -------------------------------------------------------------------------------- /man/1/kstrip: -------------------------------------------------------------------------------- 1 | .TH KSTRIP 10.1 2 | .SH NAME 3 | kstrip \- remove symbols from kernel images 4 | .SH SYNOPSIS 5 | .B kstrip 6 | .I file ... 7 | .PP 8 | .B kstrip 9 | .B -o 10 | .I ofile 11 | .I file 12 | .SH DESCRIPTION 13 | .I Kstrip 14 | removes symbol table segments from executable files, 15 | rewriting the files in place. 16 | Stripping a file requires write permission on the file 17 | and the directory it is in. 18 | .PP 19 | If the 20 | .B -o 21 | flag is given, 22 | the single input file 23 | .I file 24 | is stripped and the result written to 25 | .IR ofile . 26 | .I File 27 | is unchanged. 28 | .SH SOURCE 29 | .B /utils/kstrip 30 | .SH "SEE ALSO" 31 | .IR ksize (10.1), 32 | .IR a.out (10.6) 33 | -------------------------------------------------------------------------------- /mkconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Set the following 4 variables. The host system is the system where 3 | # the software will be built; the target system is where it will run. 4 | # They are almost always the same. 5 | 6 | # On Nt systems, the ROOT path MUST be of the form 'drive:/path' 7 | ROOT=$HOME/hg/ken-cc 8 | 9 | # build system OS type 10 | SYSHOST=Linux 11 | 12 | # target system OS type 13 | SYSTARG=Linux 14 | 15 | # target system object type 16 | OBJTYPE=386 17 | 18 | # 19 | # no changes required beyond this point 20 | # 21 | OBJDIR=$SYSTARG/$OBJTYPE 22 | 23 | <$ROOT/mkfiles/mkhost-$SYSHOST # variables appropriate for host system 24 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE # variables used to build target object type 25 | 26 | -------------------------------------------------------------------------------- /mkfiles/mkfile-FreeBSD-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | 11 | AS= cc -c 12 | ASFLAGS= 13 | 14 | CC= cc -c 15 | CFLAGS= -g\ 16 | -O\ 17 | -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\ 18 | -I$ROOT/FreeBSD/386/include\ 19 | -I$ROOT/include\ 20 | -I/usr/local/include\ 21 | -DFREEBSD_386 22 | 23 | ANSICPP= 24 | LD= cc 25 | LDFLAGS=\ 26 | -L/usr/local/lib\ 27 | 28 | SYSLIBS= 29 | 30 | YACC= iyacc 31 | YFLAGS= -d 32 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Linux-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | 11 | AS= cc -c -m32 12 | ASFLAGS= 13 | 14 | CC= cc -c -m32 15 | CFLAGS= -g\ 16 | -O\ 17 | -I$ROOT/Linux/386/include\ 18 | -I$ROOT/include\ 19 | -DLINUX_386 20 | 21 | ANSICPP= 22 | LD= cc -m32 23 | LDFLAGS= 24 | 25 | SYSLIBS= 26 | 27 | YACC= iyacc 28 | YFLAGS= -d 29 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Linux-arm: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= arm 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | 11 | AS= arm-gcc -c 12 | ASFLAGS= 13 | 14 | CC= arm-gcc -c 15 | CFLAGS= -O\ 16 | -I$ROOT/Linux/arm/include\ 17 | -I$ROOT/include\ 18 | -DLINUX_ARM 19 | 20 | ANSICPP= 21 | LD= arm-gcc 22 | LDFLAGS= 23 | 24 | SYSLIBS= 25 | 26 | YACC= iyacc 27 | YFLAGS= -d 28 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Linux-power: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= power 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= crvs 10 | 11 | AS= cc -c -m32 12 | ASFLAGS= 13 | 14 | CC= cc -c -m32 15 | CFLAGS= -g\ 16 | -O\ 17 | -I$ROOT/Linux/power/include\ 18 | -I$ROOT/include\ 19 | 20 | ANSICPP= 21 | LD= cc -m32 22 | LDFLAGS= 23 | 24 | SYSLIBS= 25 | 26 | YACC= iyacc 27 | YFLAGS= -d 28 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Linux-spim: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= spim 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= mipsel-linux-uclibc-ar 9 | ARFLAGS= crvs 10 | 11 | AS= mipsel-linux-uclibc-gcc -c -mips32 12 | ASFLAGS= 13 | 14 | CC= mipsel-linux-uclibc-gcc -c -mips32 15 | CFLAGS= -g\ 16 | -Os\ 17 | -I$ROOT/Linux/spim/include\ 18 | -I$ROOT/include\ 19 | 20 | ANSICPP= 21 | LD= mipsel-linux-uclibc-gcc 22 | LDFLAGS= 23 | 24 | SYSLIBS= 25 | 26 | YACC= iyacc 27 | YFLAGS= -d 28 | -------------------------------------------------------------------------------- /mkfiles/mkfile-MacOSX-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | A= a 11 | 12 | AS= cc -c -arch i386 13 | ASFLAGS= 14 | 15 | ISYSROOT= -isysroot /Developer/SDKs/MacOSX10.4u.sdk 16 | 17 | CC= cc -c 18 | COPTFLAGS= -Os 19 | CDEBUGFLAGS= 20 | CTHREADFLAGS= 21 | CFLAGS= -arch i386\ 22 | -mmacosx-version-min=10.4\ 23 | -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit -Wno-four-char-constants -Wno-unknown-pragmas\ 24 | -pipe\ 25 | -fno-strict-aliasing\ 26 | -no-cpp-precomp\ 27 | -mno-fused-madd\ 28 | -I$ROOT/MacOSX/386/include\ 29 | -I$ROOT/include\ 30 | $COPTFLAGS $CDEBUGFLAGS\ 31 | 32 | LD= cc -arch i386 33 | LDFLAGS=\ 34 | -mmacosx-version-min=10.4\ 35 | -multiply_defined suppress 36 | 37 | SYSLIBS= 38 | 39 | YACC= iyacc 40 | YFLAGS= -d 41 | 42 | -------------------------------------------------------------------------------- /mkfiles/mkfile-MacOSX-power: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= power 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | A= a 11 | 12 | AS= cc -c -arch ppc 13 | ASFLAGS= 14 | 15 | CC= cc -c 16 | CFLAGS= -arch ppc\ 17 | -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit -Wno-four-char-constants -Wno-unknown-pragmas\ 18 | -pipe\ 19 | -I$ROOT/MacOSX/power/include\ 20 | -I$ROOT/include\ 21 | -malign-natural -O2 22 | COPTFLAGS= -O2 23 | CDEBFLAGS= -g 24 | CTHREADFLAGS= 25 | 26 | LD= cc -arch ppc 27 | LDFLAGS= -multiply_defined suppress 28 | 29 | SYSLIBS= 30 | 31 | YACC= iyacc 32 | YFLAGS= -d 33 | -------------------------------------------------------------------------------- /mkfiles/mkfile-NetBSD-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | 11 | AS= cc -c 12 | ASFLAGS= 13 | 14 | CC= cc -c 15 | CFLAGS= -g\ 16 | -O\ 17 | -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\ 18 | -I$ROOT/NetBSD/386/include\ 19 | -I$ROOT/include\ 20 | 21 | ANSICPP= 22 | LD= cc 23 | LDFLAGS= 24 | 25 | SYSLIBS= 26 | 27 | YACC= iyacc 28 | YFLAGS= -d 29 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Nt-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Nt 2 | TARGSHTYPE= rc 3 | CPUS= 386 4 | 5 | O= obj 6 | OS= obj 7 | 8 | AR= LIB 9 | ARFLAGS= -nologo 10 | ARPREFIX= -out: 11 | 12 | AS= ml 13 | ASFLAGS= -c\ 14 | -nologo\ 15 | -coff\ 16 | -Cx\ 17 | -Zm\ 18 | -DQUIET\ 19 | -Di386\ 20 | 21 | CC= cl 22 | CFLAGS= -c\ 23 | -nologo\ 24 | -W3\ 25 | -Zi\ 26 | -MT\ 27 | -D_WIN32_WINNT=0x0400\ 28 | -I$ROOT/Nt/386/include\ 29 | -I$ROOT/include\ 30 | $XCFLAGS\ 31 | 32 | ANSICPP= 33 | LD= link 34 | LDFLAGS= $LDEBUG -nologo -incremental:no -map 35 | # LDFLAGS= -nologo -incremental:no -debug 36 | 37 | SYSLIBS= binmode.obj 38 | 39 | YACC= iyacc 40 | YFLAGS= -d 41 | -------------------------------------------------------------------------------- /mkfiles/mkfile-OpenBSD-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= ruvs 10 | 11 | AS= cc -c 12 | ASFLAGS= 13 | 14 | CC= cc -c 15 | CFLAGS= -g\ 16 | -O\ 17 | -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\ 18 | -I$ROOT/OpenBSD/386/include\ 19 | -I$ROOT/include\ 20 | -DOPENBSD_386 -fno-stack-protector 21 | 22 | ANSICPP= 23 | LD= cc 24 | LDFLAGS= 25 | 26 | SYSLIBS= 27 | 28 | YACC= iyacc 29 | YFLAGS= -d 30 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= 8 6 | OS= v851ok0q2t6 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= 8a 12 | ASFLAGS= 13 | 14 | CC= 8c 15 | CFLAGS= -wFVT -I$ROOT/Plan9/386/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= 8l 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-68020: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= 2 6 | OS= v851ok0q2t6 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= 2a 12 | ASFLAGS= 13 | 14 | CC= 2c 15 | CFLAGS= -wFV -I$ROOT/Plan9/68020/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= 2l 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-amd64: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= 6 6 | OS= v851ok0q26 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= 6a 12 | ASFLAGS= 13 | 14 | CC= 6c 15 | CFLAGS= -wFV -I$ROOT/Plan9/amd64/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= 6l 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-mips: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= v 6 | OS= v851ok0q2t6 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= va 12 | ASFLAGS= 13 | 14 | CC= vc 15 | CFLAGS= -wFV -I$ROOT/Plan9/mips/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= vl 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-power: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= q 6 | OS= v851ok0q2t6 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= qa 12 | ASFLAGS= 13 | 14 | CC= qc 15 | CFLAGS= -wFV -I$ROOT/Plan9/power/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= ql 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Plan9-sparc: -------------------------------------------------------------------------------- 1 | TARGMODEL= Plan9 2 | TARGSHTYPE= rc 3 | CPUS= 386 sparc mips power amd64 4 | 5 | O= k 6 | OS= v851ok0q2t6 7 | 8 | AR= ar 9 | ARFLAGS= vu 10 | 11 | AS= ka 12 | ASFLAGS= 13 | 14 | CC= kc 15 | CFLAGS= -wFV -I$ROOT/Plan9/sparc/include -I$ROOT/include 16 | ANSICPP= -p 17 | 18 | LD= kl 19 | LDFLAGS= 20 | 21 | SYSLIBS=-lc 22 | 23 | YACC= yacc 24 | YFLAGS= -d 25 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Solaris-386: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= 386 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= cvru 10 | 11 | AS= cc 12 | ASFLAGS= -c 13 | 14 | CC= cc 15 | CFLAGS= -c\ 16 | -mt\ 17 | -g\ 18 | -fstore\ 19 | -w\ 20 | -xCC \ 21 | -Xa\ 22 | -I$ROOT/Solaris/386/include\ 23 | -I$ROOT/include\ 24 | -I/usr/openwin/share/include\ 25 | 26 | ANSICPP= 27 | LD= cc 28 | LDFLAGS= $LDFLAGS\ 29 | -mt\ 30 | -L/usr/openwin/lib\ 31 | 32 | SYSLIBS= 33 | EMULIBS= -lnsl -lsocket -lX11 -lm -lposix4 34 | 35 | YACC= iyacc 36 | YFLAGS= -d 37 | -------------------------------------------------------------------------------- /mkfiles/mkfile-Solaris-sparc: -------------------------------------------------------------------------------- 1 | TARGMODEL= Posix 2 | TARGSHTYPE= sh 3 | CPUS= sparc 4 | 5 | O= o 6 | OS= o 7 | 8 | AR= ar 9 | ARFLAGS= cvru 10 | 11 | YACC= iyacc 12 | YFLAGS= -d 13 | 14 | AS= gcc 15 | ASFLAGS= -c 16 | 17 | CC=gcc 18 | CFLAGS= -c\ 19 | -g\ 20 | -O\ 21 | -munaligned-doubles\ 22 | -threads\ 23 | -Wimplicit\ 24 | -I$ROOT/Solaris/sparc/include\ 25 | -I$ROOT/include\ 26 | -I/usr/openwin/share/include\ 27 | 28 | ANSICPP= 29 | LD= gcc 30 | LDFLAGS=-L/usr/openwin/lib\ 31 | 32 | SYSLIBS= 33 | EMULIBS= -lthread -lsocket -lm -lX11 -lXext -lnsl -lposix4 34 | 35 | # use the following settings in order to use the native sun C compiler 36 | # rather than gcc. 37 | # this has not been tested in this release. 38 | 39 | # AS= cc 40 | # ASFLAGS= -c 41 | # 42 | # CC= cc 43 | # CFLAGS= -c\ 44 | # -mt\ 45 | # -g\ 46 | # -w\ 47 | # -xCC \ 48 | # -Xa\ 49 | # -I$ROOT/Solaris/sparc/include\ 50 | # -I$ROOT/include\ 51 | # -I/usr/openwin/share/include\ 52 | # 53 | # LD= cc 54 | # LDFLAGS= -mt\ 55 | # -L/usr/openwin/lib\ 56 | # 57 | # SYSLIBS= 58 | # EMULIBS= -lsunmath -lsocket -lm -lX11 -lXext -lnsl -lposix4 59 | -------------------------------------------------------------------------------- /mkfiles/mkhost-FreeBSD: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = Unixware 3 | 4 | SHELLTYPE= sh 5 | SHELLNAME= /bin/sh 6 | HOSTMODEL= Posix 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= ndate 11 | KSIZE= ksize 12 | AWK= awk 13 | CP= cp 14 | ECHO= echo 15 | FALSE= false 16 | MKDIR= mkdir -p 17 | RM= rm -f 18 | RMDIR= rmdir 19 | TRUE= true 20 | -------------------------------------------------------------------------------- /mkfiles/mkhost-Linux: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = Linux 3 | 4 | SHELLTYPE= sh 5 | SHELLNAME= /bin/sh 6 | HOSTMODEL= Posix 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= ndate 11 | KSIZE= ksize 12 | AWK= awk 13 | -------------------------------------------------------------------------------- /mkfiles/mkhost-MacOSX: -------------------------------------------------------------------------------- 1 | # 2 | # Supports all Darwin based systems (Darwin, Mac OS X, Mac OS X Server) 3 | # Variables for host system type = Darwin 4 | # 5 | 6 | SHELLTYPE= sh 7 | SHELLNAME= /bin/sh 8 | HOSTMODEL= Posix 9 | OSTARG= os 10 | 11 | DATA2S= data2s 12 | NDATE= ndate 13 | KSIZE= ksize 14 | AWK= awk 15 | CP= cp 16 | ECHO= echo 17 | FALSE= false 18 | MKDIR= mkdir -p 19 | RM= rm -f 20 | RMDIR= rmdir 21 | TRUE= true 22 | 23 | JAVAC= /usr/bin/javac 24 | MACOSINF=caseinsensitive # nobble .S rules 25 | -------------------------------------------------------------------------------- /mkfiles/mkhost-NetBSD: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = NetBSD 3 | 4 | SHELLTYPE= sh 5 | SHELLNAME= /bin/sh 6 | HOSTMODEL= Posix 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= date +'%s' 11 | KSIZE= ksize 12 | AWK= awk 13 | CP= cp 14 | ECHO= echo 15 | FALSE= false 16 | MKDIR= mkdir -p 17 | RM= rm -f 18 | RMDIR= rmdir 19 | TRUE= true 20 | -------------------------------------------------------------------------------- /mkfiles/mkhost-Nt: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = Nt (or Windows 95) 3 | 4 | SHELLTYPE= nt 5 | SHELLNAME= rcsh 6 | HOSTMODEL= Nt 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= ndate 11 | KSIZE= ksize 12 | AWK= awk 13 | 14 | #COMSPEC= $ROOT/$SYSHOST/$OBJTYPE/bin/rcsh.exe 15 | -------------------------------------------------------------------------------- /mkfiles/mkhost-OpenBSD: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = OpenBSD 3 | 4 | SHELLTYPE= sh 5 | SHELLNAME= /bin/sh 6 | HOSTMODEL= Posix 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= ndate 11 | KSIZE= ksize 12 | AWK= awk 13 | CP= cp 14 | ECHO= echo 15 | FALSE= false 16 | MKDIR= mkdir -p 17 | RM= rm -f 18 | RMDIR= rmdir 19 | TRUE= true 20 | -------------------------------------------------------------------------------- /mkfiles/mkhost-Plan9: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = Plan9 3 | 4 | SHELLTYPE= rc 5 | SHELLNAME= rc 6 | HOSTMODEL= Plan9 7 | OSTARG= Inferno 8 | 9 | DATA2S= data2s 10 | NDATE= date -n 11 | KSIZE= size 12 | AWK= awk 13 | -------------------------------------------------------------------------------- /mkfiles/mkhost-Solaris: -------------------------------------------------------------------------------- 1 | 2 | # Variables for host system type = Solaris 3 | 4 | SHELLTYPE= sh 5 | SHELLNAME= /bin/sh 6 | HOSTMODEL= Posix 7 | OSTARG= os 8 | 9 | DATA2S= data2s 10 | NDATE= ndate 11 | KSIZE= ksize 12 | AWK= nawk 13 | -------------------------------------------------------------------------------- /mkfiles/mklibsubdirs: -------------------------------------------------------------------------------- 1 | all:V: all-$SHELLTYPE 2 | install:V: install-$SHELLTYPE 3 | uninstall:V: uninstall-$SHELLTYPE 4 | nuke:V: nuke-$SHELLTYPE 5 | clean:V: clean-$SHELLTYPE 6 | 7 | %-rc %-nt:QV: 8 | for (j in $DIRS) 9 | { 10 | { 11 | test -d $j && { 12 | echo '@{builtin cd' $j ';' mk $MKFLAGS 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE $stem'}' 13 | @{builtin cd $j; mk $MKFLAGS 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE $stem} 14 | } 15 | } || test ! -e $j 16 | } 17 | 18 | %-sh:QV: 19 | for j in $DIRS 20 | do 21 | if test -d $j; then 22 | echo "(cd $j; mk $MKFLAGS SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE $stem)" 23 | (cd $j; mk $MKFLAGS 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE $stem) || exit 1 24 | fi || test ! -e $j 25 | done 26 | -------------------------------------------------------------------------------- /mkfiles/mkone-nt: -------------------------------------------------------------------------------- 1 | libs=${LIBS:%=$ROOT/$OBJDIR/lib/lib%.a} 2 | TARGPROG=$TARG.exe 3 | 4 | all:V: $O.out 5 | 6 | install:V: $BIN/$TARGPROG 7 | 8 | installall:V: 9 | for objtype in $CPUS 10 | do 11 | mk $MKFLAGS install 12 | done 13 | 14 | nuke:V: nuke-std 15 | 16 | clean:V: clean-std 17 | 18 | $O.out: $OFILES $libs 19 | $LD $LDFLAGS -out:$target $OFILES $libs $SYSLIBS 20 | 21 | %.$O: $HFILES # don't combine with following %.$O rules 22 | 23 | %.$O: %.c 24 | $CC $CFLAGS $stem.c 25 | 26 | %.$O: %.s 27 | $AS $ASFLAGS $stem.s 28 | 29 | y.tab.h y.tab.c: $YFILES 30 | $YACC $YFLAGS $YFILES 31 | 32 | clean-std:V: 33 | rm -f *.$O *.exe $O.out y.tmp.* 34 | rm -f y.tab.? y.debug y.output *.pdb *.pch 35 | 36 | nuke-std:V: clean-std 37 | rm -f y.tab.? y.debug y.output *.pdb *.pch 38 | 39 | $BIN/%: $O.out 40 | rm -f $BIN/$stem && cp $O.out $BIN/$stem 41 | -------------------------------------------------------------------------------- /mkfiles/mkone-rc: -------------------------------------------------------------------------------- 1 | libs=${LIBS:%=$ROOT/$OBJDIR/lib/lib%.a} 2 | 3 | all:V: $O.out 4 | 5 | install:V: $BIN/$TARG 6 | 7 | safeinstall: $O.out 8 | mv $BIN/$TARG $BIN/$TARG.`{date -n} 9 | cp $O.out $BIN/$TARG 10 | 11 | installall:V: 12 | for(objtype in $CPUS) 13 | mk $MKFLAGS install 14 | 15 | nuke:V: nuke-std 16 | 17 | clean:V: clean-std 18 | 19 | $O.out: $OFILES $libs 20 | $LD $LDFLAGS $OFILES $libs $SYSLIBS 21 | 22 | %.$O: $HFILES # don't combine with following %.$O rules 23 | 24 | %.$O: %.c 25 | $CC $CFLAGS $stem.c 26 | 27 | %.$O: %.s 28 | $AS $ASFLAGS $stem.s 29 | 30 | y.tab.h y.tab.c: $YFILES 31 | $YACC $YFLAGS $YFILES 32 | 33 | nuke-std:V: clean-std 34 | rm -f y.tab.? y.debug y.output 35 | 36 | clean-std:V: 37 | rm -f *.[$OS] [$OS].out 38 | 39 | $BIN/%: $O.out 40 | rm -f $BIN/$stem && cp $O.out $BIN/$stem 41 | -------------------------------------------------------------------------------- /mkfiles/mkone-sh: -------------------------------------------------------------------------------- 1 | libs=${LIBS:%=$ROOT/$OBJDIR/lib/lib%.a} 2 | 3 | all:V: $O.out 4 | 5 | install:V: $BIN/$TARG 6 | 7 | installall:V: 8 | for objtype in $CPUS 9 | do 10 | mk $MKFLAGS install 11 | done 12 | 13 | nuke:V: nuke-std 14 | 15 | clean:V: clean-std 16 | 17 | $O.out: $OFILES $libs 18 | $LD $LDFLAGS -o $target $OFILES $libs $SYSLIBS 19 | 20 | %.$O: $HFILES # don't combine with following %.$O rules 21 | 22 | %.$O: %.c 23 | $CC $CFLAGS -o $target $stem.c 24 | 25 | %.$O: %.s 26 | $AS $ASFLAGS -o $target $stem.s 27 | 28 | %.$O: %.S$MACOSINF 29 | $AS $ASFLAGS -o $target $stem.S 30 | 31 | y.tab.h y.tab.c: $YFILES 32 | $YACC $YFLAGS $YFILES 33 | 34 | clean-std:V: 35 | rm -f core [$OS].out 36 | rm -f `echo $OS | sed 's/./ *.&/g'` 37 | 38 | nuke-std:V: clean-std 39 | rm -f y.tab.? y.debug y.output 40 | 41 | $BIN/%: $O.out 42 | rm -f $BIN/$stem && cp $O.out $BIN/$stem 43 | -------------------------------------------------------------------------------- /mkfiles/mksubdirs: -------------------------------------------------------------------------------- 1 | all:V: all-$SHELLTYPE 2 | install:V: install-$SHELLTYPE 3 | uninstall:V: uninstall-$SHELLTYPE 4 | nuke:V: nuke-$SHELLTYPE 5 | clean:V: clean-$SHELLTYPE 6 | 7 | %-rc %-nt:QV: 8 | for (j in $DIRS) 9 | { 10 | { 11 | test -d $j && { 12 | echo '@{builtin cd' $j '; mk $MKFLAGS $stem}' 13 | @{builtin cd $j; mk $MKFLAGS $stem} 14 | } 15 | } || test ! -e $j 16 | } 17 | 18 | %-sh:QV: 19 | for j in $DIRS 20 | do 21 | if test -d $j; then 22 | echo "(cd $j; mk $MKFLAGS $stem)" 23 | (cd $j; mk $MKFLAGS $stem) || exit 1 24 | fi || test ! -e $j 25 | done 26 | -------------------------------------------------------------------------------- /mkfiles/mksyslib-nt: -------------------------------------------------------------------------------- 1 | # 2 | # Rules for updating a library with Nt rcsh 3 | # 4 | LIBDIR=$ROOT/$OBJDIR/lib 5 | LIBRARY=$LIBDIR/$LIB 6 | LIBOBJ=${OFILES:%=$LIBRARY(%)} 7 | 8 | default:V: all 9 | 10 | all install:V: $LIBRARY 11 | 12 | installall:V: 13 | for (objtype in $CPUS) 14 | mk $MKFLAGS install 15 | 16 | clean:V: clean-std 17 | 18 | nuke:V: nuke-std 19 | 20 | LIB1=${LIBRARY:%=$ARPREFIX%} 21 | 22 | $LIBRARY: $LIBOBJ $OFILES 23 | $AR $ARFLAGS $LIB1 $OFILES 24 | 25 | $LIBRARY(%.$O):N: %.$O 26 | 27 | %.$O: $HFILES # don't combine with following %.$O rules 28 | 29 | %.$O: %.c 30 | $CC $CFLAGS $stem.c 31 | 32 | %.$O: %.s 33 | $AS $ASFLAGS $stem.s 34 | 35 | y.tab.h y.tab.c: $YFILES 36 | $YACC $YFLAGS $prereq 37 | 38 | clean-std:V: 39 | rm -f *.$O y.tmp.* 40 | rm -f y.tab.? y.output y.error *.pdb *.pch 41 | 42 | nuke-std:V: clean-std 43 | rm -f y.tab.? y.output y.error *.pdb *.pch 44 | rm -f $LIBRARY 45 | 46 | #nuke-std:V: clean-std $LIBDIR/fake.lib 47 | # rm -f y.tab.? y.output y.error *.pdb *.pch 48 | # cp $LIBDIR/fake.lib $LIBRARY 49 | # 50 | #$LIBDIR/fake.lib: 51 | # echo 'void axzzzzzzz(void) { return; }' > fooxx.c 52 | # $CC $CFLAGS fooxx.c 53 | # $AR $ARFLAGS -out:$target fooxx.obj 54 | # rm -f fooxx.* 55 | -------------------------------------------------------------------------------- /mkfiles/mksyslib-rc: -------------------------------------------------------------------------------- 1 | # 2 | # Rules for updating a library with rc 3 | # 4 | LIBDIR=$ROOT/$OBJDIR/lib 5 | LIBRARY=$LIBDIR/$LIB 6 | LIBOBJ=${OFILES:%=$LIBRARY(%)} 7 | 8 | default:V: all 9 | 10 | all install:V: $LIBRARY 11 | 12 | installall:V: 13 | for(objtype in $CPUS) 14 | mk $MKFLAGS install 15 | 16 | clean:V: clean-std 17 | 18 | nuke:V: nuke-std 19 | 20 | $LIBRARY: $LIBOBJ 21 | $AR $ARFLAGS $target $newmember 22 | 23 | $LIBRARY(%.$O):N: %.$O 24 | 25 | %.$O: $HFILES # don't combine with following %.$O rules 26 | 27 | %.$O: %.c 28 | $CC $CFLAGS $stem.c 29 | 30 | %.$O: %.s 31 | $AS $ASFLAGS $stem.s 32 | 33 | y.tab.h y.tab.c: $YFILES 34 | $YACC $YFLAGS $prereq 35 | 36 | clean-std:V: 37 | rm -f *.[$OS] [$OS].out 38 | 39 | nuke-std:V: clean-std 40 | rm -f y.tab.? y.output y.error 41 | rm -f $LIBRARY 42 | -------------------------------------------------------------------------------- /mkfiles/mksyslib-sh: -------------------------------------------------------------------------------- 1 | # 2 | # Rules for updating a library with sh 3 | # 4 | LIBDIR=$ROOT/$OBJDIR/lib 5 | LIBRARY=$LIBDIR/$LIB 6 | LIBOBJ=${OFILES:%=$LIBRARY(%)} 7 | 8 | default:V: all 9 | 10 | all install:V: $LIBRARY 11 | 12 | installall:V: 13 | for objtype in $CPUS 14 | do 15 | mk $MKFLAGS install 16 | done 17 | 18 | clean:V: clean-std 19 | 20 | nuke:V: nuke-std 21 | 22 | $LIBRARY: $LIBOBJ 23 | $AR $ARFLAGS $target $newmember 24 | 25 | $LIBRARY(%.$O):N: %.$O 26 | 27 | %.$O: $HFILES # don't combine with following %.$O rules 28 | 29 | %.$O: %.c 30 | $CC $CFLAGS $stem.c 31 | 32 | %.$O: %.s 33 | $AS $ASFLAGS $stem.s 34 | 35 | %.$O: %.S$MACOSINF 36 | $AS $ASFLAGS -o $target $stem.S 37 | 38 | y.tab.h y.tab.c: $YFILES 39 | $YACC $YFLAGS $prereq 40 | 41 | clean-std:V: 42 | rm -f $O.out 43 | rm -f y.tab.? y.output y.error 44 | rm -f `echo $OS | sed 's/./ *.&/g'` 45 | 46 | nuke-std:V: clean-std 47 | rm -f y.tab.? y.output y.error 48 | rm -f $LIBRARY 49 | -------------------------------------------------------------------------------- /src/cmd/5a/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5a 4 | 5 | OFILES=\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | 9 | HFILES=\ 10 | ../5c/5.out.h\ 11 | y.tab.h\ 12 | a.h\ 13 | 14 | YFILES=a.y\ 15 | 16 | LIBS=cc bio 9 # order is important 17 | 18 | BIN=$ROOT/$OBJDIR/bin 19 | 20 | <$ROOT/mkfiles/mkone-$SHELLTYPE 21 | 22 | YFLAGS=-D1 -d 23 | 24 | lex.$O: ../cc/macbody ../cc/lexbody 25 | 26 | $ROOT/$OBJDIR/lib/libcc.a: 27 | cd ../cc 28 | mk $MKFLAGS install 29 | mk $MKFLAGS clean 30 | -------------------------------------------------------------------------------- /src/cmd/5c/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../5c/5.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/5c/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5c 4 | 5 | OFILES=\ 6 | cgen.$O\ 7 | enam.$O\ 8 | list.$O\ 9 | mul.$O\ 10 | peep.$O\ 11 | pgen.$O\ 12 | pswt.$O\ 13 | reg.$O\ 14 | sgen.$O\ 15 | swt.$O\ 16 | txt.$O\ 17 | 18 | HFILES=\ 19 | gc.h\ 20 | 5.out.h\ 21 | ../cc/cc.h\ 22 | 23 | LIBS=cc bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | 29 | $ROOT/$OBJDIR/lib/libcc.a: 30 | cd ../cc 31 | mk $MKFLAGS install 32 | mk $MKFLAGS clean 33 | 34 | %.$O: ../cc/%.c 35 | $CC -I. $CFLAGS ../cc/$stem.c 36 | -------------------------------------------------------------------------------- /src/cmd/5coff/auxi.h: -------------------------------------------------------------------------------- 1 | #define COFFCVT 2 | #define Sym Symx 3 | #include "../5l/l.h" 4 | #undef Sym 5 | #include 6 | 7 | /* 8 | * auxi.c 9 | */ 10 | extern Symx *hash[NHASH]; 11 | Symx *lookupsym(char*, int); 12 | void beginsym(void); 13 | void endsym(void); 14 | void newsym(int, char*, long, int); 15 | 16 | extern long autosize; 17 | extern Prog *firstp, *textp, *curtext, *lastp, *etextp; 18 | 19 | /* 20 | * coff.c 21 | */ 22 | void coffhdr(void); 23 | void coffsym(void); 24 | void cofflc(void); 25 | void endsym(void); 26 | 27 | /* 28 | * 5coff.c 29 | */ 30 | void cflush(void); 31 | void lput(long); 32 | void cput(int); 33 | void hputl(int); 34 | void lputl(long); 35 | long entryvalue(void); 36 | void diag(char*, ...); 37 | extern long HEADR; /* length of header */ 38 | extern long INITDAT; /* data location */ 39 | extern long INITRND; /* data round above text location */ 40 | extern long INITTEXT; /* text location */ 41 | extern long INITENTRY; /* entry point */ 42 | extern long textsize; 43 | extern long datsize; 44 | extern long bsssize; 45 | extern int cout; 46 | extern int thumb; 47 | -------------------------------------------------------------------------------- /src/cmd/5coff/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5coff 4 | 5 | OFILES= 5coff.$O\ 6 | coff.$O\ 7 | auxi.$O\ 8 | 9 | HFILES=\ 10 | a.out.h\ 11 | bio.h\ 12 | mach.h\ 13 | 14 | LIBS=mach bio 9 # order matters. 15 | 16 | 17 | BIN=$ROOT/$OBJDIR/bin 18 | 19 | <$ROOT/mkfiles/mkone-$SHELLTYPE 20 | 21 | $O.readcoff: readcoff.$O 22 | $LD $LDFLAGS -o $target readcoff.$O $libs $SYSLIBS 23 | -------------------------------------------------------------------------------- /src/cmd/5cv/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5cv 4 | 5 | OFILES= 5cv.$O\ 6 | 7 | HFILES=\ 8 | a.out.h\ 9 | bio.h\ 10 | mach.h\ 11 | 12 | LIBS=mach bio 9 # order matters. 13 | 14 | 15 | BIN=$ROOT/$OBJDIR/bin 16 | 17 | <$ROOT/mkfiles/mkone-$SHELLTYPE 18 | -------------------------------------------------------------------------------- /src/cmd/5l/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5l 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | list.$O\ 8 | noop.$O\ 9 | obj.$O\ 10 | optab.$O\ 11 | pass.$O\ 12 | span.$O\ 13 | enam.$O\ 14 | $TARGMODEL.$O\ 15 | elf.$O\ 16 | 17 | HFILES=\ 18 | l.h\ 19 | ../5c/5.out.h\ 20 | ${ROOT}/include/ar.h\ 21 | 22 | LIBS=bio 9 # order is important 23 | 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | CFLAGS= $CFLAGS -I. 29 | 30 | enam.$O: ../5c/enam.c 31 | $CC $CFLAGS ../5c/enam.c 32 | 33 | elf.$O: ../ld/elf.c 34 | $CC $CFLAGS ../ld/elf.c 35 | 36 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 37 | $CC $CFLAGS ../ld/$TARGMODEL.c 38 | -------------------------------------------------------------------------------- /src/cmd/6a/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=6a 4 | 5 | OFILES=\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | 9 | HFILES=\ 10 | ../6c/6.out.h\ 11 | y.tab.h\ 12 | a.h\ 13 | 14 | YFILES=a.y\ 15 | 16 | LIBS=cc bio 9 # order is important 17 | 18 | BIN=$ROOT/$OBJDIR/bin 19 | 20 | <$ROOT/mkfiles/mkone-$SHELLTYPE 21 | 22 | YFLAGS=-D1 -d 23 | 24 | lex.$O: ../cc/macbody ../cc/lexbody 25 | 26 | $ROOT/$OBJDIR/lib/libcc.a: 27 | cd ../cc 28 | mk $MKFLAGS install 29 | mk $MKFLAGS clean 30 | -------------------------------------------------------------------------------- /src/cmd/6c/machcap.c: -------------------------------------------------------------------------------- 1 | #include "gc.h" 2 | 3 | int 4 | machcap(Node *n) 5 | { 6 | 7 | if(n == Z) 8 | return 1; /* test */ 9 | 10 | switch(n->op) { 11 | case OMUL: 12 | case OLMUL: 13 | case OASMUL: 14 | case OASLMUL: 15 | if(typechl[n->type->etype]) 16 | return 1; 17 | if(typev[n->type->etype]) { 18 | return 1; 19 | } 20 | break; 21 | 22 | case OCOM: 23 | case ONEG: 24 | case OADD: 25 | case OAND: 26 | case OOR: 27 | case OSUB: 28 | case OXOR: 29 | case OASHL: 30 | case OLSHR: 31 | case OASHR: 32 | if(typechlv[n->left->type->etype]) 33 | return 1; 34 | break; 35 | 36 | case OCAST: 37 | return 1; 38 | 39 | case OCOND: 40 | case OCOMMA: 41 | case OLIST: 42 | case OANDAND: 43 | case OOROR: 44 | case ONOT: 45 | return 1; 46 | 47 | case OASADD: 48 | case OASSUB: 49 | case OASAND: 50 | case OASOR: 51 | case OASXOR: 52 | return 1; 53 | 54 | case OASASHL: 55 | case OASASHR: 56 | case OASLSHR: 57 | return 1; 58 | 59 | case OPOSTINC: 60 | case OPOSTDEC: 61 | case OPREINC: 62 | case OPREDEC: 63 | return 1; 64 | 65 | case OEQ: 66 | case ONE: 67 | case OLE: 68 | case OGT: 69 | case OLT: 70 | case OGE: 71 | case OHI: 72 | case OHS: 73 | case OLO: 74 | case OLS: 75 | return 1; 76 | } 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /src/cmd/6c/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=6c 4 | 5 | OFILES=\ 6 | cgen.$O\ 7 | enam.$O\ 8 | list.$O\ 9 | mul.$O\ 10 | peep.$O\ 11 | reg.$O\ 12 | sgen.$O\ 13 | swt.$O\ 14 | txt.$O\ 15 | 16 | HFILES=\ 17 | gc.h\ 18 | 6.out.h\ 19 | ../cc/cc.h\ 20 | 21 | LIBS=cc bio 9 # order is important 22 | 23 | BIN=$ROOT/$OBJDIR/bin 24 | 25 | <$ROOT/mkfiles/mkone-$SHELLTYPE 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/6c/mkfile_o: -------------------------------------------------------------------------------- 1 | 2 | #include "l.h" 3 | 4 | /* 5 | * fake malloc 6 | */ 7 | void* 8 | malloc(uint n) 9 | { 10 | void *p; 11 | 12 | while(n & 7) 13 | n++; 14 | while(nhunk < n) 15 | gethunk(); 16 | p = hunk; 17 | nhunk -= n; 18 | hunk += n; 19 | return p; 20 | } 21 | 22 | void 23 | free(void *p) 24 | { 25 | USED(p); 26 | } 27 | 28 | void* 29 | calloc(uint m, uint n) 30 | { 31 | void *p; 32 | 33 | n *= m; 34 | p = malloc(n); 35 | memset(p, 0, n); 36 | return p; 37 | } 38 | 39 | void* 40 | realloc(void *p, uint n) 41 | { 42 | void *new; 43 | 44 | new = malloc(n); 45 | if(new && p) 46 | memmove(new, p, n); 47 | return new; 48 | } 49 | 50 | #define Chunk (1*1024*1024) 51 | 52 | void* 53 | mysbrk(ulong size) 54 | { 55 | void *v; 56 | static int chunk; 57 | static uchar *brk; 58 | 59 | if(chunk < size) { 60 | chunk = Chunk; 61 | if(chunk < size) 62 | chunk = Chunk + size; 63 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 64 | if(brk == 0) 65 | return (void*)-1; 66 | } 67 | v = brk; 68 | chunk -= size; 69 | brk += size; 70 | return v; 71 | } 72 | 73 | double 74 | cputime(void) 75 | { 76 | return ((double)0); 77 | } 78 | -------------------------------------------------------------------------------- /src/cmd/6l/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | -------------------------------------------------------------------------------- /src/cmd/6l/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | void* 51 | mysbrk(ulong size) 52 | { 53 | return (void*)sbrk(size); 54 | } 55 | 56 | double 57 | cputime(void) 58 | { 59 | 60 | struct tms tmbuf; 61 | double ret_val; 62 | 63 | /* 64 | * times() only fials if &tmbuf is invalid. 65 | */ 66 | (void)times(&tmbuf); 67 | /* 68 | * Return the total time (in system clock ticks) 69 | * spent in user code and system 70 | * calls by both the calling process and its children. 71 | */ 72 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 73 | tmbuf.tms_cutime + tmbuf.tms_cstime); 74 | /* 75 | * Convert to seconds. 76 | */ 77 | ret_val *= sysconf(_SC_CLK_TCK); 78 | return ret_val; 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/6l/bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | void 6 | f(void) 7 | { 8 | struct{ 9 | int twobit:2; 10 | int :1; 11 | int threebit:3; 12 | int onebit:1; 13 | } s3; 14 | struct{ 15 | uint twobit:2; 16 | uint :1; 17 | uint threebit:3; 18 | uint onebit:1; 19 | } s4; 20 | 21 | s3.threebit = 7; 22 | s3.twobit = s3.threebit; 23 | // s3.threebit = s3.twobit; 24 | print("%d %d\n", s3.threebit, s3.twobit); 25 | 26 | s4.threebit = 7; 27 | s4.twobit = s4.threebit; 28 | // s4.threebit = s4.twobit; 29 | print("%d %d\n", s4.threebit, s4.twobit); 30 | } 31 | 32 | void 33 | main(int, char**) 34 | { 35 | f(); 36 | } 37 | -------------------------------------------------------------------------------- /src/cmd/6l/compat.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void*, ulong) 40 | { 41 | fprint(2, "realloc called\n"); 42 | abort(); 43 | return 0; 44 | } 45 | 46 | void* 47 | mysbrk(ulong size) 48 | { 49 | return sbrk(size); 50 | } 51 | 52 | void 53 | setmalloctag(void *v, ulong pc) 54 | { 55 | USED(v); 56 | USED(pc); 57 | } 58 | 59 | int 60 | fileexists(char *s) 61 | { 62 | uchar dirbuf[400]; 63 | 64 | /* it's fine if stat result doesn't fit in dirbuf, since even then the file exists */ 65 | return stat(s, dirbuf, sizeof(dirbuf)) >= 0; 66 | } 67 | -------------------------------------------------------------------------------- /src/cmd/6l/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=6l 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | list.$O\ 8 | obj.$O\ 9 | optab.$O\ 10 | pass.$O\ 11 | span.$O\ 12 | enam.$O\ 13 | $TARGMODEL.$O\ 14 | 15 | HFILES=\ 16 | l.h\ 17 | ../6c/6.out.h\ 18 | ${ROOT}/include/ar.h\ 19 | 20 | LIBS=bio 9 # order is important 21 | 22 | 23 | BIN=$ROOT/$OBJDIR/bin 24 | 25 | <$ROOT/mkfiles/mkone-$SHELLTYPE 26 | 27 | enam.$O: ../6c/enam.c 28 | $CC $CFLAGS ../6c/enam.c 29 | 30 | -------------------------------------------------------------------------------- /src/cmd/6l/mkfile_o: -------------------------------------------------------------------------------- 1 | op) { 11 | case OMUL: 12 | case OLMUL: 13 | case OASMUL: 14 | case OASLMUL: 15 | if(typechlv[n->type->etype]) 16 | return 1; 17 | break; 18 | 19 | case OADD: 20 | case OAND: 21 | case OOR: 22 | case OSUB: 23 | case OXOR: 24 | case OASHL: 25 | case OLSHR: 26 | case OASHR: 27 | if(typechlv[n->left->type->etype]) 28 | return 1; 29 | break; 30 | 31 | case OCAST: 32 | return 1; 33 | 34 | case OCOND: 35 | case OCOMMA: 36 | case OLIST: 37 | case OANDAND: 38 | case OOROR: 39 | case ONOT: 40 | return 1; 41 | 42 | case OASADD: 43 | case OASSUB: 44 | case OASAND: 45 | case OASOR: 46 | case OASXOR: 47 | return 1; 48 | 49 | case OASASHL: 50 | case OASASHR: 51 | case OASLSHR: 52 | return 1; 53 | 54 | case OPOSTINC: 55 | case OPOSTDEC: 56 | case OPREINC: 57 | case OPREDEC: 58 | return 1; 59 | 60 | case OEQ: 61 | case ONE: 62 | case OLE: 63 | case OGT: 64 | case OLT: 65 | case OGE: 66 | case OHI: 67 | case OHS: 68 | case OLO: 69 | case OLS: 70 | return 1; 71 | 72 | case ONEG: 73 | if(typechlv[n->left->type->etype]) 74 | return 1; 75 | break; 76 | 77 | case OCOM: 78 | break; 79 | } 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /src/cmd/7c/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../7c/7.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/7c/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=7c 4 | OFILES=\ 5 | cgen.$O\ 6 | enam.$O\ 7 | list.$O\ 8 | machcap.$O\ 9 | mul.$O\ 10 | peep.$O\ 11 | pgen.$O\ 12 | pswt.$O\ 13 | reg.$O\ 14 | sgen.$O\ 15 | swt.$O\ 16 | txt.$O\ 17 | 18 | HFILES=\ 19 | gc.h\ 20 | 7.out.h\ 21 | ../cc/cc.h\ 22 | 23 | LIBS=cc bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | CFLAGS=-I. $CFLAGS 29 | 30 | $ROOT/$OBJDIR/lib/libcc.a: 31 | cd ../cc 32 | mk install 33 | mk clean 34 | 35 | %.$O: ../cc/%.c 36 | $CC $CFLAGS ../cc/$stem.c 37 | 38 | t:V: $O.out 39 | $O.out -S t 40 | $LD -o t.out t.$O 41 | t.out 42 | 43 | #enam.c: 7.out.h 44 | # rc mkenam 45 | -------------------------------------------------------------------------------- /src/cmd/7l/cnam.c: -------------------------------------------------------------------------------- 1 | char *cnames[] = 2 | { 3 | "NONE", 4 | "REG", 5 | "RSP", 6 | "SHIFT", 7 | "EXTREG", 8 | "FREG", 9 | "SPR", 10 | "COND", 11 | "ZCON", 12 | "ADDCON0", 13 | "ADDCON", 14 | "MOVCON", 15 | "BITCON", 16 | "ABCON", 17 | "MBCON", 18 | "LCON", 19 | "FCON", 20 | "VCON", 21 | "AACON", 22 | "LACON", 23 | "AECON", 24 | "SBRA", 25 | "LBRA", 26 | "NPAUTO", 27 | "NSAUTO", 28 | "PSAUTO", 29 | "PPAUTO", 30 | "UAUTO4K", 31 | "UAUTO8K", 32 | "UAUTO16K", 33 | "UAUTO32K", 34 | "UAUTO64K", 35 | "LAUTO", 36 | "SEXT1", 37 | "SEXT2", 38 | "SEXT4", 39 | "SEXT8", 40 | "SEXT16", 41 | "LEXT", 42 | "NPOREG", 43 | "NSOREG", 44 | "ZOREG", 45 | "PSOREG", 46 | "PPOREG", 47 | "UOREG4K", 48 | "UOREG8K", 49 | "UOREG16K", 50 | "UOREG32K", 51 | "UOREG64K", 52 | "LOREG", 53 | "ADDR", 54 | "ROFF", 55 | "XPOST", 56 | "XPRE", 57 | "VREG", 58 | "GOK", 59 | "NCLASS", 60 | }; 61 | -------------------------------------------------------------------------------- /src/cmd/7l/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | HOST=Posix 3 | 4 | TARG=7l 5 | OFILES=\ 6 | $HOST.$O\ 7 | asm.$O\ 8 | asmout.$O\ 9 | bits.$O\ 10 | cnam.$O\ 11 | dyn.$O\ 12 | elf.$O\ 13 | enam.$O\ 14 | falloc.$O\ 15 | list.$O\ 16 | mod.$O\ 17 | noop.$O\ 18 | obj.$O\ 19 | optab.$O\ 20 | pass.$O\ 21 | pobj.$O\ 22 | span.$O\ 23 | sub.$O\ 24 | 25 | HFILES=\ 26 | l.h\ 27 | ../7c/7.out.h\ 28 | ../ld/elf.h\ 29 | ../ld/ld.h\ 30 | 31 | LIBS=bio 9 # order is important 32 | 33 | BIN=$ROOT/$OBJDIR/bin 34 | CFLAGS=$CFLAGS -I. 35 | <$ROOT/mkfiles/mkone-$SHELLTYPE 36 | 37 | #../7c/enam.c: ../7c/7.out.h 38 | # @ { cd ../7c; mk enam.c } 39 | 40 | cnam.c: l.h 41 | rc ../ld/mkcname 42 | 43 | enam.$O: ../7c/enam.c 44 | $CC $CFLAGS ../7c/enam.c 45 | %.$O: ../ld/%.c 46 | $CC $CFLAGS ../ld/$stem.c 47 | 48 | x:V: $O.out 49 | $O.out -la -o/dev/null x.7 50 | 51 | -------------------------------------------------------------------------------- /src/cmd/8a/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=8a 4 | 5 | OFILES=\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | 9 | HFILES=\ 10 | ../8c/8.out.h\ 11 | y.tab.h\ 12 | a.h\ 13 | 14 | YFILES=a.y\ 15 | 16 | LIBS=cc bio 9 # order is important 17 | 18 | BIN=$ROOT/$OBJDIR/bin 19 | 20 | <$ROOT/mkfiles/mkone-$SHELLTYPE 21 | 22 | YFLAGS=-D1 -d 23 | 24 | lex.$O: ../cc/macbody ../cc/lexbody 25 | 26 | $ROOT/$OBJDIR/lib/libcc.a: 27 | cd ../cc 28 | mk $MKFLAGS install 29 | mk $MKFLAGS clean 30 | -------------------------------------------------------------------------------- /src/cmd/8c/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../8c/8.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/8c/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=8c 4 | 5 | OFILES=\ 6 | cgen.$O\ 7 | enam.$O\ 8 | list.$O\ 9 | sgen.$O\ 10 | swt.$O\ 11 | txt.$O\ 12 | reg.$O\ 13 | peep.$O\ 14 | pgen.$O\ 15 | pswt.$O\ 16 | machcap.$O\ 17 | cgen64.$O\ 18 | div.$O\ 19 | mul.$O\ 20 | 21 | HFILES=\ 22 | gc.h\ 23 | 8.out.h\ 24 | ../cc/cc.h\ 25 | 26 | LIBS=cc bio 9 # order is important 27 | 28 | BIN=$ROOT/$OBJDIR/bin 29 | 30 | <$ROOT/mkfiles/mkone-$SHELLTYPE 31 | 32 | 33 | $ROOT/$OBJDIR/lib/libcc.a: 34 | cd ../cc 35 | mk $MKFLAGS install 36 | mk $MKFLAGS clean 37 | 38 | %.$O: ../cc/%.c 39 | $CC -I. $CFLAGS ../cc/$stem.c 40 | -------------------------------------------------------------------------------- /src/cmd/8l/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "l.h" 3 | 4 | /* 5 | * fake malloc 6 | */ 7 | void* 8 | malloc(uint n) 9 | { 10 | void *p; 11 | 12 | while(n & 7) 13 | n++; 14 | while(nhunk < n) 15 | gethunk(); 16 | p = hunk; 17 | nhunk -= n; 18 | hunk += n; 19 | return p; 20 | } 21 | 22 | void 23 | free(void *p) 24 | { 25 | USED(p); 26 | } 27 | 28 | void* 29 | calloc(uint m, uint n) 30 | { 31 | void *p; 32 | 33 | n *= m; 34 | p = malloc(n); 35 | memset(p, 0, n); 36 | return p; 37 | } 38 | 39 | void* 40 | realloc(void *p, uint n) 41 | { 42 | void *new; 43 | 44 | new = malloc(n); 45 | if(new && p) 46 | memmove(new, p, n); 47 | return new; 48 | } 49 | 50 | #define Chunk (1*1024*1024) 51 | 52 | void* 53 | mysbrk(ulong size) 54 | { 55 | void *v; 56 | static int chunk; 57 | static uchar *brk; 58 | 59 | if(chunk < size) { 60 | chunk = Chunk; 61 | if(chunk < size) 62 | chunk = Chunk + size; 63 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 64 | if(brk == 0) 65 | return (void*)-1; 66 | } 67 | v = brk; 68 | chunk -= size; 69 | brk += size; 70 | return v; 71 | } 72 | 73 | double 74 | cputime(void) 75 | { 76 | return ((double)0); 77 | } 78 | -------------------------------------------------------------------------------- /src/cmd/8l/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | 54 | void 55 | setmalloctag(void*, ulong) 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /src/cmd/8l/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | void* 51 | mysbrk(ulong size) 52 | { 53 | return (void*)sbrk(size); 54 | } 55 | 56 | double 57 | cputime(void) 58 | { 59 | 60 | struct tms tmbuf; 61 | double ret_val; 62 | 63 | /* 64 | * times() only fails if &tmbuf is invalid. 65 | */ 66 | (void)times(&tmbuf); 67 | /* 68 | * Return the total time (in system clock ticks) 69 | * spent in user code and system 70 | * calls by both the calling process and its children. 71 | */ 72 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 73 | tmbuf.tms_cutime + tmbuf.tms_cstime); 74 | /* 75 | * Convert to seconds. 76 | */ 77 | ret_val *= sysconf(_SC_CLK_TCK); 78 | return ret_val; 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/8l/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=8l 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | obj.$O\ 8 | optab.$O\ 9 | pass.$O\ 10 | span.$O\ 11 | list.$O\ 12 | enam.$O\ 13 | $TARGMODEL.$O\ 14 | elf.$O\ 15 | 16 | HFILES=\ 17 | l.h\ 18 | ../8c/8.out.h\ 19 | ${ROOT}/include/ar.h\ 20 | 21 | LIBS=bio 9 # order is important 22 | 23 | BIN=$ROOT/$OBJDIR/bin 24 | 25 | <$ROOT/mkfiles/mkone-$SHELLTYPE 26 | CFLAGS= $CFLAGS -I. 27 | 28 | 29 | enam.$O: ../8c/enam.c 30 | $CC $CFLAGS ../8c/enam.c 31 | elf.$O: ../ld/elf.c 32 | $CC $CFLAGS ../ld/elf.c 33 | 34 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 35 | $CC $CFLAGS ../ld/$TARGMODEL.c 36 | -------------------------------------------------------------------------------- /src/cmd/acid/B.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | line=`/bin/echo $1 | /bin/sed 's/-//'` 3 | if [ "x$EDITOR" = "x" ] ; then 4 | vi +$line $2 5 | else 6 | $EDITOR +$line $2 7 | fi 8 | -------------------------------------------------------------------------------- /src/cmd/acid/arm: -------------------------------------------------------------------------------- 1 | please remove this file 2 | -------------------------------------------------------------------------------- /src/cmd/acid/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=acid 4 | 5 | OFILES= main.$O\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | util.$O\ 9 | exec.$O\ 10 | expr.$O\ 11 | list.$O\ 12 | builtin.$O\ 13 | proc.$O\ 14 | dot.$O\ 15 | print.$O\ 16 | os-$TARGMODEL.$O\ 17 | rdebug.$O\ 18 | 19 | YFILES=dbg.y 20 | HFILES=acid.h y.tab.h 21 | 22 | LIBS=mach math bio regexp 9 23 | 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | 29 | CFLAGS= $CFLAGS -I${ROOT}/include 30 | -------------------------------------------------------------------------------- /src/cmd/cat/cat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | cat(int f, char *s) 5 | { 6 | char buf[8192]; 7 | long n; 8 | 9 | while((n=read(f, buf, (long)sizeof buf))>0) 10 | if(write(1, buf, n)!=n) 11 | sysfatal("write error copying %s: %r", s); 12 | if(n < 0) 13 | sysfatal("error reading %s: %r", s); 14 | } 15 | 16 | void 17 | main(int argc, char *argv[]) 18 | { 19 | int f, i; 20 | 21 | argv0 = "cat"; 22 | if(argc == 1) 23 | cat(0, ""); 24 | else for(i=1; i 3 | 4 | void* 5 | mysbrk(ulong size) 6 | { 7 | return (void*)sbrk(size); 8 | } 9 | 10 | int 11 | mycreat(char *n, int p) 12 | { 13 | 14 | return create(n, 1, p); 15 | } 16 | 17 | int 18 | mywait(int *s) 19 | { 20 | return wait(s); 21 | } 22 | 23 | int 24 | mydup(int f1, int f2) 25 | { 26 | return dup2(f1,f2); 27 | } 28 | 29 | int 30 | mypipe(int *fd) 31 | { 32 | return pipe(fd); 33 | } 34 | 35 | int 36 | systemtype(int sys) 37 | { 38 | 39 | return sys&Unix; 40 | } 41 | 42 | int 43 | pathchar(void) 44 | { 45 | return '/'; 46 | } 47 | 48 | char* 49 | mygetwd(char *path, int len) 50 | { 51 | return (char*)getcwd(path, len); 52 | } 53 | 54 | int 55 | myexec(char *path, char *argv[]) 56 | { 57 | return execvp(path, argv); 58 | } 59 | 60 | /* 61 | * fake mallocs 62 | */ 63 | void* 64 | malloc(size_t n) 65 | { 66 | return alloc(n); 67 | } 68 | 69 | void* 70 | calloc(size_t m, size_t n) 71 | { 72 | return alloc(m*n); 73 | } 74 | 75 | void* 76 | realloc(void *p, size_t n) 77 | { 78 | fprint(2, "realloc called\n"); 79 | abort(); 80 | return 0; 81 | } 82 | 83 | void 84 | free(void *p) 85 | { 86 | } 87 | 88 | int 89 | myfork(void) 90 | { 91 | return fork(); 92 | } 93 | 94 | int 95 | myaccess(char *f) 96 | { 97 | return access(f, 0); 98 | } 99 | -------------------------------------------------------------------------------- /src/cmd/cc/bits.c: -------------------------------------------------------------------------------- 1 | #include "cc.h" 2 | 3 | Bits 4 | bor(Bits a, Bits b) 5 | { 6 | Bits c; 7 | int i; 8 | 9 | for(i=0; ib[i]) 45 | return 1; 46 | return 0; 47 | } 48 | 49 | int 50 | beq(Bits a, Bits b) 51 | { 52 | int i; 53 | 54 | for(i=0; i 2 | 3 | void 4 | main(int argc, char *argv[]) 5 | { 6 | int nflag; 7 | int i, len; 8 | char *buf, *p; 9 | 10 | nflag = 0; 11 | if(argc > 1 && strcmp(argv[1], "-n") == 0) 12 | nflag = 1; 13 | 14 | len = 1; 15 | for(i = 1+nflag; i < argc; i++) 16 | len += strlen(argv[i])+1; 17 | 18 | buf = malloc(len); 19 | if(buf == 0) 20 | exits("no memory"); 21 | 22 | p = buf; 23 | for(i = 1+nflag; i < argc; i++) 24 | p += sprint(p, i == argc-1 ? "%s":"%s ", argv[i]); 25 | 26 | if(!nflag) 27 | sprint(p, "\n"); 28 | 29 | if(write(1, buf, strlen(buf)) < 0) 30 | fprint(2, "echo: write error: %r\n"); 31 | 32 | exits((char *)0); 33 | } 34 | -------------------------------------------------------------------------------- /src/cmd/echo/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=echo 4 | 5 | OFILES= echo.$O\ 6 | 7 | HFILES= 8 | 9 | LIBS=9 10 | 11 | BIN=$ROOT/$OBJDIR/bin 12 | 13 | <$ROOT/mkfiles/mkone-$SHELLTYPE 14 | -------------------------------------------------------------------------------- /src/cmd/iar/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char * 4 | myctime(long x) 5 | { 6 | time_t t; 7 | 8 | t = x; 9 | return ctime(&t); 10 | } 11 | -------------------------------------------------------------------------------- /src/cmd/iar/Plan9.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char * 4 | myctime(long x) 5 | { 6 | return ctime(x); 7 | } 8 | -------------------------------------------------------------------------------- /src/cmd/iar/Posix.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char * 4 | myctime(long x) 5 | { 6 | time_t t; 7 | 8 | t = x; 9 | return ctime(&t); 10 | } 11 | -------------------------------------------------------------------------------- /src/cmd/iar/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=iar # inferno archiver 4 | 5 | OFILES= ar.$O\ 6 | $TARGMODEL.$O\ 7 | 8 | HFILES= ${ROOT}/include/a.out.h\ 9 | ${ROOT}/include/bio.h\ 10 | ${ROOT}/include/mach.h\ 11 | 12 | LIBS=mach bio 9 # libbio.a uses lib9.a so order matters. 13 | 14 | BIN=$ROOT/$OBJDIR/bin 15 | 16 | <$ROOT/mkfiles/mkone-$SHELLTYPE 17 | 18 | -------------------------------------------------------------------------------- /src/cmd/iyacc/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=iyacc 4 | 5 | OFILES= yacc.$O\ 6 | 7 | HFILES= ${ROOT}/include/bio.h\ 8 | 9 | LIBS=bio 9 # libbio.a uses lib9.a so order matters. 10 | 11 | BIN=$ROOT/$OBJDIR/bin 12 | 13 | <$ROOT/mkfiles/mkone-$SHELLTYPE 14 | 15 | CFLAGS= $CFLAGS '-DROOT="'$ROOT'"' '-DPARSER="yaccpar"' '-DPARSERS="yaccpar"' 16 | 17 | install:V: $ROOT/lib/yaccpar 18 | 19 | $ROOT/lib/yaccpar: yaccpar 20 | rm -f $target && cp $prereq $target 21 | -------------------------------------------------------------------------------- /src/cmd/ka/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=ka 4 | 5 | OFILES=\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | 9 | HFILES=\ 10 | ../kc/k.out.h\ 11 | y.tab.h\ 12 | a.h\ 13 | 14 | YFILES=a.y\ 15 | 16 | LIBS=cc bio 9 # order is important 17 | 18 | BIN=$ROOT/$OBJDIR/bin 19 | 20 | <$ROOT/mkfiles/mkone-$SHELLTYPE 21 | 22 | YFLAGS=-D1 -d 23 | 24 | lex.$O: ../cc/macbody ../cc/lexbody 25 | 26 | $ROOT/$OBJDIR/lib/libcc.a: 27 | cd ../cc 28 | mk $MKFLAGS install 29 | mk $MKFLAGS clean 30 | -------------------------------------------------------------------------------- /src/cmd/kc/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../kc/k.out.h <<'!' 2 | v/^ A/d 3 | g/^ AEND/s//&,/ 4 | g/[ ]*=.*,/s//,/ 5 | v/,/p 6 | ,s/^ A/ "/ 7 | ,s/,.*$/",/ 8 | 1i 9 | char *anames[] = 10 | { 11 | . 12 | ,a 13 | }; 14 | . 15 | w enam.c 16 | Q 17 | ! 18 | -------------------------------------------------------------------------------- /src/cmd/kc/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=kc 4 | 5 | OFILES=\ 6 | peep.$O\ 7 | pgen.$O\ 8 | pswt.$O\ 9 | reg.$O\ 10 | cgen.$O\ 11 | enam.$O\ 12 | list.$O\ 13 | sgen.$O\ 14 | swt.$O\ 15 | txt.$O\ 16 | mul.$O\ 17 | 18 | HFILES=\ 19 | gc.h\ 20 | k.out.h\ 21 | ../cc/cc.h\ 22 | 23 | LIBS=cc bio 9 # order is important. 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | 29 | 30 | $ROOT/$OBJDIR/lib/libcc.a: 31 | cd ../cc 32 | mk $MKFLAGS install 33 | mk $MKFLAGS clean 34 | 35 | %.$O: ../cc/%.c 36 | $CC -I. $CFLAGS ../cc/$stem.c 37 | 38 | #enam.c: k.out.h 39 | # rc mkenam 40 | -------------------------------------------------------------------------------- /src/cmd/kl/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | 54 | void 55 | setmalloctag(void*, ulong) 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /src/cmd/kl/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | void* 51 | mysbrk(ulong size) 52 | { 53 | return (void*)sbrk(size); 54 | } 55 | 56 | double 57 | cputime(void) 58 | { 59 | 60 | struct tms tmbuf; 61 | double ret_val; 62 | 63 | /* 64 | * times() only fials if &tmbuf is invalid. 65 | */ 66 | (void)times(&tmbuf); 67 | /* 68 | * Return the total time (in system clock ticks) 69 | * spent in user code and system 70 | * calls by both the calling process and its children. 71 | */ 72 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 73 | tmbuf.tms_cutime + tmbuf.tms_cstime); 74 | /* 75 | * Convert to seconds. 76 | */ 77 | ret_val *= sysconf(_SC_CLK_TCK); 78 | return ret_val; 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/kl/foo.c: -------------------------------------------------------------------------------- 1 | int foo(void) 2 | { 3 | return 100; 4 | } 5 | 6 | main() 7 | { 8 | int x; 9 | 10 | x = foo(); 11 | } 12 | 13 | _main() 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /src/cmd/kl/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | 4 | TARG=kl 5 | 6 | OFILES=\ 7 | asm.$O\ 8 | list.$O\ 9 | noop.$O\ 10 | sched.$O\ 11 | obj.$O\ 12 | optab.$O\ 13 | pass.$O\ 14 | span.$O\ 15 | enam.$O\ 16 | $TARGMODEL.$O\ 17 | 18 | HFILES=\ 19 | l.h\ 20 | ../kc/k.out.h\ 21 | ${ROOT}/include/ar.h\ 22 | 23 | LIBS=bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | CFLAGS= $CFLAGS -I. 29 | 30 | enam.$O: ../kc/enam.c 31 | $CC $CFLAGS ../kc/enam.c 32 | 33 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 34 | $CC $CFLAGS ../ld/$TARGMODEL.c 35 | -------------------------------------------------------------------------------- /src/cmd/kprof/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=kprof 4 | 5 | OFILES= kprof.$O\ 6 | 7 | LIBS= mach bio 9 8 | 9 | BIN=$ROOT/$OBJDIR/bin 10 | 11 | <$ROOT/mkfiles/mkone-$SHELLTYPE 12 | 13 | -------------------------------------------------------------------------------- /src/cmd/ksize/ksize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | size(char *file) 7 | { 8 | int fd; 9 | Fhdr f; 10 | 11 | if((fd = open(file, OREAD)) < 0){ 12 | fprint(2, "size: "); 13 | perror(file); 14 | return 1; 15 | } 16 | if(crackhdr(fd, &f)) { 17 | print("%ldt + %ldd + %ldb = %ld\t%s\n", f.txtsz, f.datsz, 18 | f.bsssz, f.txtsz+f.datsz+f.bsssz, file); 19 | close(fd); 20 | return 0; 21 | } 22 | 23 | /* get error string from libmach and display */ 24 | fprint(2, "ksize: %s %r\n", file); 25 | close(fd); 26 | return 1; 27 | } 28 | 29 | void 30 | main(int argc, char *argv[]) 31 | { 32 | char *err; 33 | int i; 34 | 35 | ARGBEGIN { 36 | default: 37 | fprint(2, "usage: ksize [a.out ...]\n"); 38 | exits("usage"); 39 | } ARGEND; 40 | 41 | err = 0; 42 | if(argc == 0) 43 | if(size("8.out")) 44 | err = "error"; 45 | for(i=0; i 2 | #include 3 | 4 | /* 5 | * We can't include l.h, because Windoze wants to use some names 6 | * like FLOAT and ABC which we declare. Define what we need here. 7 | */ 8 | typedef unsigned char uchar; 9 | typedef unsigned int uint; 10 | typedef unsigned long ulong; 11 | 12 | #define Chunk (1*1024*1024) 13 | 14 | void* 15 | mysbrk(ulong size) 16 | { 17 | void *v; 18 | static int chunk; 19 | static uchar *brk; 20 | 21 | if(chunk < size) { 22 | chunk = Chunk; 23 | if(chunk < size) 24 | chunk = Chunk + size; 25 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 26 | if(brk == 0) 27 | return (void*)-1; 28 | } 29 | v = brk; 30 | chunk -= size; 31 | brk += size; 32 | return v; 33 | } 34 | 35 | double 36 | cputime(void) 37 | { 38 | return 0.0; 39 | } 40 | 41 | int 42 | fileexists(char *name) 43 | { 44 | int fd; 45 | 46 | fd = open(name, OREAD); 47 | if(fd < 0) 48 | return 0; 49 | close(fd); 50 | return 1; 51 | } 52 | -------------------------------------------------------------------------------- /src/cmd/ld/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | void* 4 | mysbrk(usize size) 5 | { 6 | return sbrk(size); 7 | } 8 | 9 | int 10 | fileexists(char *s) 11 | { 12 | uchar dirbuf[400]; 13 | 14 | /* it's fine if stat result doesn't fit in dirbuf, since even then the file exists */ 15 | return stat(s, dirbuf, sizeof(dirbuf)) >= 0; 16 | } 17 | -------------------------------------------------------------------------------- /src/cmd/ld/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #include 5 | #undef getwd 6 | #include /* For sysconf() and _SC_CLK_TCK */ 7 | 8 | void* 9 | mysbrk(usize size) 10 | { 11 | return (void*)sbrk(size); 12 | } 13 | 14 | double 15 | cputime(void) 16 | { 17 | 18 | struct tms tmbuf; 19 | double ret_val; 20 | 21 | /* 22 | * times() only fails if &tmbuf is invalid. 23 | */ 24 | (void)times(&tmbuf); 25 | /* 26 | * Return the total time (in system clock ticks) 27 | * spent in user code and system 28 | * calls by both the calling process and its children. 29 | */ 30 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 31 | tmbuf.tms_cutime + tmbuf.tms_cstime); 32 | /* 33 | * Convert to seconds. 34 | */ 35 | ret_val *= sysconf(_SC_CLK_TCK); 36 | return ret_val; 37 | 38 | } 39 | 40 | int 41 | fileexists(char *name) 42 | { 43 | struct stat sb; 44 | 45 | return stat(name, &sb) >= 0; 46 | } 47 | -------------------------------------------------------------------------------- /src/cmd/ld/Upd: -------------------------------------------------------------------------------- 1 | #!/bin/rc 2 | cp mkcname *.[ch] /n/local/usr/forsyth/7/7acl/ld/. 3 | -------------------------------------------------------------------------------- /src/cmd/ld/falloc.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(usize n) 8 | { 9 | return halloc(n); 10 | } 11 | 12 | void 13 | free(void *p) 14 | { 15 | USED(p); 16 | } 17 | 18 | void* 19 | calloc(usize m, usize n) 20 | { 21 | void *p; 22 | 23 | n *= m; 24 | p = malloc(n); 25 | memset(p, 0, n); 26 | return p; 27 | } 28 | 29 | /* 30 | * not used by compiler or loader, but Windows needs it 31 | */ 32 | void* 33 | realloc(void *p, usize n) 34 | { 35 | void *new; 36 | 37 | new = malloc(n); 38 | if(new != nil && p != nil) 39 | memmove(new, p, n); /* safe only when adjecent hunks have no gaps */ 40 | return new; 41 | } 42 | 43 | void 44 | setmalloctag(void *v, ulong pc) 45 | { 46 | USED(v); 47 | USED(pc); 48 | } 49 | -------------------------------------------------------------------------------- /src/cmd/ld/mkcname: -------------------------------------------------------------------------------- 1 | ed - l.h <<'!' 2 | v/^ C_/d 3 | g/^ C_NCLASS/s//&,/ 4 | g/[ ]*=.*,/s//,/ 5 | v/,/p 6 | ,s/^ C_/ "/ 7 | ,s/,.*$/",/ 8 | 1i 9 | char *cnames[] = 10 | { 11 | . 12 | ,a 13 | }; 14 | . 15 | w cnam.c 16 | Q 17 | ! 18 | -------------------------------------------------------------------------------- /src/cmd/mk/README: -------------------------------------------------------------------------------- 1 | Using the delivered mk to rebuild mk. 2 | 3 | You should be able to use the delivered executable of mk to 4 | build a new executable. This may be of particular interest 5 | on Windows NT/Win95 where the path of the shell program 6 | can be hard-coded by changing the variable named "shell" 7 | near the beginning of source file Nt.c. 8 | 9 | Mk uses the regular expression library, so build 10 | the program as follows: 11 | 12 | 1. ensure that ../../mkconfig contains the proper system definitions 13 | 14 | 2. ensure that the system libraries lib9, libbio, and libregexp have 15 | been built. you can do this by hand by changing to ../lib9, 16 | ../libbio, and ../libregexp and doing "mk nuke" and a "mk install" 17 | in each. 18 | 19 | 3. in this directory 20 | mk nuke 21 | mk install 22 | 23 | 4. on NT/Win95 the executable must be installed by hand because the current 24 | executable is locked down while it is executing: 25 | 26 | mv obj.out ../../Nt/386/bin/mk.exe 27 | -------------------------------------------------------------------------------- /src/cmd/mk/arc.c: -------------------------------------------------------------------------------- 1 | #include "mk.h" 2 | 3 | Arc * 4 | newarc(Node *n, Rule *r, char *stem, Resub *match) 5 | { 6 | Arc *a; 7 | 8 | a = (Arc *)Malloc(sizeof(Arc)); 9 | a->n = n; 10 | a->r = r; 11 | a->stem = strdup(stem); 12 | rcopy(a->match, match, NREGEXP); 13 | a->next = 0; 14 | a->flag = 0; 15 | a->prog = r->prog; 16 | return(a); 17 | } 18 | 19 | void 20 | dumpa(char *s, Arc *a) 21 | { 22 | char buf[1024]; 23 | 24 | Bprint(&bout, "%sArc@%p: n=%p r=%p flag=0x%x stem='%s'", 25 | s, a, a->n, a->r, a->flag, a->stem); 26 | if(a->prog) 27 | Bprint(&bout, " prog='%s'", a->prog); 28 | Bprint(&bout, "\n"); 29 | 30 | if(a->n){ 31 | snprint(buf, sizeof(buf), "%s ", (*s == ' ')? s:""); 32 | dumpn(buf, a->n); 33 | } 34 | } 35 | 36 | void 37 | nrep(void) 38 | { 39 | Symtab *sym; 40 | Word *w; 41 | 42 | sym = symlook("NREP", S_VAR, 0); 43 | if(sym){ 44 | w = (Word *) sym->value; 45 | if (w && w->s && *w->s) 46 | nreps = atoi(w->s); 47 | } 48 | if(nreps < 1) 49 | nreps = 1; 50 | if(DEBUG(D_GRAPH)) 51 | Bprint(&bout, "nreps = %d\n", nreps); 52 | } 53 | -------------------------------------------------------------------------------- /src/cmd/mk/job.c: -------------------------------------------------------------------------------- 1 | #include "mk.h" 2 | 3 | Job * 4 | newjob(Rule *r, Node *nlist, char *stem, char **match, Word *pre, Word *npre, Word *tar, Word *atar) 5 | { 6 | register Job *j; 7 | 8 | j = (Job *)Malloc(sizeof(Job)); 9 | j->r = r; 10 | j->n = nlist; 11 | j->stem = stem; 12 | j->match = match; 13 | j->p = pre; 14 | j->np = npre; 15 | j->t = tar; 16 | j->at = atar; 17 | j->nproc = -1; 18 | j->next = 0; 19 | return(j); 20 | } 21 | 22 | void 23 | dumpj(char *s, Job *j, int all) 24 | { 25 | Bprint(&bout, "%s\n", s); 26 | while(j){ 27 | Bprint(&bout, "job@%ld: r=%ld n=%ld stem='%s' nproc=%d\n", 28 | j, j->r, j->n, j->stem, j->nproc); 29 | Bprint(&bout, "\ttarget='%s' alltarget='%s' prereq='%s' nprereq='%s'\n", 30 | wtos(j->t, ' '), wtos(j->at, ' '), wtos(j->p, ' '), wtos(j->np, ' ')); 31 | j = all? j->next : 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/cmd/mk/match.c: -------------------------------------------------------------------------------- 1 | #include "mk.h" 2 | 3 | int 4 | match(char *name, char *template, char *stem) 5 | { 6 | Rune r; 7 | int n; 8 | 9 | while(*name && *template){ 10 | n = chartorune(&r, template); 11 | if (PERCENT(r)) 12 | break; 13 | while (n--) 14 | if(*name++ != *template++) 15 | return 0; 16 | } 17 | if(!PERCENT(*template)) 18 | return 0; 19 | n = strlen(name)-strlen(template+1); 20 | if (n < 0) 21 | return 0; 22 | if (strcmp(template+1, name+n)) 23 | return 0; 24 | strncpy(stem, name, n); 25 | stem[n] = 0; 26 | if(*template == '&') 27 | return !charin(stem, "./"); 28 | return 1; 29 | } 30 | 31 | void 32 | subst(char *stem, char *template, char *dest) 33 | { 34 | Rune r; 35 | char *s; 36 | int n; 37 | 38 | while(*template){ 39 | n = chartorune(&r, template); 40 | if (PERCENT(r)) { 41 | template += n; 42 | for (s = stem; *s; s++) 43 | *dest++ = *s; 44 | } else 45 | while (n--) 46 | *dest++ = *template++; 47 | } 48 | *dest = 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/cmd/mk/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=mk 4 | 5 | OFILES= arc.$O\ 6 | archive.$O\ 7 | bufblock.$O\ 8 | env.$O\ 9 | file.$O\ 10 | graph.$O\ 11 | job.$O\ 12 | lex.$O\ 13 | main.$O\ 14 | match.$O\ 15 | mk.$O\ 16 | parse.$O\ 17 | $TARGMODEL.$O\ 18 | recipe.$O\ 19 | rule.$O\ 20 | run.$O\ 21 | $TARGSHTYPE.$O\ 22 | shprint.$O\ 23 | symtab.$O\ 24 | var.$O\ 25 | varsub.$O\ 26 | word.$O\ 27 | 28 | HFILES= fns.h\ 29 | ${ROOT}/include/ar.h\ 30 | mk.h\ 31 | 32 | LIBS= regexp bio 9 33 | 34 | BIN=$ROOT/$OBJDIR/bin 35 | 36 | <$ROOT/mkfiles/mkone-$SHELLTYPE 37 | CFLAGS=$CFLAGS -I$ROOT/include -DROOT'="'$ROOT'"' 38 | 39 | 40 | value = value; 7 | symlook(name, S_MAKEVAR, (void*)""); 8 | } 9 | 10 | static void 11 | print1(Symtab *s) 12 | { 13 | Word *w; 14 | 15 | Bprint(&bout, "\t%s=", s->name); 16 | for (w = (Word *) s->value; w; w = w->next) 17 | Bprint(&bout, "'%s'", w->s); 18 | Bprint(&bout, "\n"); 19 | } 20 | 21 | void 22 | dumpv(char *s) 23 | { 24 | Bprint(&bout, "%s:\n", s); 25 | symtraverse(S_VAR, print1); 26 | } 27 | 28 | char * 29 | shname(char *a) 30 | { 31 | Rune r; 32 | int n; 33 | 34 | while (*a) { 35 | n = chartorune(&r, a); 36 | if (!WORDCHR(r)) 37 | break; 38 | a += n; 39 | } 40 | return a; 41 | } 42 | -------------------------------------------------------------------------------- /src/cmd/mkppcimage/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=mkppcimage 4 | 5 | OFILES= mkppcimage.$O\ 6 | 7 | HFILES=\ 8 | a.out.h\ 9 | bio.h\ 10 | mach.h\ 11 | 12 | LIBS=mach bio 9 # order matters. 13 | 14 | 15 | BIN=$ROOT/$OBJDIR/bin 16 | 17 | <$ROOT/mkfiles/mkone-$SHELLTYPE 18 | -------------------------------------------------------------------------------- /src/cmd/ms2/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=ms2 4 | 5 | OFILES= ms2.$O\ 6 | 7 | HFILES= \ 8 | $ROOT/include/bio.h\ 9 | ${ROOT}/include/mach.h\ 10 | 11 | LIBS=mach bio 9 #order matters 12 | 13 | BIN=$ROOT/$OBJDIR/bin 14 | 15 | <$ROOT/mkfiles/mkone-$SHELLTYPE 16 | -------------------------------------------------------------------------------- /src/cmd/mv/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=mv 4 | 5 | OFILES= mv.$O\ 6 | 7 | HFILES= 8 | 9 | LIBS=9 10 | 11 | BIN=$ROOT/$OBJDIR/bin 12 | 13 | <$ROOT/mkfiles/mkone-$SHELLTYPE 14 | -------------------------------------------------------------------------------- /src/cmd/nm/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=inm # inferno nm 4 | 5 | OFILES=\ 6 | nm.$O\ 7 | 8 | LIBS=mach bio 9 # order is important. 9 | 10 | BIN=$ROOT/$OBJDIR/bin 11 | 12 | <$ROOT/mkfiles/mkone-$SHELLTYPE 13 | 14 | CFLAGS= $CFLAGS -I. 15 | -------------------------------------------------------------------------------- /src/cmd/qa/branch: -------------------------------------------------------------------------------- 1 | BO operand encodings 2 | 3 | 0+y 0000y decrement CTR, then branch if CTR != 0 && condition is false 4 | 2+y 0001y decrement CTR, then branch if CTR == 0 && condition is false 5 | 4+y 0010y branch if condition is false 6 | 8+y 0100y decrement CTR, then branch if CTR != 0 && condition is true 7 | 10+y 0101y decrement CTR, then branch if CTR == 0 && condition is true 8 | 12+y 0110y branch if condition is true 9 | 16+y 1000y decrement CTR, then branch if CTR != 0 10 | 18+y 1001y decrement CTR, then branch if CTR == 0 11 | 20 10100 branch always 12 | 13 | y=0: 14 | BCx with negative displacement: branch probably taken 15 | all other cases: branch not taken 16 | 17 | y=1: 18 | reverse prediction 19 | 20 | predict to be taken if 21 | ((BO[0] & BO[2]) | sign(displacement)) xor y 22 | 23 | CR field bit: 24 | 25 | lt 0 26 | gt 1 27 | eq 2 28 | so 3 29 | un 3 (after fp comparison) 30 | 31 | CR fields: 32 | 33 | cr0 0 34 | cr1 4 35 | cr2 8 36 | ... 37 | cr7 28 38 | -------------------------------------------------------------------------------- /src/cmd/qa/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=qa 4 | OFILES=\ 5 | y.tab.$O\ 6 | lex.$O\ 7 | 8 | HFILES=\ 9 | ../qc/q.out.h\ 10 | y.tab.h\ 11 | a.h\ 12 | 13 | YFILES=a.y\ 14 | 15 | LIBS=cc bio 9 # order is important 16 | 17 | BIN=$ROOT/$OBJDIR/bin 18 | 19 | <$ROOT/mkfiles/mkone-$SHELLTYPE 20 | 21 | YFLAGS=-D1 -d 22 | 23 | lex.$O: ../cc/macbody ../cc/lexbody 24 | 25 | $ROOT/$OBJDIR/lib/libcc.a: 26 | cd ../cc 27 | mk $MKFLAGS install 28 | mk $MKFLAGS clean 29 | -------------------------------------------------------------------------------- /src/cmd/qc/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../qc/q.out.h <<'!' 2 | v/^ A/d 3 | g/^ AEND/s//&,/ 4 | g/^ ALAST/s//&,/ 5 | g/[ ]*=.*,/s//,/ 6 | v/,/p 7 | ,s/^ A/ "/ 8 | ,s/,.*$/",/ 9 | 1i 10 | char *anames[] = 11 | { 12 | . 13 | ,a 14 | }; 15 | . 16 | w enam.c 17 | Q 18 | ! 19 | -------------------------------------------------------------------------------- /src/cmd/qc/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=qc 4 | OFILES=\ 5 | cgen.$O\ 6 | enam.$O\ 7 | list.$O\ 8 | machcap.$O\ 9 | mul.$O\ 10 | peep.$O\ 11 | pgen.$O\ 12 | pswt.$O\ 13 | reg.$O\ 14 | sgen.$O\ 15 | swt.$O\ 16 | txt.$O\ 17 | 18 | HFILES=\ 19 | gc.h\ 20 | q.out.h\ 21 | ../cc/cc.h\ 22 | 23 | LIBS=cc bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | 29 | $ROOT/$OBJDIR/lib/libcc.a: 30 | cd ../cc 31 | mk $MKFLAGS install 32 | mk $MKFLAGS clean 33 | 34 | %.$O: ../cc/%.c 35 | $CC -I. $CFLAGS ../cc/$stem.c 36 | 37 | #enam.c: q.out.h 38 | # rc mkenam 39 | -------------------------------------------------------------------------------- /src/cmd/ql/cnam.c: -------------------------------------------------------------------------------- 1 | char *cnames[] = 2 | { 3 | "NONE", 4 | "REG", 5 | "FREG", 6 | "CREG", 7 | "SPR", 8 | "SREG", 9 | "ZCON", 10 | "SCON", 11 | "UCON", 12 | "ADDCON", 13 | "ANDCON", 14 | "LCON", 15 | "SACON", 16 | "SECON", 17 | "LACON", 18 | "LECON", 19 | "SBRA", 20 | "LBRA", 21 | "SAUTO", 22 | "LAUTO", 23 | "SEXT", 24 | "LEXT", 25 | "ZOREG", 26 | "SOREG", 27 | "LOREG", 28 | "FPSCR", 29 | "MSR", 30 | "XER", 31 | "LR", 32 | "CTR", 33 | "ANY", 34 | "GOK", 35 | "ADDR", 36 | "NCLASS", 37 | }; 38 | -------------------------------------------------------------------------------- /src/cmd/ql/mkcname: -------------------------------------------------------------------------------- 1 | ed - ../ql/l.h <<'!' 2 | v/^ C_/d 3 | g/^ C_NCLASS/s//&,/ 4 | g/[ ]*=.*,/s//,/ 5 | v/,/p 6 | ,s/^ C_/ "/ 7 | ,s/,.*$/",/ 8 | 1i 9 | char *cnames[] = 10 | { 11 | . 12 | ,a 13 | }; 14 | . 15 | w cnam.c 16 | Q 17 | ! 18 | -------------------------------------------------------------------------------- /src/cmd/ql/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=ql 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | asmout.$O\ 8 | list.$O\ 9 | noop.$O\ 10 | obj.$O\ 11 | optab.$O\ 12 | pass.$O\ 13 | span.$O\ 14 | enam.$O\ 15 | cnam.$O\ 16 | sched.$O\ 17 | $TARGMODEL.$O\ 18 | elf.$O\ 19 | 20 | HFILES=\ 21 | l.h\ 22 | ../qc/q.out.h\ 23 | ${ROOT}/include/ar.h\ 24 | 25 | LIBS=bio 9 # order is important 26 | 27 | BIN=$ROOT/$OBJDIR/bin 28 | 29 | <$ROOT/mkfiles/mkone-$SHELLTYPE 30 | 31 | CFLAGS= $CFLAGS -I. 32 | 33 | enam.$O: ../qc/enam.c 34 | $CC $CFLAGS ../qc/enam.c 35 | 36 | elf.$O: ../ld/elf.c 37 | $CC $CFLAGS ../ld/elf.c 38 | #cnam.c: l.h 39 | # rc mkcname 40 | 41 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 42 | $CC $CFLAGS ../ld/$TARGMODEL.c 43 | -------------------------------------------------------------------------------- /src/cmd/rcsh/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | # 4 | # this directory contains a stripped-down version of rc 5 | # it is only build for Windows Nt and Windows 95 6 | 7 | TARG=rcsh 8 | 9 | OFILES= code.$O\ 10 | exec.$O\ 11 | glob.$O\ 12 | here.$O\ 13 | io.$O\ 14 | lex.$O\ 15 | main.$O\ 16 | $TARGMODEL.$O\ 17 | pcmd.$O\ 18 | pfnc.$O\ 19 | simple.$O\ 20 | trap.$O\ 21 | tree.$O\ 22 | var.$O\ 23 | word.$O\ 24 | y.tab.$O\ 25 | 26 | HFILES= rc.h\ 27 | y.tab.h\ 28 | 29 | YFILES= syn.y 30 | 31 | LIBS=9 32 | 33 | BIN=$ROOT/$OBJDIR/bin 34 | 35 | <$ROOT/mkfiles/mkone-$SHELLTYPE 36 | 37 | CFLAGS= $CFLAGS '-DROOT="'$ROOT'"' 38 | 39 | $BIN/%:Q: $O.out 40 | echo $TARG must be installed manually on Windows systems 41 | echo use: cp $O.out $target 42 | cp $O.out $target 43 | 44 | install:V: $ROOT/lib/rcmain 45 | 46 | $ROOT/lib/rcmain:Q: rcmain 47 | echo $prereq must be installed manually on Windows systems 48 | echo use: cp $prereq $target 49 | cp $prereq $target 50 | 51 | Posix.c Inferno.c:QV: 52 | echo $TARG is only built on Windows NT or Windows 95 53 | exit 1 54 | -------------------------------------------------------------------------------- /src/cmd/rcsh/rcmain: -------------------------------------------------------------------------------- 1 | # rcmain: 9pm version 2 | if(~ $#home 0) home=/ 3 | if(~ $#ifs 0) ifs=' 4 | ' 5 | switch($#prompt){ 6 | case 0 7 | case 1 8 | prompt=('% ' ' ') 9 | } 10 | if(~ $rcname v.out) prompt=('broken! ' ' ') 11 | if(! ~ $#cflag 0){ 12 | if(flag l && test -r $home/lib/profile) . $home/lib/profile 13 | status='' 14 | eval $cflag 15 | } 16 | if not if(flag i){ 17 | if(flag l && test -r $home/lib/profile) . $home/lib/profile 18 | status='' 19 | if(! ~ $#* 0) . $* 20 | if not . -i 'stdin$' 21 | } 22 | if not { 23 | if(~ $#* 0) . 'stdin$' 24 | if not{ 25 | status='' 26 | . $* 27 | } 28 | } 29 | exit $status 30 | -------------------------------------------------------------------------------- /src/cmd/rcsh/rcpath: -------------------------------------------------------------------------------- 1 | # rcmain: 9pm version 2 | PF='Program Files' 3 | MVS='Microsoft Visual Studio' 4 | PATH=D:/Users/Inferno/Nt/386/bin 5 | PATH=$PATH';'D:/apps/mks/mksnt 6 | PATH=$PATH';'C:/WINNT/system32 7 | PATH=$PATH';'C:/WINNT 8 | PATH=$PATH';'D:/$PF/$MVS/Common/Tools/WinNT 9 | PATH=$PATH';'D:/$PF/$MVS/Common/MSDev98/Bin 10 | PATH=$PATH';'D:/$PF/$MVS/Common/Tools 11 | PATH=$PATH';'D:/$PF/$MVS/VC98/bin 12 | PATH=$PATH';'D:/MSSQL7/BINN 13 | PATH=$PATH';'D:/$PF/Mts 14 | -------------------------------------------------------------------------------- /src/cmd/rcsh/trap.c: -------------------------------------------------------------------------------- 1 | #include "rc.h" 2 | 3 | int interrupted; 4 | Ref ntrap; 5 | 6 | /* runs in a different thread */ 7 | void 8 | dointr(void) 9 | { 10 | refinc(&ntrap); 11 | interrupted = 1; 12 | } 13 | 14 | void 15 | dotrap(void) 16 | { 17 | Var *trapreq; 18 | Word *starval; 19 | 20 | while(refdec(&ntrap) >= 0) { 21 | if(flag['S']) 22 | exits(truestatus()?"":getstatus()); 23 | starval=vlook("*")->val; 24 | trapreq=vlook("sysint"); 25 | if(trapreq->fn){ 26 | start(trapreq->fn, trapreq->pc, (Var*)0); 27 | runq->local=newvar(strdup("*"), runq->local); 28 | runq->local->val=copywords(starval, (Word*)0); 29 | runq->local->changed=1; 30 | runq->redir=runq->startredir=0; 31 | } else { 32 | /* 33 | * run the stack down until we uncover the 34 | * command reading loop. Xreturn will exit 35 | * if there is none (i.e. if this is not 36 | * an interactive rc.) 37 | */ 38 | while(!runq->iflag) 39 | Xreturn(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/cmd/retired/0a/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=0a 5 | 6 | OFILES=\ 7 | y.tab.$O\ 8 | lex.$O\ 9 | 10 | HFILES=\ 11 | ../vc/v.out.h\ 12 | y.tab.h\ 13 | a.h\ 14 | 15 | YFILES= a.y\ 16 | 17 | LIBS=cc bio 9 # order is important 18 | 19 | BIN=$ROOT/$OBJDIR/bin 20 | 21 | <$ROOT/mkfiles/mkone-$SHELLTYPE 22 | 23 | YFLAGS=-D1 -d 24 | 25 | lex.$O: ../cc/macbody ../cc/lexbody 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/retired/0c/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../vc/v.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/retired/0c/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=0c 5 | 6 | OFILES= cgen.$O\ 7 | enam.$O\ 8 | list.$O\ 9 | peep.$O\ 10 | reg.$O\ 11 | sgen.$O\ 12 | swt.$O\ 13 | txt.$O\ 14 | mul.$O\ 15 | 16 | HFILES= gc.h\ 17 | v.out.h\ 18 | ../cc/cc.h\ 19 | 20 | LIBS=cc bio 9 # order is important 21 | 22 | BIN=$ROOT/$OBJDIR/bin 23 | 24 | <$ROOT/mkfiles/mkone-$SHELLTYPE 25 | 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/retired/0l/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "l.h" 3 | 4 | /* 5 | * fake malloc 6 | */ 7 | void* 8 | malloc(uint n) 9 | { 10 | void *p; 11 | 12 | while(n & 7) 13 | n++; 14 | while(nhunk < n) 15 | gethunk(); 16 | p = hunk; 17 | nhunk -= n; 18 | hunk += n; 19 | return p; 20 | } 21 | 22 | void 23 | free(void *p) 24 | { 25 | USED(p); 26 | } 27 | 28 | void* 29 | calloc(uint m, uint n) 30 | { 31 | void *p; 32 | 33 | n *= m; 34 | p = malloc(n); 35 | memset(p, 0, n); 36 | return p; 37 | } 38 | 39 | void* 40 | realloc(void *p, uint n) 41 | { 42 | void *new; 43 | 44 | new = malloc(n); 45 | if(new && p) 46 | memmove(new, p, n); 47 | return new; 48 | } 49 | 50 | #define Chunk (1*1024*1024) 51 | 52 | void* 53 | mysbrk(ulong size) 54 | { 55 | void *v; 56 | static int chunk; 57 | static uchar *brk; 58 | 59 | if(chunk < size) { 60 | chunk = Chunk; 61 | if(chunk < size) 62 | chunk = Chunk + size; 63 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 64 | if(brk == 0) 65 | return (void*)-1; 66 | } 67 | v = brk; 68 | chunk -= size; 69 | brk += size; 70 | return v; 71 | } 72 | 73 | double 74 | cputime(void) 75 | { 76 | return ((double)0); 77 | } 78 | -------------------------------------------------------------------------------- /src/cmd/retired/0l/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | 54 | void 55 | setmalloctag(void*, ulong) 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /src/cmd/retired/0l/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | double 51 | cputime(void) 52 | { 53 | 54 | struct tms tmbuf; 55 | double ret_val; 56 | 57 | /* 58 | * times() only fials if &tmbuf is invalid. 59 | */ 60 | (void)times(&tmbuf); 61 | /* 62 | * Return the total time (in system clock ticks) 63 | * spent in user code and system 64 | * calls by both the calling process and its children. 65 | */ 66 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 67 | tmbuf.tms_cutime + tmbuf.tms_cstime); 68 | /* 69 | * Convert to seconds. 70 | */ 71 | ret_val *= sysconf(_SC_CLK_TCK); 72 | return ret_val; 73 | 74 | } 75 | 76 | void* 77 | mysbrk(ulong size) 78 | { 79 | return (void*)sbrk(size); 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/retired/0l/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=0l 5 | OFILES=\ 6 | asm.$O\ 7 | list.$O\ 8 | noop.$O\ 9 | sched.$O\ 10 | obj.$O\ 11 | optab.$O\ 12 | pass.$O\ 13 | span.$O\ 14 | enam.$O\ 15 | $TARGMODEL.$O\ 16 | 17 | HFILES=\ 18 | l.h\ 19 | ../vc/v.out.h\ 20 | ${ROOT}/include/ar.h\ 21 | 22 | LIBS=bio 9 23 | 24 | BIN=$ROOT/$OBJDIR/bin 25 | 26 | <$ROOT/mkfiles/mkone-$SHELLTYPE 27 | 28 | CFLAGS= $CFLAGS -I ${ROOT}/include 29 | 30 | enam.$O: ../0c/enam.c 31 | $CC $CFLAGS ../0c/enam.c 32 | -------------------------------------------------------------------------------- /src/cmd/retired/1a/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=1a 5 | 6 | OFILES=\ 7 | y.tab.$O\ 8 | lex.$O\ 9 | 10 | HFILES=\ 11 | ../2c/2.out.h\ 12 | y.tab.h\ 13 | a.h\ 14 | 15 | YFILES=a.y\ 16 | 17 | LIBS=cc bio 9 # order is important 18 | 19 | BIN=$ROOT/$OBJDIR/bin 20 | 21 | <$ROOT/mkfiles/mkone-$SHELLTYPE 22 | 23 | YFLAGS=-D1 -d 24 | 25 | lex.$O: ../cc/macbody ../cc/lexbody 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/retired/1c/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=1c 5 | 6 | OFILES=\ 7 | cgen.$O\ 8 | reg.$O\ 9 | txt.$O\ 10 | peep.$O\ 11 | swt.$O\ 12 | sgen.$O\ 13 | list.$O\ 14 | enam.$O\ 15 | mul.$O\ 16 | 17 | HFILES= gc.h\ 18 | ../2c/2.out.h\ 19 | ../cc/cc.h\ 20 | 21 | LIBS=cc bio 9 # order is important 22 | 23 | BIN=$ROOT/$OBJDIR/bin 24 | 25 | <$ROOT/mkfiles/mkone-$SHELLTYPE 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/retired/1l/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "l.h" 3 | 4 | /* 5 | * fake malloc 6 | */ 7 | void* 8 | malloc(uint n) 9 | { 10 | void *p; 11 | 12 | while(n & 7) 13 | n++; 14 | while(nhunk < n) 15 | gethunk(); 16 | p = hunk; 17 | nhunk -= n; 18 | hunk += n; 19 | return p; 20 | } 21 | 22 | void 23 | free(void *p) 24 | { 25 | USED(p); 26 | } 27 | 28 | void* 29 | calloc(uint m, uint n) 30 | { 31 | void *p; 32 | 33 | n *= m; 34 | p = malloc(n); 35 | memset(p, 0, n); 36 | return p; 37 | } 38 | 39 | void* 40 | realloc(void *p, uint n) 41 | { 42 | void *new; 43 | 44 | new = malloc(n); 45 | if(new && p) 46 | memmove(new, p, n); 47 | return new; 48 | } 49 | 50 | #define Chunk (1*1024*1024) 51 | 52 | void* 53 | mysbrk(ulong size) 54 | { 55 | void *v; 56 | static int chunk; 57 | static uchar *brk; 58 | 59 | if(chunk < size) { 60 | chunk = Chunk; 61 | if(chunk < size) 62 | chunk = Chunk + size; 63 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 64 | if(brk == 0) 65 | return (void*)-1; 66 | } 67 | v = brk; 68 | chunk -= size; 69 | brk += size; 70 | return v; 71 | } 72 | 73 | double 74 | cputime(void) 75 | { 76 | return ((double)0); 77 | } 78 | -------------------------------------------------------------------------------- /src/cmd/retired/1l/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | 54 | void 55 | setmalloctag(void*, ulong) 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /src/cmd/retired/1l/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | double 51 | cputime(void) 52 | { 53 | 54 | struct tms tmbuf; 55 | double ret_val; 56 | 57 | /* 58 | * times() only fials if &tmbuf is invalid. 59 | */ 60 | (void)times(&tmbuf); 61 | /* 62 | * Return the total time (in system clock ticks) 63 | * spent in user code and system 64 | * calls by both the calling process and its children. 65 | */ 66 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 67 | tmbuf.tms_cutime + tmbuf.tms_cstime); 68 | /* 69 | * Convert to seconds. 70 | */ 71 | ret_val *= sysconf(_SC_CLK_TCK); 72 | return ret_val; 73 | 74 | } 75 | 76 | void* 77 | mysbrk(ulong size) 78 | { 79 | return (void*)sbrk(size); 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/retired/1l/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=1l 5 | OFILES=\ 6 | asm.$O\ 7 | obj.$O\ 8 | optab.$O\ 9 | pass.$O\ 10 | span.$O\ 11 | list.$O\ 12 | enam.$O\ 13 | $TARGMODEL.$O\ 14 | 15 | HFILES=\ 16 | l.h\ 17 | ../2c/2.out.h\ 18 | ${ROOT}/include/ar.h\ 19 | 20 | LIBS=bio 9 21 | BIN=$ROOT/$OBJDIR/bin 22 | <$ROOT/mkfiles/mkone-$SHELLTYPE 23 | 24 | CFLAGS= $CFLAGS -I ${ROOT}/include 25 | 26 | enam.$O: ../2c/enam.c 27 | $CC $CFLAGS ../2c/enam.c 28 | 29 | %.1: %.s 30 | 1a $stem.s 31 | 32 | %.1: %.c 33 | 1c -w $stem.c 34 | -------------------------------------------------------------------------------- /src/cmd/retired/2a/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=2a 5 | 6 | OFILES=\ 7 | y.tab.$O\ 8 | lex.$O\ 9 | 10 | HFILES=\ 11 | ../2c/2.out.h\ 12 | y.tab.h\ 13 | a.h\ 14 | 15 | YFILES=a.y\ 16 | 17 | LIBS=cc bio 9 # order is important 18 | 19 | BIN=$ROOT/$OBJDIR/bin 20 | 21 | <$ROOT/mkfiles/mkone-$SHELLTYPE 22 | 23 | YFLAGS=-D1 -d 24 | 25 | lex.$O: ../cc/macbody ../cc/lexbody 26 | 27 | $ROOT/$OBJDIR/lib/libcc.a: 28 | cd ../cc 29 | mk $MKFLAGS install 30 | mk $MKFLAGS clean 31 | -------------------------------------------------------------------------------- /src/cmd/retired/2c/Update: -------------------------------------------------------------------------------- 1 | if(n->op == ONAME) { 2 | < if(o == OSET) 3 | < gopcode(OTST, tint, D_NONE, Z, D_TREE, n); 4 | < else 5 | < gopcode(OTST, tint, D_TREE, n, D_NONE, Z); 6 | < p->as = ANOP; 7 | < } 8 | -------------------------------------------------------------------------------- /src/cmd/retired/2c/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=2c 5 | 6 | OFILES=\ 7 | cgen.$O\ 8 | reg.$O\ 9 | txt.$O\ 10 | peep.$O\ 11 | swt.$O\ 12 | sgen.$O\ 13 | list.$O\ 14 | enam.$O\ 15 | mul.$O\ 16 | 17 | HFILES=\ 18 | gc.h\ 19 | 2.out.h\ 20 | ../cc/cc.h\ 21 | 22 | LIBS=cc bio 9 # order is important 23 | 24 | BIN=$ROOT/$OBJDIR/bin 25 | 26 | <$ROOT/mkfiles/mkone-$SHELLTYPE 27 | 28 | CFLAGS= $CFLAGS -I. 29 | 30 | $ROOT/$OBJDIR/lib/libcc.a: 31 | cd ../cc 32 | mk $MKFLAGS install 33 | mk $MKFLAGS clean 34 | -------------------------------------------------------------------------------- /src/cmd/retired/2l/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "l.h" 3 | 4 | /* 5 | * fake malloc 6 | */ 7 | void* 8 | malloc(uint n) 9 | { 10 | void *p; 11 | 12 | while(n & 7) 13 | n++; 14 | while(nhunk < n) 15 | gethunk(); 16 | p = hunk; 17 | nhunk -= n; 18 | hunk += n; 19 | return p; 20 | } 21 | 22 | void 23 | free(void *p) 24 | { 25 | USED(p); 26 | } 27 | 28 | void* 29 | calloc(uint m, uint n) 30 | { 31 | void *p; 32 | 33 | n *= m; 34 | p = malloc(n); 35 | memset(p, 0, n); 36 | return p; 37 | } 38 | 39 | void* 40 | realloc(void *p, uint n) 41 | { 42 | void *new; 43 | 44 | new = malloc(n); 45 | if(new && p) 46 | memmove(new, p, n); 47 | return new; 48 | } 49 | 50 | #define Chunk (1*1024*1024) 51 | 52 | void* 53 | mysbrk(ulong size) 54 | { 55 | void *v; 56 | static int chunk; 57 | static uchar *brk; 58 | 59 | if(chunk < size) { 60 | chunk = Chunk; 61 | if(chunk < size) 62 | chunk = Chunk + size; 63 | brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 64 | if(brk == 0) 65 | return (void*)-1; 66 | } 67 | v = brk; 68 | chunk -= size; 69 | brk += size; 70 | return v; 71 | } 72 | 73 | double 74 | cputime(void) 75 | { 76 | return ((double)0); 77 | } 78 | -------------------------------------------------------------------------------- /src/cmd/retired/2l/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void *p, ulong n) 40 | { 41 | USED(p); 42 | USED(n); 43 | fprint(2, "realloc called\n"); 44 | abort(); 45 | return 0; 46 | } 47 | 48 | void* 49 | mysbrk(ulong size) 50 | { 51 | return sbrk(size); 52 | } 53 | 54 | void 55 | setmalloctag(void*, ulong) 56 | { 57 | } 58 | -------------------------------------------------------------------------------- /src/cmd/retired/2l/Posix.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | #include 3 | #include 4 | #undef getwd 5 | #include /* For sysconf() and _SC_CLK_TCK */ 6 | 7 | /* 8 | * fake malloc 9 | */ 10 | void* 11 | malloc(size_t n) 12 | { 13 | void *p; 14 | 15 | while(n & 7) 16 | n++; 17 | while(nhunk < n) 18 | gethunk(); 19 | p = hunk; 20 | nhunk -= n; 21 | hunk += n; 22 | return p; 23 | } 24 | 25 | void 26 | free(void *p) 27 | { 28 | USED(p); 29 | } 30 | 31 | void* 32 | calloc(size_t m, size_t n) 33 | { 34 | void *p; 35 | 36 | n *= m; 37 | p = malloc(n); 38 | memset(p, 0, n); 39 | return p; 40 | } 41 | 42 | void* 43 | realloc(void *p, size_t n) 44 | { 45 | fprint(2, "realloc called\n", p, n); 46 | abort(); 47 | return 0; 48 | } 49 | 50 | double 51 | cputime(void) 52 | { 53 | 54 | struct tms tmbuf; 55 | double ret_val; 56 | 57 | /* 58 | * times() only fials if &tmbuf is invalid. 59 | */ 60 | (void)times(&tmbuf); 61 | /* 62 | * Return the total time (in system clock ticks) 63 | * spent in user code and system 64 | * calls by both the calling process and its children. 65 | */ 66 | ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + 67 | tmbuf.tms_cutime + tmbuf.tms_cstime); 68 | /* 69 | * Convert to seconds. 70 | */ 71 | ret_val *= sysconf(_SC_CLK_TCK); 72 | return ret_val; 73 | 74 | } 75 | 76 | void* 77 | mysbrk(ulong size) 78 | { 79 | return (void*)sbrk(size); 80 | } 81 | -------------------------------------------------------------------------------- /src/cmd/retired/2l/mkfile: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- 2 | <../../../mkconfig 3 | 4 | TARG=2l 5 | OFILES=\ 6 | asm.$O\ 7 | obj.$O\ 8 | optab.$O\ 9 | pass.$O\ 10 | span.$O\ 11 | list.$O\ 12 | enam.$O\ 13 | $TARGMODEL.$O\ 14 | 15 | HFILES=\ 16 | l.h\ 17 | ../2c/2.out.h\ 18 | ${ROOT}/include/ar.h\ 19 | 20 | LIBS=bio 9 21 | BIN=$ROOT/$OBJDIR/bin 22 | <$ROOT/mkfiles/mkone-$SHELLTYPE 23 | 24 | CFLAGS= $CFLAGS -I ${ROOT}/include 25 | 26 | enam.$O: ../2c/enam.c 27 | $CC $CFLAGS ../2c/enam.c 28 | -------------------------------------------------------------------------------- /src/cmd/rm/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | # 4 | # the rm command is only needed on Windows NT and Windows 95 5 | # 6 | 7 | TARG=rm 8 | 9 | OFILES= rm-$TARGMODEL.$O\ 10 | 11 | HFILES= 12 | 13 | LIBS=9 14 | 15 | BIN=$ROOT/$OBJDIR/bin 16 | 17 | <$ROOT/mkfiles/mkone-$SHELLTYPE 18 | 19 | rm-Posix.c rm-Inferno.c:QV: 20 | echo 'rm is only built on Windows NT or Windows 95' 21 | exit 1 22 | 23 | $BIN/rm.exe: $O.out 24 | rm -f $target && cp $prereq $target 25 | -------------------------------------------------------------------------------- /src/cmd/sqz/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | CFLAGS=$CFLAGS -I${ROOT}/include 3 | 4 | TARG=sqz 5 | 6 | OFILES= sqz.$O\ 7 | 8 | HFILES= \ 9 | squeeze.h\ 10 | ${ROOT}/include/a.out.h\ 11 | ${ROOT}/include/mach.h\ 12 | 13 | LIBS= mach bio 9 14 | 15 | BIN=$ROOT/$OBJDIR/bin 16 | 17 | <$ROOT/mkfiles/mkone-$SHELLTYPE 18 | 19 | -------------------------------------------------------------------------------- /src/cmd/sqz/squeeze.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * squeezed file format: 4 | * Sqhdr 5 | * original Exec header 6 | * two Squeeze tables 7 | * squeezed segment 8 | * unsqueezed segment, if any 9 | */ 10 | #define SQMAGIC (ulong)0xFEEF0F1E 11 | 12 | typedef struct Sqhdr Sqhdr; 13 | struct Sqhdr { 14 | uchar magic[4]; /* SQMAGIC */ 15 | uchar text[4]; /* squeezed length of text (excluding tables) */ 16 | uchar data[4]; /* squeezed length of data (excluding tables) */ 17 | uchar asis[4]; /* length of unsqueezed segment */ 18 | uchar toptxt[4]; /* value for 0 encoding in text */ 19 | uchar topdat[4]; /* value for 0 encoding in data */ 20 | uchar sum[4]; /* simple checksum of unsqueezed data */ 21 | uchar flags[4]; 22 | }; 23 | #define SQHDRLEN (8*4) 24 | 25 | /* 26 | * certain power instruction types are rearranged by sqz 27 | * so as to move the variable part of the instruction word to the 28 | * low order bits. note that the mapping is its own inverse. 29 | */ 30 | #define QREMAP(X)\ 31 | switch((X)>>26){\ 32 | case 19: case 31: case 59: case 63:\ 33 | (X) = (((X) & 0xFC00F801) | (((X)>>15)&0x7FE) | (((X)&0x7FE)<<15));\ 34 | } 35 | -------------------------------------------------------------------------------- /src/cmd/srclist/Nt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "lib9.h" 3 | 4 | char* 5 | mygetwd(char *path, int len) 6 | { 7 | return getcwd(path, len); 8 | } 9 | -------------------------------------------------------------------------------- /src/cmd/srclist/Plan9.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | mygetwd(char *path, int len) 5 | { 6 | return getwd(path, len); 7 | } 8 | -------------------------------------------------------------------------------- /src/cmd/srclist/Posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #undef getwd 3 | #undef getwd 4 | #include 5 | 6 | char* 7 | mygetwd(char *path, int len) 8 | { 9 | return getcwd(path, len); 10 | } 11 | -------------------------------------------------------------------------------- /src/cmd/srclist/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=srclist 4 | 5 | OFILES= srclist.$O\ 6 | $TARGMODEL.$O\ 7 | 8 | HFILES=\ 9 | a.out.h\ 10 | bio.h\ 11 | mach.h\ 12 | 13 | LIBS=mach bio 9 # order matters. 14 | 15 | 16 | BIN=$ROOT/$OBJDIR/bin 17 | 18 | <$ROOT/mkfiles/mkone-$SHELLTYPE 19 | -------------------------------------------------------------------------------- /src/cmd/tc/enam.c: -------------------------------------------------------------------------------- 1 | char* anames[] = 2 | { 3 | "XXX", 4 | "AND", 5 | "EOR", 6 | "SUB", 7 | "RSB", 8 | "ADD", 9 | "ADC", 10 | "SBC", 11 | "RSC", 12 | "TST", 13 | "TEQ", 14 | "CMP", 15 | "CMN", 16 | "ORR", 17 | "BIC", 18 | "MVN", 19 | "B", 20 | "BL", 21 | "BEQ", 22 | "BNE", 23 | "BCS", 24 | "BHS", 25 | "BCC", 26 | "BLO", 27 | "BMI", 28 | "BPL", 29 | "BVS", 30 | "BVC", 31 | "BHI", 32 | "BLS", 33 | "BGE", 34 | "BLT", 35 | "BGT", 36 | "BLE", 37 | "MOVWD", 38 | "MOVWF", 39 | "MOVDW", 40 | "MOVFW", 41 | "MOVFD", 42 | "MOVDF", 43 | "MOVF", 44 | "MOVD", 45 | "CMPF", 46 | "CMPD", 47 | "ADDF", 48 | "ADDD", 49 | "SUBF", 50 | "SUBD", 51 | "MULF", 52 | "MULD", 53 | "DIVF", 54 | "DIVD", 55 | "SRL", 56 | "SRA", 57 | "SLL", 58 | "MULU", 59 | "DIVU", 60 | "MUL", 61 | "DIV", 62 | "MOD", 63 | "MODU", 64 | "MOVB", 65 | "MOVBU", 66 | "MOVH", 67 | "MOVHU", 68 | "MOVW", 69 | "MOVM", 70 | "SWPBU", 71 | "SWPW", 72 | "NOP", 73 | "RFE", 74 | "SWI", 75 | "MULA", 76 | "DATA", 77 | "GLOBL", 78 | "GOK", 79 | "HISTORY", 80 | "NAME", 81 | "RET", 82 | "TEXT", 83 | "WORD", 84 | "DYNT", 85 | "INIT", 86 | "ABCASE", 87 | "ACASE", 88 | "END", 89 | "MULL", 90 | "MULAL", 91 | "MULLU", 92 | "MULALU", 93 | "BX", 94 | "BX", 95 | "DWORD", 96 | "SIGNAME", 97 | "LAST", 98 | }; 99 | -------------------------------------------------------------------------------- /src/cmd/tc/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../5ct/5.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/tc/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=tc 4 | 5 | OFILES= cgen.$O\ 6 | enam.$O\ 7 | list.$O\ 8 | mul.$O\ 9 | peep.$O\ 10 | reg.$O\ 11 | sgen.$O\ 12 | swt.$O\ 13 | txt.$O\ 14 | 15 | HFILES= gc.h\ 16 | 5.out.h\ 17 | ../cc/cc.h\ 18 | 19 | LIBS=cc bio 9 # order is important 20 | 21 | BIN=$ROOT/$OBJDIR/bin 22 | 23 | <$ROOT/mkfiles/mkone-$SHELLTYPE 24 | 25 | $ROOT/$OBJDIR/lib/libcc.a: 26 | cd ../cc 27 | mk $MKFLAGS install 28 | mk $MKFLAGS clean 29 | -------------------------------------------------------------------------------- /src/cmd/test/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | # 4 | # the test command is only needed on Windows NT and Windows 95 5 | # 6 | 7 | TARG=test 8 | 9 | OFILES= test-$TARGMODEL.$O\ 10 | 11 | HFILES= 12 | 13 | LIBS=9 14 | 15 | BIN=$ROOT/$OBJDIR/bin 16 | 17 | <$ROOT/mkfiles/mkone-$SHELLTYPE 18 | 19 | test-Posix.c test-Inferno.c:QV: 20 | echo 'test is only built on Windows NT or Windows 95' 21 | exit 1 22 | -------------------------------------------------------------------------------- /src/cmd/tl/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=5l 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | list.$O\ 8 | noop.$O\ 9 | obj.$O\ 10 | optab.$O\ 11 | pass.$O\ 12 | span.$O\ 13 | enam.$O\ 14 | $TARGMODEL.$O\ 15 | thumb.$O\ 16 | 17 | HFILES=\ 18 | l.h\ 19 | ../5c/5.out.h\ 20 | $ROOT/include/ar.h\ 21 | 22 | LIBS=bio 9 # order is important 23 | 24 | CFLAGS=$CFLAGS -I../include -I. 25 | 26 | BIN=$ROOT/$OBJDIR/bin 27 | 28 | <$ROOT/mkfiles/mkone-$SHELLTYPE 29 | 30 | enam.$O: ../5c/enam.c 31 | $CC $CFLAGS ../5c/enam.c 32 | 33 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 34 | $CC $CFLAGS ../ld/$TARGMODEL.c 35 | -------------------------------------------------------------------------------- /src/cmd/va/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=va 4 | 5 | OFILES=\ 6 | y.tab.$O\ 7 | lex.$O\ 8 | 9 | HFILES=\ 10 | ../vc/v.out.h\ 11 | y.tab.h\ 12 | a.h\ 13 | 14 | YFILES=a.y\ 15 | 16 | LIBS=cc bio 9 # order is important 17 | 18 | BIN=$ROOT/$OBJDIR/bin 19 | 20 | <$ROOT/mkfiles/mkone-$SHELLTYPE 21 | 22 | YFLAGS=-D1 -d 23 | 24 | lex.$O: ../cc/macbody ../cc/lexbody 25 | 26 | $ROOT/$OBJDIR/lib/libcc.a: 27 | cd ../cc 28 | mk $MKFLAGS install 29 | mk $MKFLAGS clean 30 | -------------------------------------------------------------------------------- /src/cmd/va/note: -------------------------------------------------------------------------------- 1 | gen address 2 | 3 | $con 4 | type = D_CONST 5 | offset = con 6 | 7 | $name+con(P) 8 | type = D_CONST 9 | offset = con 10 | name = P 11 | 12 | $"xxx" 13 | type = D_SCONST 14 | 15 | $1.0 16 | type = D_FCONST 17 | 18 | con 19 | type = D_OREG 20 | offset = con 21 | 22 | name+con(P) 23 | type = D_OREG 24 | offset = con 25 | name = P 26 | 27 | con(R1) 28 | type = D_OREG 29 | offset = con 30 | reg = 1 31 | 32 | name+con(P)(R1) 33 | type = D_OREG 34 | offset = con 35 | name = P 36 | reg = 1 37 | 38 | R1 39 | type = D_REG 40 | reg = 1 41 | 42 | MOVB[U] 43 | LB[U], SB 44 | MOVH[U] 45 | LH[U], SB 46 | MOVW[LR] 47 | LW[LR], SW[LR] 48 | MOVW 49 | LW, SW, LUI, M[FT]HI, M[FT]LO 50 | BREAK is synonym for CACHE. 51 | operands make the difference. 52 | -------------------------------------------------------------------------------- /src/cmd/vc/mkenam: -------------------------------------------------------------------------------- 1 | ed - ../vc/v.out.h <<'!' 2 | v/^ A/d 3 | ,s/^ A/ "/ 4 | g/ .*$/s/// 5 | ,s/,*$/",/ 6 | 1i 7 | char* anames[] = 8 | { 9 | . 10 | $a 11 | }; 12 | . 13 | w enam.c 14 | Q 15 | ! 16 | -------------------------------------------------------------------------------- /src/cmd/vc/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=vc 4 | 5 | OFILES=\ 6 | cgen.$O\ 7 | enam.$O\ 8 | list.$O\ 9 | peep.$O\ 10 | pgen.$O\ 11 | pswt.$O\ 12 | reg.$O\ 13 | sgen.$O\ 14 | swt.$O\ 15 | txt.$O\ 16 | mul.$O\ 17 | 18 | HFILES=\ 19 | gc.h\ 20 | v.out.h\ 21 | ../cc/cc.h\ 22 | 23 | LIBS=cc bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | CFLAGS= $CFLAGS -I. 29 | 30 | 31 | $ROOT/$OBJDIR/lib/libcc.a: 32 | cd ../cc 33 | mk $MKFLAGS install 34 | mk $MKFLAGS clean 35 | 36 | %.$O: ../cc/%.c 37 | $CC -I. $CFLAGS ../cc/$stem.c 38 | -------------------------------------------------------------------------------- /src/cmd/vl/compat.c: -------------------------------------------------------------------------------- 1 | #include "l.h" 2 | 3 | /* 4 | * fake malloc 5 | */ 6 | void* 7 | malloc(ulong n) 8 | { 9 | void *p; 10 | 11 | while(n & 7) 12 | n++; 13 | while(nhunk < n) 14 | gethunk(); 15 | p = hunk; 16 | nhunk -= n; 17 | hunk += n; 18 | return p; 19 | } 20 | 21 | void 22 | free(void *p) 23 | { 24 | USED(p); 25 | } 26 | 27 | void* 28 | calloc(ulong m, ulong n) 29 | { 30 | void *p; 31 | 32 | n *= m; 33 | p = malloc(n); 34 | memset(p, 0, n); 35 | return p; 36 | } 37 | 38 | void* 39 | realloc(void*, ulong) 40 | { 41 | fprint(2, "realloc called\n"); 42 | abort(); 43 | return 0; 44 | } 45 | 46 | void* 47 | mysbrk(ulong size) 48 | { 49 | return sbrk(size); 50 | } 51 | 52 | void 53 | setmalloctag(void *v, ulong pc) 54 | { 55 | USED(v, pc); 56 | } 57 | 58 | int 59 | fileexists(char *s) 60 | { 61 | uchar dirbuf[400]; 62 | 63 | /* it's fine if stat result doesn't fit in dirbuf, since even then the file exists */ 64 | return stat(s, dirbuf, sizeof(dirbuf)) >= 0; 65 | } 66 | -------------------------------------------------------------------------------- /src/cmd/vl/mkfile: -------------------------------------------------------------------------------- 1 | <../../../mkconfig 2 | 3 | TARG=vl 4 | 5 | OFILES=\ 6 | asm.$O\ 7 | list.$O\ 8 | noop.$O\ 9 | sched.$O\ 10 | obj.$O\ 11 | optab.$O\ 12 | pass.$O\ 13 | span.$O\ 14 | enam.$O\ 15 | $TARGMODEL.$O\ 16 | elf.$O\ 17 | 18 | HFILES=\ 19 | l.h\ 20 | ../vc/v.out.h\ 21 | ${ROOT}/include/ar.h\ 22 | 23 | LIBS=bio 9 # order is important 24 | 25 | BIN=$ROOT/$OBJDIR/bin 26 | 27 | <$ROOT/mkfiles/mkone-$SHELLTYPE 28 | CFLAGS= $CFLAGS -I. 29 | 30 | 31 | enam.$O: ../vc/enam.c 32 | $CC $CFLAGS ../vc/enam.c 33 | elf.$O: ../ld/elf.c 34 | $CC $CFLAGS ../ld/elf.c 35 | 36 | $TARGMODEL.$O: ../ld/$TARGMODEL.c 37 | $CC $CFLAGS ../ld/$TARGMODEL.c 38 | -------------------------------------------------------------------------------- /src/lib9/argv0.c: -------------------------------------------------------------------------------- 1 | char* argv0 = 0; 2 | -------------------------------------------------------------------------------- /src/lib9/cistrcmp.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | cistrcmp(char *s1, char *s2) 5 | { 6 | int c1, c2; 7 | 8 | while(*s1){ 9 | c1 = *(uchar*)s1++; 10 | c2 = *(uchar*)s2++; 11 | 12 | if(c1 == c2) 13 | continue; 14 | 15 | if(c1 >= 'A' && c1 <= 'Z') 16 | c1 -= 'A' - 'a'; 17 | 18 | if(c2 >= 'A' && c2 <= 'Z') 19 | c2 -= 'A' - 'a'; 20 | 21 | if(c1 != c2) 22 | return c1 - c2; 23 | } 24 | return -*s2; 25 | } 26 | -------------------------------------------------------------------------------- /src/lib9/cistrncmp.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | cistrncmp(char *s1, char *s2, int n) 5 | { 6 | int c1, c2; 7 | 8 | while(*s1 && n-- > 0){ 9 | c1 = *(uchar*)s1++; 10 | c2 = *(uchar*)s2++; 11 | 12 | if(c1 == c2) 13 | continue; 14 | 15 | if(c1 >= 'A' && c1 <= 'Z') 16 | c1 -= 'A' - 'a'; 17 | 18 | if(c2 >= 'A' && c2 <= 'Z') 19 | c2 -= 'A' - 'a'; 20 | 21 | if(c1 != c2) 22 | return c1 - c2; 23 | } 24 | if(n <= 0) 25 | return 0; 26 | return -*s2; 27 | } 28 | -------------------------------------------------------------------------------- /src/lib9/cistrstr.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | cistrstr(char *s, char *sub) 5 | { 6 | int c, csub, n; 7 | 8 | csub = *sub; 9 | if(csub == '\0') 10 | return s; 11 | if(csub >= 'A' && csub <= 'Z') 12 | csub -= 'A' - 'a'; 13 | sub++; 14 | n = strlen(sub); 15 | for(; c = *s; s++){ 16 | if(c >= 'A' && c <= 'Z') 17 | c -= 'A' - 'a'; 18 | if(c == csub && cistrncmp(s+1, sub, n) == 0) 19 | return s; 20 | } 21 | return nil; 22 | } 23 | -------------------------------------------------------------------------------- /src/lib9/cleanname.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * In place, rewrite name to compress multiple /, eliminate ., and process .. 5 | */ 6 | #define SEP(x) ((x)=='/' || (x) == 0) 7 | char* 8 | cleanname(char *name) 9 | { 10 | char *p, *q, *dotdot; 11 | int rooted; 12 | 13 | rooted = name[0] == '/'; 14 | 15 | /* 16 | * invariants: 17 | * p points at beginning of path element we're considering. 18 | * q points just past the last path element we wrote (no slash). 19 | * dotdot points just past the point where .. cannot backtrack 20 | * any further (no slash). 21 | */ 22 | p = q = dotdot = name+rooted; 23 | while(*p) { 24 | if(p[0] == '/') /* null element */ 25 | p++; 26 | else if(p[0] == '.' && SEP(p[1])) 27 | p += 1; /* don't count the separator in case it is nul */ 28 | else if(p[0] == '.' && p[1] == '.' && SEP(p[2])) { 29 | p += 2; 30 | if(q > dotdot) { /* can backtrack */ 31 | while(--q > dotdot && *q != '/') 32 | ; 33 | } else if(!rooted) { /* /.. is / but ./../ is .. */ 34 | if(q != name) 35 | *q++ = '/'; 36 | *q++ = '.'; 37 | *q++ = '.'; 38 | dotdot = q; 39 | } 40 | } else { /* real path element */ 41 | if(q != name+rooted) 42 | *q++ = '/'; 43 | while((*q = *p) != '/' && *q != 0) 44 | p++, q++; 45 | } 46 | } 47 | if(q == name) /* empty string is really ``.'' */ 48 | *q++ = '.'; 49 | *q = '\0'; 50 | return name; 51 | } 52 | -------------------------------------------------------------------------------- /src/lib9/create.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | int 6 | create(char *f, int mode, int perm) 7 | { 8 | int m; 9 | 10 | m = 0; 11 | switch(mode & 3){ 12 | case OREAD: 13 | case OEXEC: 14 | m = O_RDONLY; 15 | break; 16 | case OWRITE: 17 | m = O_WRONLY; 18 | break; 19 | case ORDWR: 20 | m = O_RDWR; 21 | break; 22 | } 23 | m |= O_CREAT|O_TRUNC; 24 | 25 | if(perm & DMDIR){ 26 | if(mkdir(f, perm&0777) < 0) 27 | return -1; 28 | perm &= ~DMDIR; 29 | m &= 3; 30 | } 31 | return open(f, m, perm); 32 | } 33 | -------------------------------------------------------------------------------- /src/lib9/dirwstat.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | int 6 | dirfwstat(int fd, Dir *d) 7 | { 8 | return -1; 9 | } 10 | 11 | int 12 | dirwstat(char *name, Dir *d) 13 | { 14 | return -1; 15 | } 16 | -------------------------------------------------------------------------------- /src/lib9/errfmt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | int 18 | errfmt(Fmt *f) 19 | { 20 | char buf[ERRMAX]; 21 | 22 | rerrstr(buf, sizeof buf); 23 | return _fmtcpy(f, buf, utflen(buf), strlen(buf)); 24 | } 25 | -------------------------------------------------------------------------------- /src/lib9/errstr-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | static char errstring[ERRMAX]; 5 | 6 | enum 7 | { 8 | Magic = 0xffffff 9 | }; 10 | 11 | static void 12 | winerror(int e, char *buf, uint nerr) 13 | { 14 | int r; 15 | char buf2[ERRMAX], *p, *q; 16 | 17 | r = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 18 | 0, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 19 | buf2, sizeof(buf2), 0); 20 | 21 | if(r == 0) 22 | snprint(buf2, ERRMAX, "windows error %d", e); 23 | 24 | q = buf2; 25 | for(p = buf2; *p; p++) { 26 | if(*p == '\r') 27 | continue; 28 | if(*p == '\n') 29 | *q++ = ' '; 30 | else 31 | *q++ = *p; 32 | } 33 | *q = '\0'; 34 | utfecpy(buf, buf+nerr, buf2); 35 | } 36 | 37 | void 38 | werrstr(char *fmt, ...) 39 | { 40 | va_list arg; 41 | 42 | va_start(arg, fmt); 43 | vseprint(errstring, errstring+sizeof(errstring), fmt, arg); 44 | va_end(arg); 45 | SetLastError(Magic); 46 | } 47 | 48 | int 49 | errstr(char *buf, uint nerr) 50 | { 51 | DWORD le; 52 | 53 | le = GetLastError(); 54 | if(le == Magic) 55 | utfecpy(buf, buf+nerr, errstring); 56 | else 57 | winerror(le, buf, nerr); 58 | return 1; 59 | } 60 | 61 | void 62 | oserrstr(char *buf, uint nerr) 63 | { 64 | winerror(GetLastError(), buf, nerr); 65 | } 66 | -------------------------------------------------------------------------------- /src/lib9/errstr-Plan9.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | oserrstr(char *buf, uint nerr) 5 | { 6 | *buf = 0; 7 | errstr(buf, nerr); 8 | } 9 | -------------------------------------------------------------------------------- /src/lib9/errstr-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | #include 4 | 5 | static char errstring[ERRMAX]; 6 | 7 | enum 8 | { 9 | Magic = 0xffffff 10 | }; 11 | 12 | void 13 | werrstr(char *fmt, ...) 14 | { 15 | va_list arg; 16 | 17 | va_start(arg, fmt); 18 | vseprint(errstring, errstring+sizeof(errstring), fmt, arg); 19 | va_end(arg); 20 | errno = Magic; 21 | } 22 | 23 | void 24 | oserrstr(char *buf, uint nerr) 25 | { 26 | utfecpy(buf, buf+nerr, strerror(errno)); 27 | } 28 | 29 | int 30 | errstr(char *buf, uint nerr) 31 | { 32 | if(errno == Magic) 33 | utfecpy(buf, buf+nerr, errstring); 34 | else 35 | oserrstr(buf, nerr); 36 | return 1; 37 | } 38 | -------------------------------------------------------------------------------- /src/lib9/exits.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | exits(char *s) 5 | { 6 | if(s == 0 || *s == 0) 7 | exit(0); 8 | exit(1); 9 | } 10 | 11 | void 12 | _exits(char *s) 13 | { 14 | if(s == 0 || *s == 0) 15 | _exit(0); 16 | _exit(1); 17 | } 18 | -------------------------------------------------------------------------------- /src/lib9/fmtfd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | /* 18 | * public routine for final flush of a formatting buffer 19 | * to a file descriptor; returns total char count. 20 | */ 21 | int 22 | fmtfdflush(Fmt *f) 23 | { 24 | if(_fmtFdFlush(f) <= 0) 25 | return -1; 26 | return f->nfmt; 27 | } 28 | 29 | /* 30 | * initialize an output buffer for buffered printing 31 | */ 32 | int 33 | fmtfdinit(Fmt *f, int fd, char *buf, int size) 34 | { 35 | f->runes = 0; 36 | f->start = buf; 37 | f->to = buf; 38 | f->stop = buf + size; 39 | f->flush = _fmtFdFlush; 40 | f->farg = (void*)fd; 41 | f->nfmt = 0; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/lib9/fmtlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | void 17 | _fmtlock(void) 18 | { 19 | } 20 | 21 | void 22 | _fmtunlock(void) 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/lib9/fmtprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | 18 | /* 19 | * format a string into the output buffer 20 | * designed for formats which themselves call fmt, 21 | * but ignore any width flags 22 | */ 23 | int 24 | fmtprint(Fmt *f, char *fmt, ...) 25 | { 26 | va_list va; 27 | int n; 28 | 29 | f->flags = 0; 30 | f->width = 0; 31 | f->prec = 0; 32 | va = f->args; 33 | va_start(f->args, fmt); 34 | n = dofmt(f, fmt); 35 | va_end(f->args); 36 | f->flags = 0; 37 | f->width = 0; 38 | f->prec = 0; 39 | f->args = va; 40 | if(n >= 0) 41 | return 0; 42 | return n; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/lib9/fmtrune.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | int 18 | fmtrune(Fmt *f, int r) 19 | { 20 | Rune *rt; 21 | char *t; 22 | int n; 23 | 24 | if(f->runes){ 25 | rt = f->to; 26 | FMTRCHAR(f, rt, f->stop, r); 27 | f->to = rt; 28 | n = 1; 29 | }else{ 30 | t = f->to; 31 | FMTRUNE(f, t, f->stop, r); 32 | n = t - (char*)f->to; 33 | f->to = t; 34 | } 35 | f->nfmt += n; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/lib9/fmtstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | fmtstrflush(Fmt *f) 18 | { 19 | if(f->start == nil) 20 | return nil; 21 | *(char*)f->to = '\0'; 22 | return f->start; 23 | } 24 | -------------------------------------------------------------------------------- /src/lib9/fmtvprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | 18 | /* 19 | * format a string into the output buffer 20 | * designed for formats which themselves call fmt, 21 | * but ignore any width flags 22 | */ 23 | int 24 | fmtvprint(Fmt *f, char *fmt, va_list args) 25 | { 26 | va_list va; 27 | int n; 28 | 29 | f->flags = 0; 30 | f->width = 0; 31 | f->prec = 0; 32 | va = f->args; 33 | f->args = args; 34 | n = dofmt(f, fmt); 35 | f->flags = 0; 36 | f->width = 0; 37 | f->prec = 0; 38 | f->args = va; 39 | if(n >= 0) 40 | return 0; 41 | return n; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/lib9/fprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | fprint(int fd, char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vfprint(fd, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-FreeBSD-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-FreeBSD-386.S" 2 | 3 | .type getcallerpc,@function 4 | .global getcallerpc 5 | getcallerpc: 6 | movl 4(%ebp), %eax 7 | ret 8 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Hp-s800.s: -------------------------------------------------------------------------------- 1 | .LEVEL 1.1 2 | 3 | .SPACE $TEXT$,SORT=8 4 | .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=0x2c,CODE_ONLY,SORT=24 5 | getcallerpc 6 | .PROC 7 | .CALLINFO FRAME=0,ARGS_SAVED 8 | .ENTRY 9 | LDI 0,%r28 10 | .EXIT 11 | BV,N %r0(%r2) 12 | .PROCEND 13 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Irix-mips.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | LEAF(getcallerpc) 5 | .set noreorder 6 | lw v0, 28(sp) 7 | j ra 8 | .set reorder 9 | END(getcallerpc) 10 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Linux-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-Linux-386.S" 2 | .type getcallerpc,@function 3 | .global getcallerpc 4 | getcallerpc: 5 | movl 4(%ebp), %eax 6 | ret 7 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Linux-arm.S: -------------------------------------------------------------------------------- 1 | /* getcallerpc for arm Linux is placed in lib9.h as inline function*/ 2 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-MacOSX-386.s: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-MacOSX-386.s" 2 | 3 | .text 4 | 5 | .globl _getcallerpc 6 | _getcallerpc: 7 | movl 4(%ebp), %eax 8 | ret 9 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-MacOSX-power.s: -------------------------------------------------------------------------------- 1 | /* 2 | File: getcallerpc-Darwin-power.s 3 | 4 | getcallerpc() is passed a pointer 5 | 6 | Plan 9 asm: 7 | 8 | TEXT getcallerpc(SB), $-4 9 | MOVW 0(R1), R3 10 | RETURN 11 | 12 | */ 13 | 14 | #import 15 | 16 | .text 17 | LABEL(_getcallerpc) 18 | mflr r3 19 | blr 20 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Solaris-386.s: -------------------------------------------------------------------------------- 1 | .align 4 2 | .globl getcallerpc 3 | getcallerpc: 4 | movl 4(%ebp),%eax 5 | ret 6 | .align 4 7 | .type getcallerpc,@function 8 | .size getcallerpc,.-getcallerpc 9 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Solaris-sparc.s: -------------------------------------------------------------------------------- 1 | .section ".text", #alloc, #execinstr 2 | .align 8 3 | .skip 16 4 | .global getcallerpc 5 | .type getcallerpc, 2 6 | getcallerpc: ! ignore argument 7 | retl 8 | add %i7,0,%o0 9 | 10 | .size getcallerpc,(.-getcallerpc) 11 | 12 | -------------------------------------------------------------------------------- /src/lib9/getcallerpc-Unixware-386.s: -------------------------------------------------------------------------------- 1 | .align 4 2 | .globl getcallerpc 3 | getcallerpc: 4 | movl 4(%ebp),%eax 5 | ret 6 | .align 4 7 | .type getcallerpc,@function 8 | .size getcallerpc,.-getcallerpc 9 | -------------------------------------------------------------------------------- /src/lib9/getfields.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | int 3 | getfields(char *str, char **args, int max, int mflag, char *set) 4 | { 5 | Rune r; 6 | int nr, intok, narg; 7 | 8 | if(max <= 0) 9 | return 0; 10 | 11 | narg = 0; 12 | args[narg] = str; 13 | if(!mflag) 14 | narg++; 15 | intok = 0; 16 | for(;; str += nr) { 17 | nr = chartorune(&r, str); 18 | if(r == 0) 19 | break; 20 | if(utfrune(set, r)) { 21 | if(narg >= max) 22 | break; 23 | *str = 0; 24 | intok = 0; 25 | args[narg] = str + nr; 26 | if(!mflag) 27 | narg++; 28 | } else { 29 | if(!intok && mflag) 30 | narg++; 31 | intok = 1; 32 | } 33 | } 34 | return narg; 35 | } 36 | -------------------------------------------------------------------------------- /src/lib9/getuser-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | getuser(void) 5 | { 6 | static char *user = 0; 7 | user = "unknown"; 8 | return user; 9 | } 10 | -------------------------------------------------------------------------------- /src/lib9/getuser-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | char* 5 | getuser(void) 6 | { 7 | struct passwd *p; 8 | 9 | static char *user = 0; 10 | 11 | if (!user) { 12 | p = getpwuid(getuid()); 13 | if (p && p->pw_name) { 14 | user = malloc(strlen(p->pw_name)+1); 15 | if (user) 16 | strcpy(user, p->pw_name); 17 | } 18 | } 19 | if(!user) 20 | user = "unknown"; 21 | return user; 22 | } 23 | -------------------------------------------------------------------------------- /src/lib9/getwd-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | 5 | char* 6 | getwd(char *buf, int size) 7 | { 8 | int n; 9 | char *p; 10 | 11 | buf[0] = 0; 12 | 13 | n = GetCurrentDirectory(size, buf); 14 | if(n == 0) { 15 | /*winerror();*/ 16 | return 0; 17 | } 18 | 19 | for(p=buf; *p; p++) 20 | if(*p == '\\') 21 | *p = '/'; 22 | 23 | return buf; 24 | } 25 | -------------------------------------------------------------------------------- /src/lib9/getwd-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #undef getwd 3 | #include 4 | 5 | char * 6 | infgetwd(char *buf, int size) 7 | { 8 | return getcwd(buf, size); 9 | } 10 | -------------------------------------------------------------------------------- /src/lib9/lock-Hp-s800.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; /* 3 | ; * To get lock routine, compile this into a .s, then SUBSTITUTE 4 | ; * a LOAD AND CLEAR WORD instruction for the load and store of 5 | ; * l->key. 6 | ; * 7 | ; */ 8 | ; typedef struct Lock { 9 | ; int key; 10 | ; } Lock; 11 | ; 12 | ; int 13 | ; mutexlock(Lock *l) 14 | ; { 15 | ; int key; 16 | ; 17 | ; key = l->key; 18 | ; l->key = 0; 19 | ; return key != 0; 20 | ; } 21 | 22 | .LEVEL 1.1 23 | 24 | .SPACE $TEXT$,SORT=8 25 | .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=0x2c,CODE_ONLY,SORT=24 26 | mutexlock 27 | .PROC 28 | .CALLINFO FRAME=0,ARGS_SAVED 29 | .ENTRY 30 | ; SUBSTITUTED LDW 0(%r26),%r31 31 | ; SUBSTITUTED STWS %r0,0(%r26) 32 | LDCWS 0(%r26),%r31 ; SUBSTITUTED 33 | COMICLR,= 0,%r31,%r28 34 | LDI 1,%r28 35 | .EXIT 36 | BV,N %r0(%r2) 37 | .PROCEND 38 | .end 39 | -------------------------------------------------------------------------------- /src/lib9/lock-Irix-mips.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | * lock from r4000 book 6 | */ 7 | LEAF(canlock) 8 | .set noreorder 9 | 1: 10 | ll t0,0(a0) /* a0 is argument */ 11 | or t1, t0, 1 12 | sc t1,0(a0) 13 | beq t1,zero,1b 14 | nop 15 | j $31 /* lock held */ 16 | xor v0, t0, 1 17 | 18 | .set reorder 19 | END(canlock) 20 | -------------------------------------------------------------------------------- /src/lib9/lock-MacOSX-power.s: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | LEAF(__tas) 4 | sync 5 | mr r4,r3 6 | addi r5,0,0x1 7 | 1: 8 | lwarx r3,0,r4 9 | cmpwi r3,0x0 10 | bne- 2f 11 | stwcx. r5,0,r4 12 | bne- 1b /* Lost reservation, try again */ 13 | 2: 14 | sync 15 | blr 16 | END(__tas) 17 | -------------------------------------------------------------------------------- /src/lib9/lock-Nt-386.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | ulong 4 | _tas(ulong *la) 5 | { 6 | ulong v; 7 | 8 | _asm { 9 | mov eax, la 10 | mov ebx, 1 11 | xchg ebx, [eax] 12 | mov v, ebx 13 | } 14 | return v; 15 | } 16 | -------------------------------------------------------------------------------- /src/lib9/lock-Solaris-386.s: -------------------------------------------------------------------------------- 1 | .section .bss 2 | .align 4 3 | .L4_.bss: 4 | .align 4 5 | Solaris_Asm_IntP: / Offset 0 6 | .type Solaris_Asm_IntP,@object 7 | .size Solaris_Asm_IntP,4 8 | .set .,.+4 9 | Solaris_Asm_VoidP: / Offset 4 10 | .type Solaris_Asm_VoidP,@object 11 | .size Solaris_Asm_VoidP,4 12 | .set .,.+4 13 | .section .data 14 | .align 4 15 | .L2_.data: 16 | .align 4 17 | .L01: .string "canlock corrupted 0x%lux\n\000" 18 | .set .,.+0x2 19 | .section .text 20 | .align 4 21 | .L1_.text: 22 | 23 | .align 4 24 | .align 4 25 | .globl canlock 26 | canlock: 27 | pushl %ebp 28 | movl %esp,%ebp 29 | pushl %esi 30 | movl 8(%ebp),%eax 31 | movl %eax,Solaris_Asm_IntP 32 | movl $1, %ecx 33 | xchg (%eax), %ecx 34 | andl %ecx,%ecx 35 | jne .L1 36 | movl $1,%esi 37 | jmp .L2 38 | .align 4 39 | .L3: 40 | subl %esi,%esi 41 | jmp .L2 42 | .align 4 43 | .L1: 44 | cmpl $1,%ecx 45 | je .L3 46 | pushl %ecx 47 | pushl $.L01 48 | call print 49 | addl $8,%esp 50 | .L2: 51 | movl %esi,%eax 52 | popl %esi 53 | leave 54 | ret 55 | .type canlock,@function 56 | .size canlock,.-canlock 57 | -------------------------------------------------------------------------------- /src/lib9/lock-Solaris-sparc.s: -------------------------------------------------------------------------------- 1 | 2 | .section ".text", #alloc, #execinstr 3 | .align 8 4 | .skip 16 5 | .global canlock 6 | .type canlock,2 7 | 8 | canlock: 9 | or %g0,1,%o1 10 | swap [%o0],%o1 ! o0 points to lock; key is first word 11 | cmp %o1,1 12 | bne .gotit 13 | nop 14 | retl ! key was 1 15 | or %g0,0,%o0 16 | .gotit: 17 | retl ! key was not 1 18 | or %g0,1,%o0 19 | 20 | .size canlock,(.-canlock) 21 | -------------------------------------------------------------------------------- /src/lib9/lock-Unixware-386.s: -------------------------------------------------------------------------------- 1 | .section .bss 2 | .align 4 3 | .L4_.bss: 4 | .align 4 5 | Unixware_Asm_IntP: / Offset 0 6 | .type Unixware_Asm_IntP,@object 7 | .size Unixware_Asm_IntP,4 8 | .set .,.+4 9 | Unixware_Asm_VoidP: / Offset 4 10 | .type Unixware_Asm_VoidP,@object 11 | .size Unixware_Asm_VoidP,4 12 | .set .,.+4 13 | .section .data 14 | .align 4 15 | .L2_.data: 16 | .align 4 17 | .L01: .string "canlock corrupted 0x%lux\n\000" 18 | .set .,.+0x2 19 | .section .text 20 | .align 4 21 | .L1_.text: 22 | 23 | .align 4 24 | .align 4 25 | .globl canlock 26 | canlock: 27 | pushl %ebp 28 | movl %esp,%ebp 29 | pushl %esi 30 | movl 8(%ebp),%eax 31 | movl %eax,Unixware_Asm_IntP 32 | movl $1, %ecx 33 | xchg (%eax), %ecx 34 | andl %ecx,%ecx 35 | jne .L1 36 | movl $1,%esi 37 | jmp .L2 38 | .align 4 39 | .L3: 40 | subl %esi,%esi 41 | jmp .L2 42 | .align 4 43 | .L1: 44 | cmpl $1,%ecx 45 | je .L3 46 | pushl %ecx 47 | pushl $.L01 48 | call print 49 | addl $8,%esp 50 | .L2: 51 | movl %esi,%eax 52 | popl %esi 53 | leave 54 | ret 55 | .type canlock,@function 56 | .size canlock,.-canlock 57 | -------------------------------------------------------------------------------- /src/lib9/mkfile-Nt: -------------------------------------------------------------------------------- 1 | TARGFILES=\ 2 | $IMPORTFILES\ 3 | dirstat-Nt.$O\ 4 | errstr-Nt.$O\ 5 | getuser-Nt.$O\ 6 | getwd-Nt.$O\ 7 | setbinmode-Nt.$O\ 8 | lock-Nt-386.$O\ 9 | -------------------------------------------------------------------------------- /src/lib9/mkfile-Plan9: -------------------------------------------------------------------------------- 1 | TARGFILES=errstr-Plan9.$O\ 2 | 3 | -------------------------------------------------------------------------------- /src/lib9/mkfile-Posix: -------------------------------------------------------------------------------- 1 | TARGFILES=\ 2 | $IMPORTFILES\ 3 | dirstat-posix.$O\ 4 | errstr-posix.$O\ 5 | getuser-posix.$O\ 6 | getcallerpc-$SYSTARG-$OBJTYPE.$O\ 7 | getwd-posix.$O\ 8 | sbrk-posix.$O\ 9 | -------------------------------------------------------------------------------- /src/lib9/nulldir.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | nulldir(Dir *d) 5 | { 6 | memset(d, ~0, sizeof(Dir)); 7 | d->name = d->uid = d->gid = d->muid = ""; 8 | } 9 | -------------------------------------------------------------------------------- /src/lib9/pow10.c: -------------------------------------------------------------------------------- 1 | #ifdef LINUX_386 2 | #define _MATH_H 3 | #endif 4 | 5 | #include "lib9.h" 6 | 7 | /* 8 | * this table might overflow 127-bit exponent representations. 9 | * in that case, truncate it after 1.0e38. 10 | * it is important to get all one can from this 11 | * routine since it is used in atof to scale numbers. 12 | * the presumption is that C converts fp numbers better 13 | * than multipication of lower powers of 10. 14 | */ 15 | 16 | static 17 | double tab[] = 18 | { 19 | 1.0e0, 1.0e1, 1.0e2, 1.0e3, 1.0e4, 1.0e5, 1.0e6, 1.0e7, 1.0e8, 1.0e9, 20 | 1.0e10,1.0e11,1.0e12,1.0e13,1.0e14,1.0e15,1.0e16,1.0e17,1.0e18,1.0e19, 21 | 1.0e20,1.0e21,1.0e22,1.0e23,1.0e24,1.0e25,1.0e26,1.0e27,1.0e28,1.0e29, 22 | 1.0e30,1.0e31,1.0e32,1.0e33,1.0e34,1.0e35,1.0e36,1.0e37,1.0e38,1.0e39, 23 | 1.0e40,1.0e41,1.0e42,1.0e43,1.0e44,1.0e45,1.0e46,1.0e47,1.0e48,1.0e49, 24 | 1.0e50,1.0e51,1.0e52,1.0e53,1.0e54,1.0e55,1.0e56,1.0e57,1.0e58,1.0e59, 25 | 1.0e60,1.0e61,1.0e62,1.0e63,1.0e64,1.0e65,1.0e66,1.0e67,1.0e68,1.0e69, 26 | }; 27 | 28 | double 29 | pow10(int n) 30 | { 31 | int m; 32 | 33 | if(n < 0) { 34 | n = -n; 35 | if(n < sizeof(tab)/sizeof(tab[0])) 36 | return 1/tab[n]; 37 | m = n/2; 38 | return pow10(-m) * pow10(m-n); 39 | } 40 | if(n < sizeof(tab)/sizeof(tab[0])) 41 | return tab[n]; 42 | m = n/2; 43 | return pow10(m) * pow10(n-m); 44 | } 45 | -------------------------------------------------------------------------------- /src/lib9/print.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | print(char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vfprint(1, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | -------------------------------------------------------------------------------- /src/lib9/readn.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | long 4 | readn(int f, void *av, long n) 5 | { 6 | char *a; 7 | long m, t; 8 | 9 | a = av; 10 | t = 0; 11 | while(t < n){ 12 | m = read(f, a+t, n-t); 13 | if(m <= 0){ 14 | if(t == 0) 15 | return m; 16 | break; 17 | } 18 | t += m; 19 | } 20 | return t; 21 | } 22 | -------------------------------------------------------------------------------- /src/lib9/rerrstr.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | rerrstr(char *buf, uint nbuf) 5 | { 6 | char tmp[ERRMAX]; 7 | 8 | tmp[0] = 0; 9 | errstr(tmp, sizeof tmp); 10 | utfecpy(buf, buf+nbuf, tmp); 11 | errstr(tmp, sizeof tmp); 12 | } 13 | -------------------------------------------------------------------------------- /src/lib9/runeseprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runeseprint(Rune *buf, Rune *e, char *fmt, ...) 5 | { 6 | Rune *p; 7 | va_list args; 8 | 9 | va_start(args, fmt); 10 | p = runevseprint(buf, e, fmt, args); 11 | va_end(args); 12 | return p; 13 | } 14 | -------------------------------------------------------------------------------- /src/lib9/runesmprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runesmprint(char *fmt, ...) 5 | { 6 | va_list args; 7 | Rune *p; 8 | 9 | va_start(args, fmt); 10 | p = runevsmprint(fmt, args); 11 | va_end(args); 12 | return p; 13 | } 14 | -------------------------------------------------------------------------------- /src/lib9/runesnprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | runesnprint(Rune *buf, int len, char *fmt, ...) 5 | { 6 | int n; 7 | va_list args; 8 | 9 | va_start(args, fmt); 10 | n = runevsnprint(buf, len, fmt, args); 11 | va_end(args); 12 | return n; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/lib9/runestrlen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | 4 | long 5 | runestrlen(Rune *s) 6 | { 7 | int i; 8 | 9 | i = 0; 10 | while(*s++) 11 | i++; 12 | return i; 13 | } 14 | -------------------------------------------------------------------------------- /src/lib9/runevseprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runevseprint(Rune *buf, Rune *e, char *fmt, va_list args) 5 | { 6 | Fmt f; 7 | 8 | if(e <= buf) 9 | return nil; 10 | f.runes = 1; 11 | f.start = buf; 12 | f.to = buf; 13 | f.stop = e - 1; 14 | f.flush = nil; 15 | f.farg = nil; 16 | f.nfmt = 0; 17 | f.args = args; 18 | dofmt(&f, fmt); 19 | *(Rune*)f.to = '\0'; 20 | return f.to; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/lib9/sbrk-posix.c: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE_CC__ /* look for a better way */ 2 | #include "lib9.h" 3 | #undef _POSIX_C_SOURCE 4 | #undef getwd 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | 30 | __typeof__(sbrk(0)) 31 | sbrk(int size) 32 | { 33 | void *brk; 34 | kern_return_t err; 35 | 36 | err = vm_allocate( (vm_map_t) mach_task_self(), 37 | (vm_address_t *)&brk, 38 | size, 39 | VM_FLAGS_ANYWHERE); 40 | if (err != KERN_SUCCESS) 41 | brk = (void*)-1; 42 | 43 | return brk; 44 | } 45 | #else 46 | /* dummy function for everyone else, in case its ar complains about empty files */ 47 | void __fakesbrk(void){} 48 | #endif 49 | -------------------------------------------------------------------------------- /src/lib9/seek.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | vlong 6 | seek(int fd, vlong where, int from) 7 | { 8 | return lseek(fd, where, from); 9 | } 10 | -------------------------------------------------------------------------------- /src/lib9/seprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | seprint(char *buf, char *e, char *fmt, ...) 18 | { 19 | char *p; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | p = vseprint(buf, e, fmt, args); 24 | va_end(args); 25 | return p; 26 | } 27 | -------------------------------------------------------------------------------- /src/lib9/setbinmode-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | setbinmode(void) 5 | { 6 | _setmode(0, _O_BINARY); 7 | _setmode(1, _O_BINARY); 8 | _setmode(2, _O_BINARY); 9 | } 10 | -------------------------------------------------------------------------------- /src/lib9/smprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | smprint(char *fmt, ...) 18 | { 19 | va_list args; 20 | char *p; 21 | 22 | va_start(args, fmt); 23 | p = vsmprint(fmt, args); 24 | va_end(args); 25 | return p; 26 | } 27 | -------------------------------------------------------------------------------- /src/lib9/snprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | snprint(char *buf, int len, char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vsnprint(buf, len, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/lib9/sprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | sprint(char *buf, char *fmt, ...) 18 | { 19 | int n; 20 | uint len; 21 | va_list args; 22 | 23 | len = 1<<30; /* big number, but sprint is deprecated anyway */ 24 | /* 25 | * the stack might be near the top of memory, so 26 | * we must be sure not to overflow a 32-bit pointer. 27 | */ 28 | if(buf+len < buf) 29 | len = -(uint)buf-1; 30 | 31 | va_start(args, fmt); 32 | n = vsnprint(buf, len, fmt, args); 33 | va_end(args); 34 | return n; 35 | } 36 | -------------------------------------------------------------------------------- /src/lib9/strdup.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | strdup(const char *s) 5 | { 6 | char *os; 7 | 8 | os = malloc(strlen(s) + 1); 9 | if(os == 0) 10 | return 0; 11 | return strcpy(os, s); 12 | } 13 | -------------------------------------------------------------------------------- /src/lib9/strecpy.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | strecpy(char *to, char *e, char *from) 5 | { 6 | if(to >= e) 7 | return to; 8 | to = memccpy(to, from, '\0', e - to); 9 | if(to == nil){ 10 | to = e - 1; 11 | *to = '\0'; 12 | }else{ 13 | to--; 14 | } 15 | return to; 16 | } 17 | -------------------------------------------------------------------------------- /src/lib9/strtoll.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | vlong 4 | strtoll(const char *nptr, char **endptr, int base) 5 | { 6 | const char *p; 7 | vlong n; 8 | int c, v, neg, ndig; 9 | 10 | p = nptr; 11 | neg = 0; 12 | n = 0; 13 | ndig = 0; 14 | 15 | /* 16 | * White space 17 | */ 18 | for(;;p++){ 19 | switch(*p){ 20 | case ' ': 21 | case '\t': 22 | case '\n': 23 | case '\f': 24 | case '\r': 25 | case '\v': 26 | continue; 27 | } 28 | break; 29 | } 30 | 31 | /* 32 | * Sign 33 | */ 34 | if(*p=='-' || *p=='+') 35 | if(*p++ == '-') 36 | neg = 1; 37 | 38 | /* 39 | * Base 40 | */ 41 | if(base==0){ 42 | if(*p != '0') 43 | base = 10; 44 | else{ 45 | base = 8; 46 | if(p[1]=='x' || p[1]=='X'){ 47 | p += 2; 48 | base = 16; 49 | } 50 | } 51 | }else if(base==16 && *p=='0'){ 52 | if(p[1]=='x' || p[1]=='X') 53 | p += 2; 54 | }else if(base<0 || 36= base) 70 | break; 71 | n = n*base + v; 72 | } 73 | Return: 74 | if(ndig == 0) 75 | p = nptr; 76 | if(endptr) 77 | *endptr = (char*) p; 78 | if(neg) 79 | return -n; 80 | return n; 81 | } 82 | -------------------------------------------------------------------------------- /src/lib9/sysfatal.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | 4 | 5 | static void 6 | _sysfatalimpl(char *fmt, va_list arg) 7 | { 8 | char buf[1024]; 9 | 10 | vseprint(buf, buf+sizeof(buf), fmt, arg); 11 | if(argv0) 12 | fprint(2, "%s: %s\n", argv0, buf); 13 | else 14 | fprint(2, "%s\n", buf); 15 | exits(buf); 16 | } 17 | 18 | void (*_sysfatal)(char *fmt, va_list arg) = _sysfatalimpl; 19 | 20 | void 21 | sysfatal(char *fmt, ...) 22 | { 23 | va_list arg; 24 | 25 | va_start(arg, fmt); 26 | (*_sysfatal)(fmt, arg); 27 | va_end(arg); 28 | } 29 | -------------------------------------------------------------------------------- /src/lib9/tokenize.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | static char qsep[] = " \t\r\n"; 4 | 5 | static char* 6 | qtoken(char *s) 7 | { 8 | int quoting; 9 | char *t; 10 | 11 | quoting = 0; 12 | t = s; /* s is output string, t is input string */ 13 | while(*t!='\0' && (quoting || utfrune(qsep, *t)==nil)){ 14 | if(*t != '\''){ 15 | *s++ = *t++; 16 | continue; 17 | } 18 | /* *t is a quote */ 19 | if(!quoting){ 20 | quoting = 1; 21 | t++; 22 | continue; 23 | } 24 | /* quoting and we're on a quote */ 25 | if(t[1] != '\''){ 26 | /* end of quoted section; absorb closing quote */ 27 | t++; 28 | quoting = 0; 29 | continue; 30 | } 31 | /* doubled quote; fold one quote into two */ 32 | t++; 33 | *s++ = *t++; 34 | } 35 | if(*s != '\0'){ 36 | *s = '\0'; 37 | if(t == s) 38 | t++; 39 | } 40 | return t; 41 | } 42 | 43 | int 44 | tokenize(char *s, char **args, int maxargs) 45 | { 46 | int nargs; 47 | 48 | for(nargs=0; nargs 2 | static char t16e[] = "0123456789ABCDEF"; 3 | 4 | int 5 | dec16(uchar *out, int lim, char *in, int n) 6 | { 7 | int c, w = 0, i = 0; 8 | uchar *start = out; 9 | uchar *eout = out + lim; 10 | 11 | while(n-- > 0){ 12 | c = *in++; 13 | if('0' <= c && c <= '9') 14 | c = c - '0'; 15 | else if('a' <= c && c <= 'z') 16 | c = c - 'a' + 10; 17 | else if('A' <= c && c <= 'Z') 18 | c = c - 'A' + 10; 19 | else 20 | continue; 21 | w = (w<<4) + c; 22 | i++; 23 | if(i == 2){ 24 | if(out + 1 > eout) 25 | goto exhausted; 26 | *out++ = w; 27 | w = 0; 28 | i = 0; 29 | } 30 | } 31 | exhausted: 32 | return out - start; 33 | } 34 | 35 | int 36 | enc16(char *out, int lim, uchar *in, int n) 37 | { 38 | uint c; 39 | char *eout = out + lim; 40 | char *start = out; 41 | 42 | while(n-- > 0){ 43 | c = *in++; 44 | if(out + 2 >= eout) 45 | goto exhausted; 46 | *out++ = t16e[c>>4]; 47 | *out++ = t16e[c&0xf]; 48 | } 49 | exhausted: 50 | *out = 0; 51 | return out - start; 52 | } 53 | -------------------------------------------------------------------------------- /src/lib9/utfecpy.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfecpy(char *to, char *e, char *from) 5 | { 6 | char *end; 7 | 8 | if(to >= e) 9 | return to; 10 | end = memccpy(to, from, '\0', e - to); 11 | if(end == nil){ 12 | end = e; 13 | while(end>to && (*--end&0xC0)==0x80) 14 | ; 15 | *end = '\0'; 16 | }else{ 17 | end--; 18 | } 19 | return end; 20 | } 21 | -------------------------------------------------------------------------------- /src/lib9/utflen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | utflen(char *s) 5 | { 6 | int c; 7 | long n; 8 | Rune rune; 9 | 10 | n = 0; 11 | for(;;) { 12 | c = *(uchar*)s; 13 | if(c < Runeself) { 14 | if(c == 0) 15 | return n; 16 | s++; 17 | } else 18 | s += chartorune(&rune, s); 19 | n++; 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/lib9/utfnlen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | utfnlen(char *s, long m) 5 | { 6 | int c; 7 | long n; 8 | Rune rune; 9 | char *es; 10 | 11 | es = s + m; 12 | for(n = 0; s < es; n++) { 13 | c = *(uchar*)s; 14 | if(c < Runeself){ 15 | if(c == '\0') 16 | break; 17 | s++; 18 | continue; 19 | } 20 | if(!fullrune(s, es-s)) 21 | break; 22 | s += chartorune(&rune, s); 23 | } 24 | return n; 25 | } 26 | -------------------------------------------------------------------------------- /src/lib9/utfrrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfrrune(char *s, long c) 5 | { 6 | long c1; 7 | Rune r; 8 | char *s1; 9 | 10 | if(c < Runesync) /* not part of utf sequence */ 11 | return strrchr(s, c); 12 | 13 | s1 = 0; 14 | for(;;) { 15 | c1 = *(uchar*)s; 16 | if(c1 < Runeself) { /* one byte rune */ 17 | if(c1 == 0) 18 | return s1; 19 | if(c1 == c) 20 | s1 = s; 21 | s++; 22 | continue; 23 | } 24 | c1 = chartorune(&r, s); 25 | if(r == c) 26 | s1 = s; 27 | s += c1; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/lib9/utfrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfrune(char *s, long c) 5 | { 6 | long c1; 7 | Rune r; 8 | int n; 9 | 10 | if(c < Runesync) /* not part of utf sequence */ 11 | return strchr(s, c); 12 | 13 | for(;;) { 14 | c1 = *(uchar*)s; 15 | if(c1 < Runeself) { /* one byte rune */ 16 | if(c1 == 0) 17 | return 0; 18 | if(c1 == c) 19 | return s; 20 | s++; 21 | continue; 22 | } 23 | n = chartorune(&r, s); 24 | if(r == c) 25 | return s; 26 | s += n; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/lib9/vseprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | vseprint(char *buf, char *e, char *fmt, va_list args) 18 | { 19 | Fmt f; 20 | 21 | if(e <= buf) 22 | return nil; 23 | f.runes = 0; 24 | f.start = buf; 25 | f.to = buf; 26 | f.stop = e - 1; 27 | f.flush = nil; 28 | f.farg = nil; 29 | f.nfmt = 0; 30 | f.args = args; 31 | dofmt(&f, fmt); 32 | *(char*)f.to = '\0'; 33 | return f.to; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/lib9/vsnprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | vsnprint(char *buf, int len, char *fmt, va_list args) 18 | { 19 | Fmt f; 20 | 21 | if(len <= 0) 22 | return -1; 23 | f.runes = 0; 24 | f.start = buf; 25 | f.to = buf; 26 | f.stop = buf + len - 1; 27 | f.flush = nil; 28 | f.farg = nil; 29 | f.nfmt = 0; 30 | f.args = args; 31 | dofmt(&f, fmt); 32 | *(char*)f.to = '\0'; 33 | return (char*)f.to - buf; 34 | } 35 | -------------------------------------------------------------------------------- /src/libbio/bbuffered.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bbuffered(Biobuf *bp) 6 | { 7 | switch(bp->state) { 8 | case Bracteof: 9 | case Bractive: 10 | return -bp->icount; 11 | 12 | case Bwactive: 13 | return bp->bsize + bp->ocount; 14 | 15 | case Binactive: 16 | return 0; 17 | } 18 | fprint(2, "Bbuffered: unknown state %d\n", bp->state); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /src/libbio/bfildes.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bfildes(Biobuf *bp) 6 | { 7 | 8 | return bp->fid; 9 | } 10 | -------------------------------------------------------------------------------- /src/libbio/bflush.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bflush(Biobuf *bp) 6 | { 7 | int n, c; 8 | 9 | switch(bp->state) { 10 | case Bwactive: 11 | n = bp->bsize+bp->ocount; 12 | if(n == 0) 13 | return 0; 14 | c = write(bp->fid, bp->bbuf, n); 15 | if(n == c) { 16 | bp->offset += n; 17 | bp->ocount = -bp->bsize; 18 | return 0; 19 | } 20 | bp->state = Binactive; 21 | bp->ocount = 0; 22 | break; 23 | 24 | case Bracteof: 25 | bp->state = Bractive; 26 | 27 | case Bractive: 28 | bp->icount = 0; 29 | bp->gbuf = bp->ebuf; 30 | return 0; 31 | } 32 | return Beof; 33 | } 34 | -------------------------------------------------------------------------------- /src/libbio/bgetc.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bgetc(Biobuf *bp) 6 | { 7 | int i; 8 | 9 | loop: 10 | i = bp->icount; 11 | if(i != 0) { 12 | bp->icount = i+1; 13 | return bp->ebuf[i]; 14 | } 15 | if(bp->state != Bractive) { 16 | if(bp->state == Bracteof) 17 | bp->state = Bractive; 18 | return Beof; 19 | } 20 | /* 21 | * get next buffer, try to keep Bungetsize 22 | * characters pre-catenated from the previous 23 | * buffer to allow that many ungets. 24 | */ 25 | memmove(bp->bbuf-Bungetsize, bp->ebuf-Bungetsize, Bungetsize); 26 | i = read(bp->fid, bp->bbuf, bp->bsize); 27 | bp->gbuf = bp->bbuf; 28 | if(i <= 0) { 29 | bp->state = Bracteof; 30 | if(i < 0) 31 | bp->state = Binactive; 32 | return Beof; 33 | } 34 | if(i < bp->bsize) { 35 | memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, i+Bungetsize); 36 | bp->gbuf = bp->ebuf-i; 37 | } 38 | bp->icount = -i; 39 | bp->offset += i; 40 | goto loop; 41 | } 42 | 43 | int 44 | Bungetc(Biobuf *bp) 45 | { 46 | 47 | if(bp->state == Bracteof) 48 | bp->state = Bractive; 49 | if(bp->state != Bractive) 50 | return Beof; 51 | bp->icount--; 52 | return 1; 53 | } 54 | -------------------------------------------------------------------------------- /src/libbio/bgetd.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | struct bgetd 5 | { 6 | Biobuf* b; 7 | int eof; 8 | }; 9 | 10 | static int 11 | Bgetdf(void *vp) 12 | { 13 | int c; 14 | struct bgetd *bg = vp; 15 | 16 | c = Bgetc(bg->b); 17 | if(c == Beof) 18 | bg->eof = 1; 19 | return c; 20 | } 21 | 22 | int 23 | Bgetd(Biobuf *bp, double *dp) 24 | { 25 | double d; 26 | struct bgetd b; 27 | 28 | b.b = bp; 29 | b.eof = 0; 30 | d = charstod(Bgetdf, &b); 31 | if(b.eof) 32 | return -1; 33 | Bungetc(bp); 34 | *dp = d; 35 | return 1; 36 | } 37 | -------------------------------------------------------------------------------- /src/libbio/bgetrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bgetrune(Biobuf *bp) 6 | { 7 | int c, i; 8 | Rune rune; 9 | char str[UTFmax]; 10 | 11 | c = Bgetc(bp); 12 | if(c < Runeself) { /* one char */ 13 | bp->runesize = 1; 14 | return c; 15 | } 16 | str[0] = c; 17 | bp->runesize = 0; 18 | 19 | for(i=1;;) { 20 | c = Bgetc(bp); 21 | if(c < 0) 22 | return c; 23 | if (i >= sizeof str) 24 | return Runeerror; 25 | str[i++] = c; 26 | 27 | if(fullrune(str, i)) { 28 | /* utf is long enough to be a rune, but could be bad. */ 29 | bp->runesize = chartorune(&rune, str); 30 | if (rune == Runeerror) 31 | bp->runesize = 0; /* push back nothing */ 32 | else 33 | /* push back bytes unconsumed by chartorune */ 34 | for(; i > bp->runesize; i--) 35 | Bungetc(bp); 36 | return rune; 37 | } 38 | } 39 | } 40 | 41 | int 42 | Bungetrune(Biobuf *bp) 43 | { 44 | 45 | if(bp->state == Bracteof) 46 | bp->state = Bractive; 47 | if(bp->state != Bractive) 48 | return Beof; 49 | bp->icount -= bp->runesize; 50 | bp->runesize = 0; 51 | return 1; 52 | } 53 | -------------------------------------------------------------------------------- /src/libbio/boffset.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | vlong 5 | Boffset(Biobuf *bp) 6 | { 7 | vlong n; 8 | 9 | switch(bp->state) { 10 | default: 11 | fprint(2, "Boffset: unknown state %d\n", bp->state); 12 | n = Beof; 13 | break; 14 | 15 | case Bracteof: 16 | case Bractive: 17 | n = bp->offset + bp->icount; 18 | break; 19 | 20 | case Bwactive: 21 | n = bp->offset + (bp->bsize + bp->ocount); 22 | break; 23 | } 24 | return n; 25 | } 26 | -------------------------------------------------------------------------------- /src/libbio/bprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bprint(Biobuf *bp, char *fmt, ...) 6 | { 7 | va_list arg; 8 | int n; 9 | 10 | va_start(arg, fmt); 11 | n = Bvprint(bp, fmt, arg); 12 | va_end(arg); 13 | return n; 14 | } 15 | -------------------------------------------------------------------------------- /src/libbio/bputc.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bputc(Biobuf *bp, int c) 6 | { 7 | int i; 8 | 9 | for(;;) { 10 | i = bp->ocount; 11 | if(i) { 12 | bp->ebuf[i++] = c; 13 | bp->ocount = i; 14 | return 0; 15 | } 16 | if(Bflush(bp) == Beof) 17 | break; 18 | } 19 | return Beof; 20 | } 21 | -------------------------------------------------------------------------------- /src/libbio/bputrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bputrune(Biobuf *bp, long c) 6 | { 7 | Rune rune; 8 | char str[UTFmax]; 9 | int n; 10 | 11 | rune = c; 12 | if(rune < Runeself) { 13 | Bputc(bp, rune); 14 | return 1; 15 | } 16 | n = runetochar(str, &rune); 17 | if(n == 0) 18 | return Bbad; 19 | if(Bwrite(bp, str, n) != n) 20 | return Beof; 21 | return n; 22 | } 23 | -------------------------------------------------------------------------------- /src/libbio/bread.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bread(Biobuf *bp, void *ap, long count) 6 | { 7 | long c; 8 | uchar *p; 9 | int i, n, ic; 10 | 11 | p = ap; 12 | c = count; 13 | ic = bp->icount; 14 | 15 | while(c > 0) { 16 | n = -ic; 17 | if(n > c) 18 | n = c; 19 | if(n == 0) { 20 | if(bp->state != Bractive) 21 | break; 22 | i = read(bp->fid, bp->bbuf, bp->bsize); 23 | if(i <= 0) { 24 | bp->state = Bracteof; 25 | if(i < 0) 26 | bp->state = Binactive; 27 | break; 28 | } 29 | bp->gbuf = bp->bbuf; 30 | bp->offset += i; 31 | if(i < bp->bsize) { 32 | memmove(bp->ebuf-i, bp->bbuf, i); 33 | bp->gbuf = bp->ebuf-i; 34 | } 35 | ic = -i; 36 | continue; 37 | } 38 | memmove(p, bp->ebuf+ic, n); 39 | c -= n; 40 | ic += n; 41 | p += n; 42 | } 43 | bp->icount = ic; 44 | if(count == c && bp->state == Binactive) 45 | return -1; 46 | return count-c; 47 | } 48 | -------------------------------------------------------------------------------- /src/libbio/bseek.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | vlong 5 | Bseek(Biobuf *bp, vlong offset, int base) 6 | { 7 | vlong n, d; 8 | 9 | switch(bp->state) { 10 | default: 11 | fprint(2, "Bseek: unknown state %d\n", bp->state); 12 | return Beof; 13 | 14 | case Bracteof: 15 | bp->state = Bractive; 16 | bp->icount = 0; 17 | bp->gbuf = bp->ebuf; 18 | 19 | case Bractive: 20 | n = offset; 21 | if(base == 1) { 22 | n += Boffset(bp); 23 | base = 0; 24 | } 25 | 26 | /* 27 | * try to seek within buffer 28 | */ 29 | if(base == 0) { 30 | /* 31 | * if d is too large for an int, icount may wrap, 32 | * so we need to ensure that icount hasn't wrapped 33 | * and points within the buffer's valid data. 34 | */ 35 | d = n - Boffset(bp); 36 | bp->icount += d; 37 | if(d <= bp->bsize && bp->icount <= 0 && 38 | bp->ebuf - bp->gbuf >= -bp->icount) 39 | return n; 40 | } 41 | 42 | /* 43 | * reset the buffer 44 | */ 45 | n = seek(bp->fid, n, base); 46 | bp->icount = 0; 47 | bp->gbuf = bp->ebuf; 48 | break; 49 | 50 | case Bwactive: 51 | Bflush(bp); 52 | n = seek(bp->fid, offset, base); 53 | break; 54 | } 55 | bp->offset = n; 56 | return n; 57 | } 58 | -------------------------------------------------------------------------------- /src/libbio/bvprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | static int 5 | fmtBflush(Fmt *f) 6 | { 7 | Biobuf *bp; 8 | 9 | bp = f->farg; 10 | bp->ocount = (char*)f->to - (char*)f->stop; 11 | if(Bflush(bp) < 0) 12 | return 0; 13 | f->stop = bp->ebuf; 14 | f->to = (char*)f->stop + bp->ocount; 15 | f->start = f->to; 16 | return 1; 17 | } 18 | 19 | int 20 | Bvprint(Biobuf *bp, char *fmt, va_list arg) 21 | { 22 | int n; 23 | Fmt f; 24 | 25 | f.runes = 0; 26 | f.stop = bp->ebuf; 27 | f.start = (char*)f.stop + bp->ocount; 28 | f.to = f.start; 29 | f.flush = fmtBflush; 30 | f.farg = bp; 31 | f.nfmt = 0; 32 | #ifdef va_copy 33 | va_copy(f.args, arg); 34 | #else 35 | f.args = arg; 36 | #endif 37 | n = dofmt(&f, fmt); 38 | #ifdef va_copy 39 | va_end(f.args); 40 | #endif 41 | bp->ocount = (char*)f.to - (char*)f.stop; 42 | return n; 43 | } 44 | -------------------------------------------------------------------------------- /src/libbio/bwrite.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bwrite(Biobuf *bp, void *ap, long count) 6 | { 7 | long c; 8 | uchar *p; 9 | int i, n, oc; 10 | char errbuf[ERRMAX]; 11 | 12 | p = ap; 13 | c = count; 14 | oc = bp->ocount; 15 | 16 | while(c > 0) { 17 | n = -oc; 18 | if(n > c) 19 | n = c; 20 | if(n == 0) { 21 | if(bp->state != Bwactive) 22 | return Beof; 23 | i = write(bp->fid, bp->bbuf, bp->bsize); 24 | if(i != bp->bsize) { 25 | errstr(errbuf, sizeof errbuf); 26 | if(strstr(errbuf, "interrupt") == nil) 27 | bp->state = Binactive; 28 | errstr(errbuf, sizeof errbuf); 29 | return Beof; 30 | } 31 | bp->offset += i; 32 | oc = -bp->bsize; 33 | continue; 34 | } 35 | memmove(bp->ebuf+oc, p, n); 36 | oc += n; 37 | c -= n; 38 | p += n; 39 | } 40 | bp->ocount = oc; 41 | return count-c; 42 | } 43 | -------------------------------------------------------------------------------- /src/libbio/mkfile: -------------------------------------------------------------------------------- 1 | <../../mkconfig 2 | 3 | LIB=libbio.a 4 | OFILES=\ 5 | bbuffered.$O\ 6 | bfildes.$O\ 7 | bflush.$O\ 8 | bgetrune.$O\ 9 | bgetc.$O\ 10 | bgetd.$O\ 11 | binit.$O\ 12 | boffset.$O\ 13 | bprint.$O\ 14 | bputrune.$O\ 15 | bputc.$O\ 16 | brdline.$O\ 17 | brdstr.$O\ 18 | bread.$O\ 19 | bseek.$O\ 20 | bvprint.$O\ 21 | bwrite.$O\ 22 | 23 | HFILES= $ROOT/include/bio.h 24 | 25 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 26 | -------------------------------------------------------------------------------- /src/libmach/mkfile: -------------------------------------------------------------------------------- 1 | <../../mkconfig 2 | 3 | LIB=libmach.a 4 | OFILES=\ 5 | 4.$O\ 6 | 5.$O\ 7 | 6.$O\ 8 | 8.$O\ 9 | 9.$O\ 10 | k.$O\ 11 | q.$O\ 12 | v.$O\ 13 | 5db.$O\ 14 | 8db.$O\ 15 | kdb.$O\ 16 | qdb.$O\ 17 | vdb.$O\ 18 | 5obj.$O\ 19 | 6obj.$O\ 20 | 8obj.$O\ 21 | 9obj.$O\ 22 | kobj.$O\ 23 | qobj.$O\ 24 | vobj.$O\ 25 | obj.$O\ 26 | map.$O\ 27 | swap.$O\ 28 | sym.$O\ 29 | access.$O\ 30 | machdata.$O\ 31 | setmach.$O\ 32 | executable.$O\ 33 | vcodas.$O\ 34 | 35 | HFILES=\ 36 | $ROOT/include/mach.h\ 37 | $ROOT/include/a.out.h\ 38 | bootexec.h\ 39 | elf.h\ 40 | ureg4.h\ 41 | ureg6.h\ 42 | ureg8.h\ 43 | uregk.h\ 44 | uregv.h\ 45 | ureg5.h 46 | 47 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 48 | CFLAGS= $CFLAGS -I../cmd/ 49 | -------------------------------------------------------------------------------- /src/libmach/obj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * obj.h -- defs for dealing with object files 3 | */ 4 | 5 | typedef enum Kind /* variable defs and references in obj */ 6 | { 7 | aNone, /* we don't care about this prog */ 8 | aName, /* introduces a name */ 9 | aText, /* starts a function */ 10 | aData, /* references to a global object */ 11 | } Kind; 12 | 13 | typedef struct Prog Prog; 14 | 15 | struct Prog /* info from .$O files */ 16 | { 17 | Kind kind; /* what kind of symbol */ 18 | char type; /* type of the symbol: ie, 'T', 'a', etc. */ 19 | char sym; /* index of symbol's name */ 20 | char *id; /* name for the symbol, if it introduces one */ 21 | uint sig; /* type signature for symbol */ 22 | }; 23 | 24 | #define UNKNOWN '?' 25 | void _offset(int, vlong); 26 | -------------------------------------------------------------------------------- /src/libmach/retired/ureg2.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong r0; 4 | ulong r1; 5 | ulong r2; 6 | ulong r3; 7 | ulong r4; 8 | ulong r5; 9 | ulong r6; 10 | ulong r7; 11 | ulong a0; 12 | ulong a1; 13 | ulong a2; 14 | ulong a3; 15 | ulong a4; 16 | ulong a5; 17 | ulong a6; 18 | ulong sp; 19 | ulong usp; 20 | ulong magic; /* for db to find bottom of ureg */ 21 | ushort sr; 22 | ulong pc; 23 | ushort vo; 24 | #ifndef UREGVARSZ 25 | #define UREGVARSZ 23 /* for 68040; 15 is enough on 68020 */ 26 | #endif 27 | uchar microstate[UREGVARSZ]; /* variable-sized portion */ 28 | }; 29 | -------------------------------------------------------------------------------- /src/libmach/retired/uregt.h: -------------------------------------------------------------------------------- 1 | struct Ureg { 2 | uint r0; 3 | uint r1; 4 | uint r2; 5 | uint r3; 6 | uint r4; 7 | uint r5; 8 | uint r6; 9 | uint r7; 10 | uint r8; 11 | uint r9; 12 | uint r10; 13 | uint r11; 14 | uint r12; 15 | uint r13; 16 | uint r14; 17 | uint link; 18 | uint type; 19 | uint psr; 20 | uint pc; 21 | }; 22 | -------------------------------------------------------------------------------- /src/libmach/ureg4.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong status; 4 | long pc; 5 | union 6 | { 7 | long sp; /* r29 */ 8 | long usp; /* r29 */ 9 | } u0; 10 | ulong cause; 11 | ulong badvaddr; 12 | ulong tlbvirt; 13 | 14 | long hhi; long hi; 15 | long hlo; long lo; 16 | long hr31; long r31; 17 | long hr30; long r30; 18 | long hr28; long r28; 19 | long hr27; long r27; 20 | long hr26; long r26; 21 | long hr25; long r25; 22 | long hr24; long r24; 23 | long hr23; long r23; 24 | long hr22; long r22; 25 | long hr21; long r21; 26 | long hr20; long r20; 27 | long hr19; long r19; 28 | long hr18; long r18; 29 | long hr17; long r17; 30 | long hr16; long r16; 31 | long hr15; long r15; 32 | long hr14; long r14; 33 | long hr13; long r13; 34 | long hr12; long r12; 35 | long hr11; long r11; 36 | long hr10; long r10; 37 | long hr9; long r9; 38 | long hr8; long r8; 39 | long hr7; long r7; 40 | long hr6; long r6; 41 | long hr5; long r5; 42 | long hr4; long r4; 43 | long hr3; long r3; 44 | long hr2; long r2; 45 | long hr1; long r1; 46 | }; 47 | -------------------------------------------------------------------------------- /src/libmach/ureg5.h: -------------------------------------------------------------------------------- 1 | struct Ureg { 2 | uint r0; 3 | uint r1; 4 | uint r2; 5 | uint r3; 6 | uint r4; 7 | uint r5; 8 | uint r6; 9 | uint r7; 10 | uint r8; 11 | uint r9; 12 | uint r10; 13 | uint r11; 14 | uint r12; 15 | uint r13; 16 | uint r14; 17 | uint link; 18 | uint type; 19 | uint psr; 20 | uint pc; 21 | }; 22 | -------------------------------------------------------------------------------- /src/libmach/ureg6.h: -------------------------------------------------------------------------------- 1 | struct Ureg { 2 | u64int ax; 3 | u64int bx; 4 | u64int cx; 5 | u64int dx; 6 | u64int si; 7 | u64int di; 8 | u64int bp; 9 | u64int r8; 10 | u64int r9; 11 | u64int r10; 12 | u64int r11; 13 | u64int r12; 14 | u64int r13; 15 | u64int r14; 16 | u64int r15; 17 | 18 | u16int ds; 19 | u16int es; 20 | u16int fs; 21 | u16int gs; 22 | 23 | u64int type; 24 | u64int error; /* error code (or zero) */ 25 | u64int ip; /* pc */ 26 | u64int cs; /* old context */ 27 | u64int flags; /* old flags */ 28 | u64int sp; /* sp */ 29 | u64int ss; /* old stack segment */ 30 | }; 31 | -------------------------------------------------------------------------------- /src/libmach/ureg8.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong di; /* general registers */ 4 | ulong si; /* ... */ 5 | ulong bp; /* ... */ 6 | ulong nsp; 7 | ulong bx; /* ... */ 8 | ulong dx; /* ... */ 9 | ulong cx; /* ... */ 10 | ulong ax; /* ... */ 11 | ulong gs; /* data segments */ 12 | ulong fs; /* ... */ 13 | ulong es; /* ... */ 14 | ulong ds; /* ... */ 15 | ulong trap; /* trap type */ 16 | ulong ecode; /* error code (or zero) */ 17 | ulong pc; /* pc */ 18 | ulong cs; /* old context */ 19 | ulong flags; /* old flags */ 20 | union { 21 | ulong usp; 22 | ulong sp; 23 | } u0; 24 | ulong ss; /* old stack segment */ 25 | }; 26 | -------------------------------------------------------------------------------- /src/libmach/ureg9.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | /* 0*/ u64int cause; /* trap or interrupt vector */ 4 | /* 8*/ u64int msr; /* SRR1 */ 5 | /* 16*/ u64int pc; /* SRR0 */ 6 | /* 24*/ u64int unused; 7 | /* 32*/ u64int lr; 8 | /* 36*/ u32int pad; 9 | /* 40*/ u32int cr; 10 | /* 48*/ u64int xer; 11 | /* 56*/ u64int ctr; 12 | /* 64*/ u64int r0; 13 | /* 72*/ union{ u64int r1; u64int sp; u64int usp; }; 14 | /* 80*/ u64int r2; 15 | /* 88*/ u64int r3; 16 | /* 96*/ u64int r4; 17 | /*104*/ u64int r5; 18 | /*112*/ u64int r6; 19 | /*120*/ u64int r7; 20 | /*128*/ u64int r8; 21 | /*136*/ u64int r9; 22 | /*144*/ u64int r10; 23 | /*152*/ u64int r11; 24 | /*160*/ u64int r12; 25 | /*168*/ u64int r13; 26 | /*176*/ u64int r14; 27 | /*184*/ u64int r15; 28 | /*192*/ u64int r16; 29 | /*200*/ u64int r17; 30 | /*208*/ u64int r18; 31 | /*216*/ u64int r19; 32 | /*224*/ u64int r20; 33 | /*232*/ u64int r21; 34 | /*240*/ u64int r22; 35 | /*248*/ u64int r23; 36 | /*256*/ u64int r24; 37 | /*264*/ u64int r25; 38 | /*272*/ u64int r26; 39 | /*280*/ u64int r27; 40 | /*288*/ u64int r28; 41 | /*296*/ u64int r29; 42 | /*304*/ u64int r30; 43 | /*312*/ u64int r31; 44 | }; 45 | -------------------------------------------------------------------------------- /src/libmach/uregk.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong r0; /* unnecessary; just for symmetry */ 4 | union{ 5 | ulong sp; /* r1 */ 6 | ulong usp; /* r1 */ 7 | ulong r1; 8 | } u0; 9 | ulong r2; 10 | ulong r3; 11 | ulong r4; 12 | ulong r5; 13 | ulong r6; 14 | ulong r7; 15 | ulong r8; 16 | ulong r9; 17 | ulong r10; 18 | ulong r11; 19 | ulong r12; 20 | ulong r13; 21 | ulong r14; 22 | ulong r15; 23 | ulong r16; 24 | ulong r17; 25 | ulong r18; 26 | ulong r19; 27 | ulong r20; 28 | ulong r21; 29 | ulong r22; 30 | ulong r23; 31 | ulong r24; 32 | ulong r25; 33 | ulong r26; 34 | ulong r27; 35 | ulong r28; 36 | ulong r29; 37 | ulong r30; 38 | ulong r31; 39 | ulong y; 40 | ulong tbr; 41 | ulong psr; 42 | ulong npc; 43 | ulong pc; 44 | ulong pad; /* so structure is double word aligned */ 45 | }; 46 | -------------------------------------------------------------------------------- /src/libmach/uregq.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong cause; 4 | ulong srr1; 5 | ulong pc; /* SRR0 */ 6 | ulong pad; 7 | ulong lr; 8 | ulong cr; 9 | ulong xer; 10 | ulong ctr; 11 | ulong r0; 12 | ulong sp; 13 | ulong r2; 14 | ulong r3; 15 | ulong r4; 16 | ulong r5; 17 | ulong r6; 18 | ulong r7; 19 | ulong r8; 20 | ulong r9; 21 | ulong r10; 22 | ulong r11; 23 | ulong r12; 24 | ulong r13; 25 | ulong r14; 26 | ulong r15; 27 | ulong r16; 28 | ulong r17; 29 | ulong r18; 30 | ulong r19; 31 | ulong r20; 32 | ulong r21; 33 | ulong r22; 34 | ulong r23; 35 | ulong r24; 36 | ulong r25; 37 | ulong r26; 38 | ulong r27; 39 | ulong r28; 40 | ulong r29; 41 | ulong r30; 42 | ulong r31; 43 | }; 44 | -------------------------------------------------------------------------------- /src/libmach/uregv.h: -------------------------------------------------------------------------------- 1 | struct Ureg 2 | { 3 | ulong status; 4 | ulong pc; 5 | union{ 6 | ulong sp; /* r29 */ 7 | ulong usp; /* r29 */ 8 | } u0; 9 | ulong cause; 10 | ulong badvaddr; 11 | ulong tlbvirt; 12 | ulong hi; 13 | ulong lo; 14 | ulong r31; 15 | ulong r30; 16 | ulong r28; 17 | ulong r27; /* unused */ 18 | ulong r26; /* unused */ 19 | ulong r25; 20 | ulong r24; 21 | ulong r23; 22 | ulong r22; 23 | ulong r21; 24 | ulong r20; 25 | ulong r19; 26 | ulong r18; 27 | ulong r17; 28 | ulong r16; 29 | ulong r15; 30 | ulong r14; 31 | ulong r13; 32 | ulong r12; 33 | ulong r11; 34 | ulong r10; 35 | ulong r9; 36 | ulong r8; 37 | ulong r7; 38 | ulong r6; 39 | ulong r5; 40 | ulong r4; 41 | ulong r3; 42 | ulong r2; 43 | ulong r1; 44 | }; 45 | -------------------------------------------------------------------------------- /src/libmath/FPcontrol-Plan9.c: -------------------------------------------------------------------------------- 1 | #include "FPcontrol-Inferno.c" 2 | -------------------------------------------------------------------------------- /src/libmath/bin/unif_dtoa: -------------------------------------------------------------------------------- 1 | #!/bin/rc 2 | test -d /netlib/fp || 9fs netlib 3 | test -d /n/hati/usr/ehg || 9fs hati 4 | 5 | echo '/* derived from /netlib/fp/dtoa.c assuming IEEE, Standard C */' > dtoa.c 6 | echo '/* kudos to dmg@research.att.com, gripes to ehg@research.att.com */' >> dtoa.c 7 | echo '#include "lib9.h"' >> dtoa.c 8 | 9 | sed 's/^#if defined.IEEE_8087. . defined.IEEE_MC68k.*!= 1/#ifndef IEEE_Arith/ 10 | s/^#if defined.IEEE_8087. . defined.IEEE_MC68k.*/#ifdef IEEE_Arith/' \ 11 | /netlib/fp/dtoa.c > /n/hati/usr/ehg/xxx.c 12 | # undefine __STDC__ because we can't depend on HUGE_VAL 13 | rx hati 'unifdef -UIBM -UVAX -UKR_headers -U__cplusplus -U__STDC__ -UDEBUG \ 14 | -UBad_float_h -UJust_16 -UInaccurate_Divide -UROUND_BIASED \ 15 | -URND_PRODQUOT -DNo_leftright -UCheck_FLT_ROUNDS -D__MATH_H__ \ 16 | -DUnsigned_Shifts -DMALLOC=Malloc -DCONST=const \ 17 | -DPack_32 -DIEEE_Arith xxx.c | cb -s' > xxx.c 18 | sam -d >> dtoa.c >[2] err <> dtoa.c 37 | rm xxx.c 38 | -------------------------------------------------------------------------------- /src/libmath/bin/unif_fdlibm: -------------------------------------------------------------------------------- 1 | #!/bin/rc 2 | test -d /netlib/fdlibm || 9fs netlib 3 | test -d /n/hati/usr/ehg || 9fs hati 4 | 5 | echo '/* derived from /netlib/fdlibm */' > $1 6 | if (~ $1 fdlibm.h) echo '#include "lib9.h"' >> $1 7 | 8 | cp /netlib/fdlibm/$1 /n/hati/usr/ehg/xxx.c 9 | rx hati 'unifdef -D__STDC__ -D_IEEE_LIBM -D_SCALB_INT -U__NEWVALID xxx.c' > xxx.c 10 | > /n/hati/usr/ehg/xxx.c 11 | sam -d >> $1 >[2] err <> $1 20 | rm xxx.c 21 | -------------------------------------------------------------------------------- /src/libmath/blas.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include "mathi.h" 3 | 4 | double 5 | dot(int n, double *x, double *y) 6 | { 7 | double sum = 0; 8 | if (n <= 0) 9 | return 0; 10 | while (n--) { 11 | sum += *x++ * *y++; 12 | } 13 | return sum; 14 | } 15 | 16 | 17 | int 18 | iamax(int n, double *x) 19 | { 20 | int i, m; 21 | double xm, a; 22 | if (n <= 0) 23 | return 0; 24 | m = 0; 25 | xm = fabs(*x); 26 | for (i = 1; i < n; i++) { 27 | a = fabs(*++x); 28 | if (xm < a) { 29 | m = i; 30 | xm = a; 31 | } 32 | } 33 | return m; 34 | } 35 | 36 | 37 | double 38 | norm1(int n, double *x) 39 | { 40 | double sum = 0; 41 | if (n <= 0) 42 | return 0; 43 | while (n--) { 44 | sum += fabs(*x); 45 | x++; 46 | } 47 | return sum; 48 | } 49 | 50 | 51 | double 52 | norm2(int n, double *x) 53 | { 54 | double sum = 0; 55 | if (n <= 0) 56 | return 0; 57 | while (n--) { 58 | sum += *x * *x; 59 | x++; 60 | } 61 | return sum; 62 | } 63 | -------------------------------------------------------------------------------- /src/libmath/fdim.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include "mathi.h" 3 | 4 | double 5 | fdim(double x, double y) 6 | { 7 | if(x>y) 8 | return x-y; 9 | else 10 | return 0; 11 | } 12 | 13 | double 14 | fmax(double x, double y) 15 | { 16 | if(x>y) 17 | return x; 18 | else 19 | return y; 20 | } 21 | 22 | double 23 | fmin(double x, double y) 24 | { 25 | if(x>31; 27 | } 28 | -------------------------------------------------------------------------------- /src/libmath/fdlibm/s_ilogb.c: -------------------------------------------------------------------------------- 1 | /* derived from /netlib/fdlibm */ 2 | 3 | /* @(#)s_ilogb.c 1.3 95/01/18 */ 4 | /* 5 | * ==================================================== 6 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 9 | * Permission to use, copy, modify, and distribute this 10 | * software is freely granted, provided that this notice 11 | * is preserved. 12 | * ==================================================== 13 | */ 14 | 15 | /* ilogb(double x) 16 | * return the binary exponent of non-zero x 17 | * ilogb(0) = 0x80000001 18 | * ilogb(inf/NaN) = 0x7fffffff (no signal is raised) 19 | */ 20 | 21 | #include "fdlibm.h" 22 | 23 | int ilogb(double x) 24 | { 25 | int hx,lx,ix; 26 | 27 | hx = (__HI(x))&0x7fffffff; /* high word of x */ 28 | if(hx<0x00100000) { 29 | lx = __LO(x); 30 | if((hx|lx)==0) 31 | return 0x80000001; /* ilogb(0) = 0x80000001 */ 32 | else /* subnormal x */ 33 | if(hx==0) { 34 | for (ix = -1043; lx>0; lx<<=1) ix -=1; 35 | } else { 36 | for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1; 37 | } 38 | return ix; 39 | } 40 | else if (hx<0x7ff00000) return (hx>>20)-1023; 41 | else return 0x7fffffff; 42 | } 43 | -------------------------------------------------------------------------------- /src/libmath/fdlibm/s_isnan.c: -------------------------------------------------------------------------------- 1 | /* derived from /netlib/fdlibm */ 2 | 3 | /* @(#)s_isnan.c 1.3 95/01/18 */ 4 | /* 5 | * ==================================================== 6 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 9 | * Permission to use, copy, modify, and distribute this 10 | * software is freely granted, provided that this notice 11 | * is preserved. 12 | * ==================================================== 13 | */ 14 | 15 | /* 16 | * isnan(x) returns 1 is x is nan, else 0; 17 | * no branching! 18 | */ 19 | 20 | #include "fdlibm.h" 21 | 22 | int isnan(double x) 23 | { 24 | int hx,lx; 25 | hx = (__HI(x)&0x7fffffff); 26 | lx = __LO(x); 27 | hx |= (unsigned)(lx|(-lx))>>31; 28 | hx = 0x7ff00000 - hx; 29 | return ((unsigned)(hx))>>31; 30 | } 31 | -------------------------------------------------------------------------------- /src/libmath/mkfile: -------------------------------------------------------------------------------- 1 | <../../mkconfig 2 | 3 | TARGTYPE=${SYSTARG:os%=Inferno%} # maps 'os' into 'Inferno' 4 | 5 | LIB=libmath.a 6 | OFILES=\ 7 | blas.$O\ 8 | dtoa.$O\ 9 | fdim.$O\ 10 | FPcontrol-$TARGTYPE.$O\ 11 | gemm.$O\ 12 | g_fmt.$O\ 13 | gfltconv.$O\ 14 | pow10.$O\ 15 | e_acos.$O\ 16 | e_acosh.$O\ 17 | e_asin.$O\ 18 | e_atan2.$O\ 19 | e_atanh.$O\ 20 | e_cosh.$O\ 21 | e_exp.$O\ 22 | e_fmod.$O\ 23 | e_hypot.$O\ 24 | e_j0.$O\ 25 | e_j1.$O\ 26 | e_jn.$O\ 27 | e_lgamma_r.$O\ 28 | e_log.$O\ 29 | e_log10.$O\ 30 | e_pow.$O\ 31 | e_rem_pio2.$O\ 32 | e_remainder.$O\ 33 | e_sinh.$O\ 34 | e_sqrt.$O\ 35 | k_cos.$O\ 36 | k_rem_pio2.$O\ 37 | k_sin.$O\ 38 | k_tan.$O\ 39 | s_asinh.$O\ 40 | s_atan.$O\ 41 | s_cbrt.$O\ 42 | s_ceil.$O\ 43 | s_copysign.$O\ 44 | s_cos.$O\ 45 | s_erf.$O\ 46 | s_expm1.$O\ 47 | s_fabs.$O\ 48 | s_finite.$O\ 49 | s_floor.$O\ 50 | s_ilogb.$O\ 51 | s_isnan.$O\ 52 | s_log1p.$O\ 53 | s_nextafter.$O\ 54 | s_rint.$O\ 55 | s_scalbn.$O\ 56 | s_sin.$O\ 57 | s_tan.$O\ 58 | s_tanh.$O\ 59 | 60 | HFILES=\ 61 | $ROOT/include/mathi.h\ 62 | fdlibm/fdlibm.h\ 63 | 64 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 65 | 66 | %.$O: fdlibm/%.c 67 | $CC $CFLAGS -o $target -Ifdlibm fdlibm/$stem.c 68 | -------------------------------------------------------------------------------- /src/libmath/pow10.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include "mathi.h" 3 | 4 | double 5 | ipow10(int n) 6 | { 7 | return pow(10.,n); 8 | } 9 | -------------------------------------------------------------------------------- /src/libregexp/mkfile: -------------------------------------------------------------------------------- 1 | <../../mkconfig 2 | 3 | #XXX 4 | <$ROOT/mkfiles/mkhost-$SYSHOST # variables appropriate for host system 5 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE # variables used to build target object type 6 | 7 | LIB=libregexp.a 8 | 9 | OFILES=\ 10 | regcomp.$O\ 11 | regerror.$O\ 12 | regexec.$O\ 13 | regsub.$O\ 14 | regaux.$O\ 15 | rregexec.$O\ 16 | rregsub.$O\ 17 | 18 | HFILES= $ROOT/include/regexp.h\ 19 | regcomp.h\ 20 | 21 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 22 | -------------------------------------------------------------------------------- /src/libregexp/regerror.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "regexp.h" 3 | 4 | void 5 | regerror(char *s) 6 | { 7 | char buf[132]; 8 | 9 | strcpy(buf, "regerror: "); 10 | strcat(buf, s); 11 | strcat(buf, "\n"); 12 | write(2, buf, strlen(buf)); 13 | exits("regerr"); 14 | } 15 | -------------------------------------------------------------------------------- /src/libregexp/regsub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "regexp.h" 3 | 4 | /* substitute into one string using the matches from the last regexec() */ 5 | extern void 6 | regsub(char *sp, /* source string */ 7 | char *dp, /* destination string */ 8 | Resub *mp, /* subexpression elements */ 9 | int ms) /* number of elements pointed to by mp */ 10 | { 11 | char *ssp; 12 | int i; 13 | 14 | while(*sp != '\0'){ 15 | if(*sp == '\\'){ 16 | switch(*++sp){ 17 | case '0': 18 | case '1': 19 | case '2': 20 | case '3': 21 | case '4': 22 | case '5': 23 | case '6': 24 | case '7': 25 | case '8': 26 | case '9': 27 | i = *sp-'0'; 28 | if(mp[i].s.sp != 0 && mp!=0 && ms>i) 29 | for(ssp = mp[i].s.sp; 30 | ssp < mp[i].e.ep; 31 | ssp++) 32 | *dp++ = *ssp; 33 | break; 34 | case '\\': 35 | *dp++ = '\\'; 36 | break; 37 | case '\0': 38 | sp--; 39 | break; 40 | default: 41 | *dp++ = *sp; 42 | break; 43 | } 44 | }else if(*sp == '&'){ 45 | if(mp[0].s.sp != 0 && mp!=0 && ms>0) 46 | if(mp[0].s.sp != 0) 47 | for(ssp = mp[0].s.sp; 48 | ssp < mp[0].e.ep; ssp++) 49 | *dp++ = *ssp; 50 | }else 51 | *dp++ = *sp; 52 | sp++; 53 | } 54 | *dp = '\0'; 55 | } 56 | -------------------------------------------------------------------------------- /src/libregexp/rregsub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "regexp.h" 3 | 4 | /* substitute into one string using the matches from the last regexec() */ 5 | extern void 6 | rregsub(Rune *sp, /* source string */ 7 | Rune *dp, /* destination string */ 8 | Resub *mp, /* subexpression elements */ 9 | int ms) /* number of elements pointed to by mp */ 10 | { 11 | Rune *ssp; 12 | int i; 13 | 14 | while(*sp != '\0'){ 15 | if(*sp == '\\'){ 16 | switch(*++sp){ 17 | case '0': 18 | case '1': 19 | case '2': 20 | case '3': 21 | case '4': 22 | case '5': 23 | case '6': 24 | case '7': 25 | case '8': 26 | case '9': 27 | i = *sp-'0'; 28 | if(mp[i].s.rsp != 0 && mp!=0 && ms>i) 29 | for(ssp = mp[i].s.rsp; 30 | ssp < mp[i].e.rep; 31 | ssp++) 32 | *dp++ = *ssp; 33 | break; 34 | case '\\': 35 | *dp++ = '\\'; 36 | break; 37 | case '\0': 38 | sp--; 39 | break; 40 | default: 41 | *dp++ = *sp; 42 | break; 43 | } 44 | }else if(*sp == '&'){ 45 | if(mp[0].s.rsp != 0 && mp!=0 && ms>0) 46 | if(mp[0].s.rsp != 0) 47 | for(ssp = mp[0].s.rsp; 48 | ssp < mp[0].e.rep; ssp++) 49 | *dp++ = *ssp; 50 | }else 51 | *dp++ = *sp; 52 | sp++; 53 | } 54 | *dp = '\0'; 55 | } 56 | --------------------------------------------------------------------------------