From e70feee4a3ddacae2355ff650fe68b67d1f45d64 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 19 Apr 2017 23:33:14 +0200 Subject: [PATCH] libc: introduce "jehanne_" namespace With this commit all functions declared in libc.h have been renamed with the "jehanne_" prefix. This is done for several reason: - it removes conflicts during symbol resolution when linking standard C libraries like newlib or musl - it allows programs depending on a standard C library to directly link to a library depending on our non standard libc (eg libsec). To ease transiction two files are provided: - sys/include/lib9.h that can be included instead of to use the old names (via a simple set of macros) - sys/src/lib/c/lib9.c that can be compiled with a program where the macro provided by lib9.h are too dumb (see for example rc or grep). In the kernel port/lib.h has been modified accordingly and some of the functions it directly provides has been renamed too (eg malloc in qmalloc.c and print in devcons.c). --- qa/gnu/gcc/rune.c | 2 +- qa/kern/alarm.c | 2 +- qa/kern/args.c | 2 +- qa/kern/awake.c | 2 +- qa/kern/brk.c | 2 +- qa/kern/execl.c | 2 +- qa/kern/float.c | 2 +- qa/kern/fork.c | 2 +- qa/kern/frexp.c | 2 +- qa/kern/getmainpid.c | 2 +- qa/kern/getpid.c | 2 +- qa/kern/getppid.c | 2 +- qa/kern/iphash.c | 2 +- qa/kern/malloc1GiB.c | 2 +- qa/kern/memoryisolation.c | 2 +- qa/kern/memoryshare.c | 2 +- qa/kern/mixedfloat.c | 2 +- qa/kern/noexecmem.c | 2 +- qa/kern/notify.c | 2 +- qa/kern/nsec.c | 2 +- qa/kern/pipering.c | 2 +- qa/kern/postnote.c | 2 +- qa/kern/psx.c | 2 +- qa/kern/sched0.c | 2 +- qa/kern/segattach.c | 2 +- qa/kern/syscall.c | 2 +- qa/kern/sysstatread.c | 2 +- qa/kern/tsemacquire.c | 2 +- qa/kern/waserror.c | 2 +- qa/lib/c/asmscall.c | 2 +- qa/lib/c/cleanname.c | 2 +- qa/lib/c/conswrite.c | 2 +- qa/lib/c/hcube.c | 2 +- qa/lib/c/lockt.c | 6 +- qa/lib/c/longjmp.c | 2 +- qa/lib/c/privates.c | 2 +- qa/lib/c/privates2.c | 2 +- qa/lib/c/qlockt0.c | 2 +- qa/lib/c/qlockt1.c | 2 +- qa/lib/c/qlockt2.c | 2 +- qa/lib/c/rlockt0.c | 2 +- qa/lib/c/rlockt1.c | 2 +- qa/lib/c/rlockt2.c | 2 +- qa/lib/c/rsleept0.c | 2 +- qa/lib/c/rsleept1.c | 2 +- qa/lib/c/rsleept2.c | 2 +- qa/lib/c/rwakeup0.c | 2 +- qa/lib/c/sleep.c | 2 +- qa/lib/c/sqrt.c | 2 +- qa/lib/c/sysfatal.c | 2 +- qa/lib/c/va_copy.c | 2 +- qa/lib/c/vseprint.c | 2 +- qa/lib/c/wlockt0.c | 2 +- qa/lib/c/wlockt1.c | 2 +- qa/lib/c/wlockt2.c | 2 +- qa/lib/thread/thread.c | 2 +- sys/include/9P2000.h | 1 + sys/include/apw/errno.h | 215 ++++++++ sys/include/apw/stdlib.h | 2 +- sys/include/ip.h | 4 +- sys/include/lib9.h | 310 ++++++++++++ sys/include/libc.h | 645 +++++++++++------------- sys/src/cmd/acme/acme.c | 2 +- sys/src/cmd/acme/addr.c | 2 +- sys/src/cmd/acme/aux/awd.c | 2 +- sys/src/cmd/acme/aux/mkwnew.c | 2 +- sys/src/cmd/acme/aux/win/fs.c | 2 +- sys/src/cmd/acme/aux/win/main.c | 2 +- sys/src/cmd/acme/aux/win/pipe.c | 2 +- sys/src/cmd/acme/aux/win/util.c | 2 +- sys/src/cmd/acme/aux/win/win.c | 2 +- sys/src/cmd/acme/buff.c | 2 +- sys/src/cmd/acme/cols.c | 2 +- sys/src/cmd/acme/disk.c | 2 +- sys/src/cmd/acme/ecmd.c | 2 +- sys/src/cmd/acme/edit.c | 2 +- sys/src/cmd/acme/elog.c | 2 +- sys/src/cmd/acme/exec.c | 2 +- sys/src/cmd/acme/file.c | 2 +- sys/src/cmd/acme/fsys.c | 2 +- sys/src/cmd/acme/look.c | 2 +- sys/src/cmd/acme/regx.c | 2 +- sys/src/cmd/acme/rows.c | 2 +- sys/src/cmd/acme/scrl.c | 2 +- sys/src/cmd/acme/text.c | 2 +- sys/src/cmd/acme/time.c | 2 +- sys/src/cmd/acme/util.c | 2 +- sys/src/cmd/acme/wind.c | 2 +- sys/src/cmd/acme/xfid.c | 2 +- sys/src/cmd/ascii.c | 2 +- sys/src/cmd/auth/as.c | 2 +- sys/src/cmd/auth/asn12dsa.c | 2 +- sys/src/cmd/auth/asn12rsa.c | 2 +- sys/src/cmd/auth/authsrv.c | 2 +- sys/src/cmd/auth/challenge.c | 2 +- sys/src/cmd/auth/changeuser.c | 2 +- sys/src/cmd/auth/convbio.c | 2 +- sys/src/cmd/auth/convkeys.c | 2 +- sys/src/cmd/auth/cron.c | 2 +- sys/src/cmd/auth/debug.c | 2 +- sys/src/cmd/auth/dsa2pub.c | 2 +- sys/src/cmd/auth/dsa2ssh.c | 2 +- sys/src/cmd/auth/dsagen.c | 2 +- sys/src/cmd/auth/factotum/dat.h | 2 +- sys/src/cmd/auth/guard.srv.c | 2 +- sys/src/cmd/auth/httpauth.c | 2 +- sys/src/cmd/auth/keyfs.c | 2 +- sys/src/cmd/auth/lib/error.c | 2 +- sys/src/cmd/auth/lib/fs.c | 2 +- sys/src/cmd/auth/lib/getauthkey.c | 2 +- sys/src/cmd/auth/lib/getexpiration.c | 2 +- sys/src/cmd/auth/lib/keyfmt.c | 2 +- sys/src/cmd/auth/lib/log.c | 2 +- sys/src/cmd/auth/lib/netcheck.c | 2 +- sys/src/cmd/auth/lib/okpasswd.c | 2 +- sys/src/cmd/auth/lib/private.c | 2 +- sys/src/cmd/auth/lib/querybio.c | 2 +- sys/src/cmd/auth/lib/rdbio.c | 2 +- sys/src/cmd/auth/lib/readarg.c | 2 +- sys/src/cmd/auth/lib/readln.c | 2 +- sys/src/cmd/auth/lib/readn.c | 2 +- sys/src/cmd/auth/lib/readwrite.c | 2 +- sys/src/cmd/auth/lib/wrbio.c | 2 +- sys/src/cmd/auth/login.c | 2 +- sys/src/cmd/auth/netkey.c | 2 +- sys/src/cmd/auth/newns.c | 2 +- sys/src/cmd/auth/none.c | 2 +- sys/src/cmd/auth/passwd.c | 2 +- sys/src/cmd/auth/pemdecode.c | 2 +- sys/src/cmd/auth/pemencode.c | 2 +- sys/src/cmd/auth/printnetkey.c | 2 +- sys/src/cmd/auth/readnvram.c | 2 +- sys/src/cmd/auth/respond.c | 2 +- sys/src/cmd/auth/rsa2any.c | 2 +- sys/src/cmd/auth/rsa2csr.c | 2 +- sys/src/cmd/auth/rsa2pub.c | 2 +- sys/src/cmd/auth/rsa2ssh.c | 2 +- sys/src/cmd/auth/rsa2x509.c | 2 +- sys/src/cmd/auth/rsafill.c | 2 +- sys/src/cmd/auth/rsagen.c | 2 +- sys/src/cmd/auth/secstore/SConn.c | 2 +- sys/src/cmd/auth/secstore/aescbc.c | 2 +- sys/src/cmd/auth/secstore/dirls.c | 2 +- sys/src/cmd/auth/secstore/pak.c | 2 +- sys/src/cmd/auth/secstore/password.c | 2 +- sys/src/cmd/auth/secstore/secchk.c | 2 +- sys/src/cmd/auth/secstore/secstore.c | 2 +- sys/src/cmd/auth/secstore/secstored.c | 2 +- sys/src/cmd/auth/secstore/secuser.c | 2 +- sys/src/cmd/auth/secstore/util.c | 2 +- sys/src/cmd/auth/secureidcheck.c | 2 +- sys/src/cmd/auth/uniq.c | 2 +- sys/src/cmd/auth/userpasswd.c | 2 +- sys/src/cmd/auth/warning.c | 2 +- sys/src/cmd/auth/wrkey.c | 2 +- sys/src/cmd/awk/awk.h | 2 +- sys/src/cmd/awk/awkgram.y | 2 +- sys/src/cmd/awk/lex.c | 2 +- sys/src/cmd/awk/lib.c | 2 +- sys/src/cmd/awk/main.c | 36 +- sys/src/cmd/awk/maketab.c | 4 +- sys/src/cmd/awk/maketab.go | 2 +- sys/src/cmd/awk/parse.c | 2 +- sys/src/cmd/awk/popen.c | 2 +- sys/src/cmd/awk/re.c | 2 +- sys/src/cmd/awk/run.c | 2 +- sys/src/cmd/awk/tran.c | 2 +- sys/src/cmd/basename.c | 2 +- sys/src/cmd/bind.c | 2 +- sys/src/cmd/cal.c | 2 +- sys/src/cmd/cat.c | 2 +- sys/src/cmd/chgrp.c | 2 +- sys/src/cmd/chmod.c | 2 +- sys/src/cmd/cleanname.c | 2 +- sys/src/cmd/cmds.json | 4 +- sys/src/cmd/cp.c | 2 +- sys/src/cmd/cpu.c | 22 +- sys/src/cmd/date.c | 2 +- sys/src/cmd/dd.c | 2 +- sys/src/cmd/disk/format.c | 2 +- sys/src/cmd/disk/mkext.c | 2 +- sys/src/cmd/disk/mkfs.c | 2 +- sys/src/cmd/disk/prep/calc.y | 2 +- sys/src/cmd/disk/prep/edit.c | 2 +- sys/src/cmd/disk/prep/fdisk.c | 2 +- sys/src/cmd/disk/prep/fdisk.json | 1 + sys/src/cmd/disk/prep/prep.c | 98 ++-- sys/src/cmd/disk/prep/prep.json | 1 + sys/src/cmd/disk/rofs/mkrofs.c | 2 +- sys/src/cmd/disk/rofs/rofs.c | 2 +- sys/src/cmd/dossrv/chat.c | 10 +- sys/src/cmd/dossrv/devio.c | 2 +- sys/src/cmd/dossrv/dosfs.c | 62 +-- sys/src/cmd/dossrv/dossubs.c | 116 ++--- sys/src/cmd/dossrv/fns.h | 2 +- sys/src/cmd/dossrv/iotrack.c | 8 +- sys/src/cmd/dossrv/xfile.c | 24 +- sys/src/cmd/dossrv/xfssrv.c | 32 +- sys/src/cmd/du.c | 2 +- sys/src/cmd/echo.c | 2 +- sys/src/cmd/ed.c | 2 +- sys/src/cmd/exportfs/exportfs.c | 2 +- sys/src/cmd/exportfs/exportsrv.c | 2 +- sys/src/cmd/exportfs/pattern.c | 2 +- sys/src/cmd/fcp.c | 2 +- sys/src/cmd/field.c | 2 +- sys/src/cmd/flip.c | 2 +- sys/src/cmd/grep/build.json | 1 + sys/src/cmd/grep/grep.h | 2 +- sys/src/cmd/hget.c | 2 +- sys/src/cmd/hjfs/9p.c | 2 +- sys/src/cmd/hjfs/auth.c | 2 +- sys/src/cmd/hjfs/buf.c | 2 +- sys/src/cmd/hjfs/cons.c | 2 +- sys/src/cmd/hjfs/conv.c | 2 +- sys/src/cmd/hjfs/dev.c | 2 +- sys/src/cmd/hjfs/dump.c | 2 +- sys/src/cmd/hjfs/fs1.c | 2 +- sys/src/cmd/hjfs/fs2.c | 2 +- sys/src/cmd/hjfs/main.c | 2 +- sys/src/cmd/hmi/console/buffer.c | 2 +- sys/src/cmd/hmi/console/cga.c | 2 +- sys/src/cmd/hmi/console/comconsole.c | 2 +- sys/src/cmd/hmi/console/keyboard.c | 2 +- sys/src/cmd/hmi/console/passthrough.c | 2 +- sys/src/cmd/hmi/console/pipeconsole.c | 2 +- sys/src/cmd/hmi/console/screenconsole.c | 2 +- sys/src/cmd/hmi/console/serve9p.c | 2 +- sys/src/cmd/hmi/console/utils.c | 2 +- sys/src/cmd/hmi/mouse.c | 2 +- sys/src/cmd/hmi/realemu/arg.c | 2 +- sys/src/cmd/hmi/realemu/debug.c | 2 +- sys/src/cmd/hmi/realemu/decode.c | 2 +- sys/src/cmd/hmi/realemu/fmt.c | 2 +- sys/src/cmd/hmi/realemu/loadcom.c | 2 +- sys/src/cmd/hmi/realemu/main.c | 2 +- sys/src/cmd/hmi/realemu/pit.c | 2 +- sys/src/cmd/hmi/realemu/xec.c | 2 +- sys/src/cmd/hmi/vga/ch9294.c | 2 +- sys/src/cmd/hmi/vga/clgd542x.c | 2 +- sys/src/cmd/hmi/vga/clgd546x.c | 2 +- sys/src/cmd/hmi/vga/data.c | 2 +- sys/src/cmd/hmi/vga/db.c | 2 +- sys/src/cmd/hmi/vga/error.c | 2 +- sys/src/cmd/hmi/vga/icd2061a.c | 2 +- sys/src/cmd/hmi/vga/ics2494.c | 2 +- sys/src/cmd/hmi/vga/ics534x.c | 2 +- sys/src/cmd/hmi/vga/io.c | 2 +- sys/src/cmd/hmi/vga/main.c | 2 +- sys/src/cmd/hmi/vga/nvidia.c | 2 +- sys/src/cmd/hmi/vga/palette.c | 2 +- sys/src/cmd/hmi/vga/pci.c | 2 +- sys/src/cmd/hmi/vga/radeon.c | 2 +- sys/src/cmd/hmi/vga/rgb524.c | 2 +- sys/src/cmd/hmi/vga/rgb524mn.c | 2 +- sys/src/cmd/hmi/vga/s3801.c | 2 +- sys/src/cmd/hmi/vga/s3928.c | 2 +- sys/src/cmd/hmi/vga/s3clock.c | 2 +- sys/src/cmd/hmi/vga/s3generic.c | 2 +- sys/src/cmd/hmi/vga/s3hwgc.c | 2 +- sys/src/cmd/hmi/vga/sc15025.c | 2 +- sys/src/cmd/hmi/vga/stg1702.c | 2 +- sys/src/cmd/hmi/vga/t2r4.c | 2 +- sys/src/cmd/hmi/vga/template.c | 2 +- sys/src/cmd/hmi/vga/trio64.c | 2 +- sys/src/cmd/hmi/vga/tvp3020.c | 2 +- sys/src/cmd/hmi/vga/tvp3025.c | 2 +- sys/src/cmd/hmi/vga/tvp3025clock.c | 2 +- sys/src/cmd/hmi/vga/tvp3026.c | 2 +- sys/src/cmd/hmi/vga/tvp3026clock.c | 2 +- sys/src/cmd/hmi/vga/vesa.c | 2 +- sys/src/cmd/hmi/vga/vesadb.c | 2 +- sys/src/cmd/hmi/vga/vga.c | 2 +- sys/src/cmd/hmi/vga/virge.c | 2 +- sys/src/cmd/hmi/vga/vision864.c | 2 +- sys/src/cmd/hmi/vga/vision964.c | 2 +- sys/src/cmd/hmi/vga/vision968.c | 2 +- sys/src/cmd/hmi/vga/vmware.c | 2 +- sys/src/cmd/hoc/build.json | 1 + sys/src/cmd/hoc/code.c | 2 +- sys/src/cmd/hoc/hoc.y | 2 +- sys/src/cmd/hoc/init.c | 2 +- sys/src/cmd/hoc/math.c | 2 +- sys/src/cmd/hoc/symbol.c | 2 +- sys/src/cmd/import.c | 2 +- sys/src/cmd/init.c | 2 +- sys/src/cmd/ip/dhcpclient.c | 2 +- sys/src/cmd/ip/dhcpd/db.c | 2 +- sys/src/cmd/ip/dhcpd/dhcpd.c | 2 +- sys/src/cmd/ip/dhcpd/dhcpleases.c | 2 +- sys/src/cmd/ip/dhcpd/ndb.c | 2 +- sys/src/cmd/ip/dhcpd/ping.c | 2 +- sys/src/cmd/ip/dhcpd/testlook.c | 2 +- sys/src/cmd/ip/dhcpd/testlookup.c | 2 +- sys/src/cmd/ip/dhcpd/testping.c | 2 +- sys/src/cmd/ip/gping.c | 10 +- sys/src/cmd/ip/hogports.c | 2 +- sys/src/cmd/ip/ipconfig/ipv6.c | 2 +- sys/src/cmd/ip/ipconfig/main.c | 2 +- sys/src/cmd/ip/ipconfig/ppp.c | 2 +- sys/src/cmd/ip/linklocal.c | 2 +- sys/src/cmd/ip/listen.c | 2 +- sys/src/cmd/ip/listen1.c | 2 +- sys/src/cmd/ip/ping.c | 14 +- sys/src/cmd/ip/rip.c | 2 +- sys/src/cmd/ip/timesync.c | 2 +- sys/src/cmd/ip/traceroute.c | 2 +- sys/src/cmd/ip/trampoline.c | 2 +- sys/src/cmd/join.c | 2 +- sys/src/cmd/lock.c | 52 +- sys/src/cmd/look.c | 3 +- sys/src/cmd/ls.c | 2 +- sys/src/cmd/mc.c | 2 +- sys/src/cmd/mkdir.c | 2 +- sys/src/cmd/mntgen.c | 2 +- sys/src/cmd/mount.c | 2 +- sys/src/cmd/mpc.y | 2 +- sys/src/cmd/ms.c | 2 +- sys/src/cmd/mtime.c | 2 +- sys/src/cmd/mv.c | 2 +- sys/src/cmd/ndb/convDNS2M.c | 2 +- sys/src/cmd/ndb/convM2DNS.c | 2 +- sys/src/cmd/ndb/cs.c | 2 +- sys/src/cmd/ndb/csquery.c | 2 +- sys/src/cmd/ndb/dblookup.c | 24 +- sys/src/cmd/ndb/dn.c | 64 +-- sys/src/cmd/ndb/dnarea.c | 12 +- sys/src/cmd/ndb/dnnotify.c | 2 +- sys/src/cmd/ndb/dnresolve.c | 2 +- sys/src/cmd/ndb/dns.c | 34 +- sys/src/cmd/ndb/dnsdebug.c | 2 +- sys/src/cmd/ndb/dnserver.c | 2 +- sys/src/cmd/ndb/dnsgetip.c | 2 +- sys/src/cmd/ndb/dnsquery.c | 2 +- sys/src/cmd/ndb/dnstcp.c | 2 +- sys/src/cmd/ndb/dnudpserver.c | 2 +- sys/src/cmd/ndb/idn.c | 2 +- sys/src/cmd/ndb/inform.c | 2 +- sys/src/cmd/ndb/ipquery.c | 2 +- sys/src/cmd/ndb/mkdb.c | 2 +- sys/src/cmd/ndb/mkhash.c | 2 +- sys/src/cmd/ndb/mkhosts.c | 2 +- sys/src/cmd/ndb/query.c | 2 +- sys/src/cmd/netstat.c | 2 +- sys/src/cmd/ns.c | 2 +- sys/src/cmd/p.c | 2 +- sys/src/cmd/pict/bmp.c | 2 +- sys/src/cmd/pict/close.c | 2 +- sys/src/cmd/pict/gif.c | 2 +- sys/src/cmd/pict/ico.c | 2 +- sys/src/cmd/pict/jpg.c | 2 +- sys/src/cmd/pict/multichan.c | 2 +- sys/src/cmd/pict/onechan.c | 2 +- sys/src/cmd/pict/png.c | 2 +- sys/src/cmd/pict/ppm.c | 2 +- sys/src/cmd/pict/readbmp.c | 2 +- sys/src/cmd/pict/readgif.c | 2 +- sys/src/cmd/pict/readjpg.c | 2 +- sys/src/cmd/pict/readpng.c | 2 +- sys/src/cmd/pict/readppm.c | 2 +- sys/src/cmd/pict/readtga.c | 2 +- sys/src/cmd/pict/readtif.c | 2 +- sys/src/cmd/pict/readv210.c | 2 +- sys/src/cmd/pict/readyuv.c | 2 +- sys/src/cmd/pict/rgbrgbv.c | 2 +- sys/src/cmd/pict/rgbycc.c | 2 +- sys/src/cmd/pict/tga.c | 2 +- sys/src/cmd/pict/tif.c | 2 +- sys/src/cmd/pict/togif.c | 2 +- sys/src/cmd/pict/toico.c | 2 +- sys/src/cmd/pict/tojpg.c | 2 +- sys/src/cmd/pict/topng.c | 2 +- sys/src/cmd/pict/toppm.c | 2 +- sys/src/cmd/pict/torgbv.c | 2 +- sys/src/cmd/pict/totif.c | 2 +- sys/src/cmd/pict/totruecolor.c | 2 +- sys/src/cmd/pict/v210.c | 2 +- sys/src/cmd/pict/writegif.c | 2 +- sys/src/cmd/pict/writejpg.c | 2 +- sys/src/cmd/pict/writepng.c | 2 +- sys/src/cmd/pict/writeppm.c | 2 +- sys/src/cmd/pict/writerawimage.c | 2 +- sys/src/cmd/pict/writetif.c | 2 +- sys/src/cmd/pict/yuv.c | 2 +- sys/src/cmd/pipefile.c | 2 +- sys/src/cmd/ps.c | 2 +- sys/src/cmd/pwd.c | 2 +- sys/src/cmd/ramfs.c | 2 +- sys/src/cmd/rc/build.json | 1 + sys/src/cmd/rc/rc.h | 2 +- sys/src/cmd/rio/data.c | 2 +- sys/src/cmd/rio/fsys.c | 2 +- sys/src/cmd/rio/rio.c | 4 +- sys/src/cmd/rio/scrl.c | 2 +- sys/src/cmd/rio/time.c | 2 +- sys/src/cmd/rio/util.c | 2 +- sys/src/cmd/rio/wctl.c | 2 +- sys/src/cmd/rio/wind.c | 2 +- sys/src/cmd/rio/xfid.c | 2 +- sys/src/cmd/rm.c | 2 +- sys/src/cmd/sam/sam.h | 2 +- sys/src/cmd/samterm/flayer.c | 4 +- sys/src/cmd/samterm/io.c | 16 +- sys/src/cmd/samterm/main.c | 12 +- sys/src/cmd/samterm/menu.c | 40 +- sys/src/cmd/samterm/mesg.c | 18 +- sys/src/cmd/samterm/plan9.c | 54 +- sys/src/cmd/samterm/rasp.c | 14 +- sys/src/cmd/samterm/scroll.c | 2 +- sys/src/cmd/sed.c | 2 +- sys/src/cmd/seq.c | 2 +- sys/src/cmd/sleep.c | 2 +- sys/src/cmd/sort.c | 2 +- sys/src/cmd/split.c | 2 +- sys/src/cmd/srv.c | 2 +- sys/src/cmd/srvfs.c | 2 +- sys/src/cmd/stats.c | 2 +- sys/src/cmd/sys/call/syscall.c | 2 +- sys/src/cmd/sys/ctrace.c | 2 +- sys/src/cmd/tail.c | 2 +- sys/src/cmd/tar.c | 2 +- sys/src/cmd/tee.c | 2 +- sys/src/cmd/test.c | 2 +- sys/src/cmd/time.c | 32 +- sys/src/cmd/touch.c | 2 +- sys/src/cmd/tr.c | 2 +- sys/src/cmd/unicode.c | 2 +- sys/src/cmd/uniq.c | 2 +- sys/src/cmd/unmount.c | 2 +- sys/src/cmd/usb/audio/audio.c | 2 +- sys/src/cmd/usb/disk/disk.c | 2 +- sys/src/cmd/usb/disk/mkscsierrs | 2 +- sys/src/cmd/usb/disk/scsierrs.c | 2 +- sys/src/cmd/usb/disk/scsireq.c | 2 +- sys/src/cmd/usb/ether/asix.c | 2 +- sys/src/cmd/usb/ether/aue.c | 2 +- sys/src/cmd/usb/ether/cdc.c | 2 +- sys/src/cmd/usb/ether/ether.c | 2 +- sys/src/cmd/usb/ether/rndis.c | 2 +- sys/src/cmd/usb/ether/smsc.c | 2 +- sys/src/cmd/usb/ether/url.c | 2 +- sys/src/cmd/usb/joy/joy.c | 2 +- sys/src/cmd/usb/kb/kb.c | 2 +- sys/src/cmd/usb/lib/dev.c | 2 +- sys/src/cmd/usb/lib/dump.c | 2 +- sys/src/cmd/usb/lib/parse.c | 2 +- sys/src/cmd/usb/ptp/ptp.c | 2 +- sys/src/cmd/usb/serial/ftdi.c | 2 +- sys/src/cmd/usb/serial/prolific.c | 2 +- sys/src/cmd/usb/serial/serial.c | 2 +- sys/src/cmd/usb/serial/silabs.c | 2 +- sys/src/cmd/usb/serial/ucons.c | 2 +- sys/src/cmd/usb/usbd/hname.c | 2 +- sys/src/cmd/usb/usbd/hub.c | 12 +- sys/src/cmd/usb/usbd/usbd.c | 2 +- sys/src/cmd/wc.c | 2 +- sys/src/cmd/xargs.c | 2 +- sys/src/cmd/xd.c | 2 +- sys/src/kern/386/bios32.c | 10 +- sys/src/kern/386/devether.c | 70 +-- sys/src/kern/386/devpmc.c | 72 +-- sys/src/kern/386/devrtc.c | 16 +- sys/src/kern/386/ether8139.c | 78 +-- sys/src/kern/386/ether8169.c | 114 ++--- sys/src/kern/386/ether82557.c | 92 ++-- sys/src/kern/386/ether82563.c | 94 ++-- sys/src/kern/386/ether82598.c | 44 +- sys/src/kern/386/etherbcm.c | 60 +-- sys/src/kern/386/etherigbe.c | 106 ++-- sys/src/kern/386/etherm10g.c | 146 +++--- sys/src/kern/386/ethermii.c | 8 +- sys/src/kern/386/fis.c | 20 +- sys/src/kern/386/i8042.c | 12 +- sys/src/kern/386/kbd.c | 20 +- sys/src/kern/386/pci.c | 74 +-- sys/src/kern/386/pmcio.c | 38 +- sys/src/kern/386/sdiahci.c | 144 +++--- sys/src/kern/386/sdscsi.c | 38 +- sys/src/kern/386/uarti8250.c | 12 +- sys/src/kern/386/uartpci.c | 8 +- sys/src/kern/386/vgavesa.c | 12 +- sys/src/kern/amd64/acpi.c | 200 ++++---- sys/src/kern/amd64/archamd64.c | 24 +- sys/src/kern/amd64/cbscreen.c | 18 +- sys/src/kern/amd64/cga.c | 8 +- sys/src/kern/amd64/dat.h | 2 +- sys/src/kern/amd64/devacpi.c | 28 +- sys/src/kern/amd64/devarch.c | 36 +- sys/src/kern/amd64/devkbin.c | 2 +- sys/src/kern/amd64/devvga.c | 80 +-- sys/src/kern/amd64/fpu.c | 12 +- sys/src/kern/amd64/hpet.c | 8 +- sys/src/kern/amd64/i8254.c | 6 +- sys/src/kern/amd64/ioapic.c | 40 +- sys/src/kern/amd64/lapic.c | 34 +- sys/src/kern/amd64/main.c | 42 +- sys/src/kern/amd64/memory.c | 14 +- sys/src/kern/amd64/mmu.c | 72 +-- sys/src/kern/amd64/mouse.c | 8 +- sys/src/kern/amd64/mp.c | 42 +- sys/src/kern/amd64/msi.c | 2 +- sys/src/kern/amd64/multiboot.c | 26 +- sys/src/kern/amd64/options.c | 36 +- sys/src/kern/amd64/screen.c | 18 +- sys/src/kern/amd64/sdahci.c | 108 ++-- sys/src/kern/amd64/sdata.c | 172 +++---- sys/src/kern/amd64/sipi.c | 10 +- sys/src/kern/amd64/syscall.c | 46 +- sys/src/kern/amd64/trap.c | 34 +- sys/src/kern/amd64/usbehci.h | 8 +- sys/src/kern/amd64/usbehcipc.c | 16 +- sys/src/kern/amd64/usbohci.c | 226 ++++----- sys/src/kern/amd64/usbuhci.c | 204 ++++---- sys/src/kern/amd64/vga.c | 8 +- sys/src/kern/amd64/vsvm.c | 4 +- sys/src/kern/boot/aux.c | 60 +-- sys/src/kern/boot/boot.c | 146 +++--- sys/src/kern/boot/boot.h | 2 +- sys/src/kern/boot/bootauth.c | 18 +- sys/src/kern/boot/bootcache.c | 46 +- sys/src/kern/boot/bootip.c | 72 +-- sys/src/kern/boot/bootrc.c | 22 +- sys/src/kern/boot/doauthenticate.c | 34 +- sys/src/kern/boot/embed.c | 26 +- sys/src/kern/boot/getpasswd.c | 6 +- sys/src/kern/boot/local.c | 48 +- sys/src/kern/boot/nopsession.c | 8 +- sys/src/kern/boot/paq.c | 20 +- sys/src/kern/boot/printstub.c | 4 +- sys/src/kern/boot/sac.c | 6 +- sys/src/kern/boot/settime.c | 20 +- sys/src/kern/ip/arp.c | 44 +- sys/src/kern/ip/chandial.c | 20 +- sys/src/kern/ip/devip.c | 130 ++--- sys/src/kern/ip/esp.c | 138 ++--- sys/src/kern/ip/ethermedium.c | 100 ++-- sys/src/kern/ip/gre.c | 74 +-- sys/src/kern/ip/icmp.c | 36 +- sys/src/kern/ip/icmp6.c | 48 +- sys/src/kern/ip/il.c | 14 +- sys/src/kern/ip/ip.c | 18 +- sys/src/kern/ip/ip.h | 4 +- sys/src/kern/ip/ipaux.c | 8 +- sys/src/kern/ip/ipifc.c | 148 +++--- sys/src/kern/ip/iproute.c | 74 +-- sys/src/kern/ip/ipv6.c | 26 +- sys/src/kern/ip/ipv6.h | 2 +- sys/src/kern/ip/loopbackmedium.c | 2 +- sys/src/kern/ip/netdevmedium.c | 2 +- sys/src/kern/ip/netlog.c | 18 +- sys/src/kern/ip/tcp.c | 112 ++-- sys/src/kern/ip/udp.c | 20 +- sys/src/kern/port/allocb.c | 16 +- sys/src/kern/port/awake.c | 8 +- sys/src/kern/port/bud.c | 18 +- sys/src/kern/port/cache.c | 20 +- sys/src/kern/port/chan.c | 162 +++--- sys/src/kern/port/debug.c | 8 +- sys/src/kern/port/dev.c | 28 +- sys/src/kern/port/dev9p.c | 70 +-- sys/src/kern/port/devbridge.c | 128 ++--- sys/src/kern/port/devcap.c | 28 +- sys/src/kern/port/devcons.c | 82 +-- sys/src/kern/port/devdraw.c | 154 +++--- sys/src/kern/port/devdup.c | 4 +- sys/src/kern/port/devenv.c | 62 +-- sys/src/kern/port/devfs.c | 132 ++--- sys/src/kern/port/devkprof.c | 10 +- sys/src/kern/port/devmem.c | 8 +- sys/src/kern/port/devmem1.c | 8 +- sys/src/kern/port/devmouse.c | 36 +- sys/src/kern/port/devpci.c | 14 +- sys/src/kern/port/devpipe.c | 20 +- sys/src/kern/port/devproc.c | 132 ++--- sys/src/kern/port/devroot.c | 6 +- sys/src/kern/port/devsd.c | 164 +++--- sys/src/kern/port/devsegment.c | 42 +- sys/src/kern/port/devself.c | 30 +- sys/src/kern/port/devshr.c | 66 +-- sys/src/kern/port/devsrv.c | 48 +- sys/src/kern/port/devssl.c | 130 ++--- sys/src/kern/port/devtab.c | 10 +- sys/src/kern/port/devtls.c | 154 +++--- sys/src/kern/port/devtrace.c | 118 ++--- sys/src/kern/port/devuart.c | 28 +- sys/src/kern/port/devusb.c | 170 +++---- sys/src/kern/port/devwd.c | 20 +- sys/src/kern/port/elf64.c | 14 +- sys/src/kern/port/fault.c | 4 +- sys/src/kern/port/imagmem.c | 8 +- sys/src/kern/port/initcode.c | 30 +- sys/src/kern/port/latin1.c | 2 +- sys/src/kern/port/led.c | 6 +- sys/src/kern/port/lib.h | 135 +++-- sys/src/kern/port/log.c | 14 +- sys/src/kern/port/mcslock.c | 2 +- sys/src/kern/port/netif.c | 110 ++-- sys/src/kern/port/parse.c | 20 +- sys/src/kern/port/pgrp.c | 22 +- sys/src/kern/port/physalloc.c | 6 +- sys/src/kern/port/portclock.c | 4 +- sys/src/kern/port/print.c | 6 +- sys/src/kern/port/proc.c | 66 +-- sys/src/kern/port/ps.c | 4 +- sys/src/kern/port/qio.c | 64 +-- sys/src/kern/port/qlock.c | 10 +- sys/src/kern/port/qmalloc.c | 145 +++--- sys/src/kern/port/rmap.c | 8 +- sys/src/kern/port/sd.h | 4 +- sys/src/kern/port/sysauth.c | 18 +- sys/src/kern/port/syscallfmt.c | 16 +- sys/src/kern/port/sysfile.c | 42 +- sys/src/kern/port/sysproc.c | 70 +-- sys/src/kern/port/tod.c | 2 +- sys/src/kern/port/uidgid.c | 60 +-- sys/src/kern/port/umem/images.c | 45 +- sys/src/kern/port/umem/pages.c | 44 +- sys/src/kern/port/umem/raw.c | 14 +- sys/src/kern/port/umem/segments.c | 10 +- sys/src/kern/port/umem/test.c | 32 +- sys/src/kern/port/usb.h | 8 +- sys/src/kern/port/usbehci.c | 292 +++++------ sys/src/lib/9p/auth.c | 2 +- sys/src/lib/9p/dirread.c | 2 +- sys/src/lib/9p/fid.c | 2 +- sys/src/lib/9p/file.c | 108 ++-- sys/src/lib/9p/ftest.c | 2 +- sys/src/lib/9p/intmap.c | 2 +- sys/src/lib/9p/listen.c | 2 +- sys/src/lib/9p/mem.c | 2 +- sys/src/lib/9p/parse.c | 2 +- sys/src/lib/9p/post.c | 2 +- sys/src/lib/9p/queue.c | 2 +- sys/src/lib/9p/ramfs.c | 2 +- sys/src/lib/9p/req.c | 2 +- sys/src/lib/9p/rfork.c | 2 +- sys/src/lib/9p/srv.c | 2 +- sys/src/lib/9p/thread.c | 2 +- sys/src/lib/9p/uid.c | 2 +- sys/src/lib/9p/util.c | 2 +- sys/src/lib/9p2000/convM2S.c | 2 +- sys/src/lib/9p2000/convS2M.c | 2 +- sys/src/lib/9p2000/fcallfmt.c | 2 +- sys/src/lib/9p2000/read9pmsg.c | 2 +- sys/src/lib/String/s_alloc.c | 12 +- sys/src/lib/String/s_append.c | 2 +- sys/src/lib/String/s_array.c | 2 +- sys/src/lib/String/s_copy.c | 2 +- sys/src/lib/String/s_getline.c | 2 +- sys/src/lib/String/s_grow.c | 2 +- sys/src/lib/String/s_memappend.c | 2 +- sys/src/lib/String/s_nappend.c | 2 +- sys/src/lib/String/s_parse.c | 2 +- sys/src/lib/String/s_putc.c | 2 +- sys/src/lib/String/s_rdinstack.c | 2 +- sys/src/lib/String/s_read.c | 2 +- sys/src/lib/String/s_read_line.c | 2 +- sys/src/lib/String/s_reset.c | 2 +- sys/src/lib/String/s_terminate.c | 2 +- sys/src/lib/String/s_tolower.c | 2 +- sys/src/lib/String/s_unique.c | 2 +- sys/src/lib/aml/aml.c | 2 +- sys/src/lib/aml/amlalloc.c | 2 +- sys/src/lib/aml/amldelay.c | 2 +- sys/src/lib/aml/amlmapio.c | 2 +- sys/src/lib/aml/amlunmapio.c | 2 +- sys/src/lib/auth/amount.c | 2 +- sys/src/lib/auth/amount_getkey.c | 2 +- sys/src/lib/auth/attr.c | 2 +- sys/src/lib/auth/auth_attr.c | 2 +- sys/src/lib/auth/auth_challenge.c | 2 +- sys/src/lib/auth/auth_chuid.c | 2 +- sys/src/lib/auth/auth_getkey.c | 2 +- sys/src/lib/auth/auth_getuserpasswd.c | 2 +- sys/src/lib/auth/auth_proxy.c | 2 +- sys/src/lib/auth/auth_respond.c | 2 +- sys/src/lib/auth/auth_rpc.c | 2 +- sys/src/lib/auth/auth_userpasswd.c | 2 +- sys/src/lib/auth/auth_wep.c | 2 +- sys/src/lib/auth/login.c | 2 +- sys/src/lib/auth/newns.c | 2 +- sys/src/lib/auth/noworld.c | 2 +- sys/src/lib/authsrv/_asgetpakkey.c | 2 +- sys/src/lib/authsrv/_asgetresp.c | 2 +- sys/src/lib/authsrv/_asgetticket.c | 2 +- sys/src/lib/authsrv/_asrdresp.c | 2 +- sys/src/lib/authsrv/_asrequest.c | 2 +- sys/src/lib/authsrv/authdial.c | 2 +- sys/src/lib/authsrv/authpak.c | 6 +- sys/src/lib/authsrv/convA2M.c | 2 +- sys/src/lib/authsrv/convM2A.c | 2 +- sys/src/lib/authsrv/convM2PR.c | 2 +- sys/src/lib/authsrv/convM2T.c | 2 +- sys/src/lib/authsrv/convM2TR.c | 2 +- sys/src/lib/authsrv/convPR2M.c | 2 +- sys/src/lib/authsrv/convT2M.c | 2 +- sys/src/lib/authsrv/convTR2M.c | 2 +- sys/src/lib/authsrv/form1.c | 2 +- sys/src/lib/authsrv/nvcsum.c | 2 +- sys/src/lib/authsrv/passtokey.c | 2 +- sys/src/lib/authsrv/readnvram.c | 2 +- sys/src/lib/avl/avl.c | 2 +- sys/src/lib/bio/bbuffered.c | 2 +- sys/src/lib/bio/bfildes.c | 2 +- sys/src/lib/bio/bflush.c | 2 +- sys/src/lib/bio/bgetc.c | 2 +- sys/src/lib/bio/bgetd.c | 2 +- sys/src/lib/bio/bgetrune.c | 2 +- sys/src/lib/bio/binit.c | 2 +- sys/src/lib/bio/boffset.c | 2 +- sys/src/lib/bio/bprint.c | 2 +- sys/src/lib/bio/bputc.c | 2 +- sys/src/lib/bio/bputrune.c | 2 +- sys/src/lib/bio/brdline.c | 2 +- sys/src/lib/bio/brdstr.c | 2 +- sys/src/lib/bio/bread.c | 2 +- sys/src/lib/bio/bseek.c | 2 +- sys/src/lib/bio/btestprint.c | 2 +- sys/src/lib/bio/bvprint.c | 2 +- sys/src/lib/bio/bwrite.c | 2 +- sys/src/lib/c/9sys/access.c | 2 +- sys/src/lib/c/9sys/announce.c | 80 +-- sys/src/lib/c/9sys/awakened.c | 6 +- sys/src/lib/c/9sys/chdir.c | 8 +- sys/src/lib/c/9sys/convD2M.c | 10 +- sys/src/lib/c/9sys/convM2D.c | 4 +- sys/src/lib/c/9sys/cputime.c | 4 +- sys/src/lib/c/9sys/ctime.c | 30 +- sys/src/lib/c/9sys/dial.c | 94 ++-- sys/src/lib/c/9sys/dirfstat.c | 10 +- sys/src/lib/c/9sys/dirfwstat.c | 10 +- sys/src/lib/c/9sys/dirmodefmt.c | 6 +- sys/src/lib/c/9sys/dirread.c | 20 +- sys/src/lib/c/9sys/dirstat.c | 12 +- sys/src/lib/c/9sys/dirwstat.c | 12 +- sys/src/lib/c/9sys/dup.c | 2 +- sys/src/lib/c/9sys/fork.c | 2 +- sys/src/lib/c/9sys/getenv.c | 18 +- sys/src/lib/c/9sys/getmainpid.c | 2 +- sys/src/lib/c/9sys/getnetconninfo.c | 48 +- sys/src/lib/c/9sys/getpid.c | 2 +- sys/src/lib/c/9sys/getppid.c | 2 +- sys/src/lib/c/9sys/getwd.c | 2 +- sys/src/lib/c/9sys/iounit.c | 8 +- sys/src/lib/c/9sys/nsec.c | 2 +- sys/src/lib/c/9sys/nulldir.c | 4 +- sys/src/lib/c/9sys/ocreate.c | 8 +- sys/src/lib/c/9sys/pipe.c | 2 +- sys/src/lib/c/9sys/postnote.c | 18 +- sys/src/lib/c/9sys/privalloc.c | 6 +- sys/src/lib/c/9sys/pushssl.c | 12 +- sys/src/lib/c/9sys/putenv.c | 20 +- sys/src/lib/c/9sys/qlock.c | 190 +++---- sys/src/lib/c/9sys/rerrstr.c | 4 +- sys/src/lib/c/9sys/segattach.c | 12 +- sys/src/lib/c/9sys/{sbrk.c => segbrk.c} | 4 +- sys/src/lib/c/9sys/setnetmtpt.c | 6 +- sys/src/lib/c/9sys/sleep.c | 4 +- sys/src/lib/c/9sys/stat.c | 8 +- sys/src/lib/c/9sys/sysfatal.c | 10 +- sys/src/lib/c/9sys/syslog.c | 40 +- sys/src/lib/c/9sys/sysname.c | 2 +- sys/src/lib/c/9sys/time.c | 4 +- sys/src/lib/c/9sys/times.c | 14 +- sys/src/lib/c/9sys/tm2sec.c | 12 +- sys/src/lib/c/9sys/truerand.c | 6 +- sys/src/lib/c/9sys/wait.c | 20 +- sys/src/lib/c/9sys/waitpid.c | 8 +- sys/src/lib/c/9sys/werrstr.c | 4 +- sys/src/lib/c/amd64/atom.s | 12 +- sys/src/lib/c/amd64/crt0.s | 21 +- sys/src/lib/c/amd64/getfcr.s | 15 +- sys/src/lib/c/amd64/initlib.c | 51 ++ sys/src/lib/c/amd64/notejmp.c | 2 +- sys/src/lib/c/amd64/setjmp.s | 8 +- sys/src/lib/c/amd64/sqrt.s | 4 +- sys/src/lib/c/amd64/tas.s | 4 +- sys/src/lib/c/apw/eprintf.c | 2 +- sys/src/lib/c/apw/exit.c | 4 +- sys/src/lib/c/apw/system.c | 16 +- sys/src/lib/c/build.json | 3 +- sys/src/lib/c/fmt/dofmt.c | 26 +- sys/src/lib/c/fmt/dorfmt.c | 2 +- sys/src/lib/c/fmt/errfmt.c | 6 +- sys/src/lib/c/fmt/fltfmt.c | 42 +- sys/src/lib/c/fmt/fmt.c | 6 +- sys/src/lib/c/fmt/fmtdef.h | 4 +- sys/src/lib/c/fmt/fmtfd.c | 4 +- sys/src/lib/c/fmt/fmtlock.c | 4 +- sys/src/lib/c/fmt/fmtprint.c | 4 +- sys/src/lib/c/fmt/fmtquote.c | 20 +- sys/src/lib/c/fmt/fmtrune.c | 2 +- sys/src/lib/c/fmt/fmtstr.c | 2 +- sys/src/lib/c/fmt/fmtvprint.c | 4 +- sys/src/lib/c/fmt/fprint.c | 4 +- sys/src/lib/c/fmt/print.c | 4 +- sys/src/lib/c/fmt/runefmtstr.c | 2 +- sys/src/lib/c/fmt/runeseprint.c | 4 +- sys/src/lib/c/fmt/runesmprint.c | 4 +- sys/src/lib/c/fmt/runesnprint.c | 4 +- sys/src/lib/c/fmt/runesprint.c | 4 +- sys/src/lib/c/fmt/runevseprint.c | 4 +- sys/src/lib/c/fmt/runevsmprint.c | 22 +- sys/src/lib/c/fmt/runevsnprint.c | 4 +- sys/src/lib/c/fmt/seprint.c | 4 +- sys/src/lib/c/fmt/smprint.c | 6 +- sys/src/lib/c/fmt/snprint.c | 4 +- sys/src/lib/c/fmt/sprint.c | 4 +- sys/src/lib/c/fmt/vfprint.c | 6 +- sys/src/lib/c/fmt/vseprint.c | 4 +- sys/src/lib/c/fmt/vsmprint.c | 22 +- sys/src/lib/c/fmt/vsnprint.c | 4 +- sys/src/lib/c/lib9.c | 42 ++ sys/src/lib/c/port/_assert.c | 4 +- sys/src/lib/c/port/abs.c | 4 +- sys/src/lib/c/port/asin.c | 18 +- sys/src/lib/c/port/atan.c | 4 +- sys/src/lib/c/port/atan2.c | 4 +- sys/src/lib/c/port/atexit.c | 18 +- sys/src/lib/c/port/atnotify.c | 6 +- sys/src/lib/c/port/atof.c | 4 +- sys/src/lib/c/port/atol.c | 6 +- sys/src/lib/c/port/atoll.c | 4 +- sys/src/lib/c/port/bsearch.c | 2 +- sys/src/lib/c/port/charstod.c | 24 +- sys/src/lib/c/port/cistrcmp.c | 2 +- sys/src/lib/c/port/cistrncmp.c | 2 +- sys/src/lib/c/port/cistrstr.c | 6 +- sys/src/lib/c/port/cleanname.c | 10 +- sys/src/lib/c/port/encodefmt.c | 22 +- sys/src/lib/c/port/execl.c | 4 +- sys/src/lib/c/port/exp.c | 8 +- sys/src/lib/c/port/fabs.c | 2 +- sys/src/lib/c/port/floor.c | 10 +- sys/src/lib/c/port/fmod.c | 8 +- sys/src/lib/c/port/frand.c | 6 +- sys/src/lib/c/port/frexp.c | 16 +- sys/src/lib/c/port/getcallerpc.c | 2 +- sys/src/lib/c/port/getfields.c | 6 +- sys/src/lib/c/port/getuser.c | 4 +- sys/src/lib/c/port/hangup.c | 2 +- sys/src/lib/c/port/hypot.c | 4 +- sys/src/lib/c/port/lnrand.c | 4 +- sys/src/lib/c/port/lock.c | 22 +- sys/src/lib/c/port/log.c | 12 +- sys/src/lib/c/port/lrand.c | 12 +- sys/src/lib/c/port/malloc.c | 68 +-- sys/src/lib/c/port/memccpy.c | 2 +- sys/src/lib/c/port/memchr.c | 2 +- sys/src/lib/c/port/memcmp.c | 2 +- sys/src/lib/c/port/memmove.c | 6 +- sys/src/lib/c/port/memset.c | 2 +- sys/src/lib/c/port/mktemp.c | 6 +- sys/src/lib/c/port/muldiv.c | 6 +- sys/src/lib/c/port/nan.c | 10 +- sys/src/lib/c/port/needsrcquote.c | 4 +- sys/src/lib/c/port/netmkaddr.c | 16 +- sys/src/lib/c/port/nrand.c | 4 +- sys/src/lib/c/port/ntruerand.c | 4 +- sys/src/lib/c/port/perror.c | 6 +- sys/src/lib/c/port/pool.c | 20 +- sys/src/lib/c/port/pow.c | 18 +- sys/src/lib/c/port/pow10.c | 6 +- sys/src/lib/c/port/qsort.c | 2 +- sys/src/lib/c/port/quote.c | 24 +- sys/src/lib/c/port/rand.c | 4 +- sys/src/lib/c/port/readn.c | 2 +- sys/src/lib/c/port/rune.c | 12 +- sys/src/lib/c/port/runebase.c | 6 +- sys/src/lib/c/port/runestrcat.c | 4 +- sys/src/lib/c/port/runestrchr.c | 2 +- sys/src/lib/c/port/runestrcmp.c | 2 +- sys/src/lib/c/port/runestrcpy.c | 2 +- sys/src/lib/c/port/runestrdup.c | 8 +- sys/src/lib/c/port/runestrecpy.c | 2 +- sys/src/lib/c/port/runestrlen.c | 4 +- sys/src/lib/c/port/runestrncat.c | 4 +- sys/src/lib/c/port/runestrncmp.c | 2 +- sys/src/lib/c/port/runestrncpy.c | 2 +- sys/src/lib/c/port/runestrrchr.c | 6 +- sys/src/lib/c/port/runestrstr.c | 4 +- sys/src/lib/c/port/runetypebody-6.2.0.h | 18 +- sys/src/lib/c/port/sin.c | 8 +- sys/src/lib/c/port/sinh.c | 16 +- sys/src/lib/c/port/strcat.c | 4 +- sys/src/lib/c/port/strchr.c | 2 +- sys/src/lib/c/port/strcmp.c | 2 +- sys/src/lib/c/port/strcpy.c | 4 +- sys/src/lib/c/port/strcspn.c | 4 +- sys/src/lib/c/port/strdup.c | 8 +- sys/src/lib/c/port/strecpy.c | 4 +- sys/src/lib/c/port/strlen.c | 4 +- sys/src/lib/c/port/strncat.c | 2 +- sys/src/lib/c/port/strncmp.c | 2 +- sys/src/lib/c/port/strncpy.c | 2 +- sys/src/lib/c/port/strpbrk.c | 4 +- sys/src/lib/c/port/strrchr.c | 6 +- sys/src/lib/c/port/strspn.c | 4 +- sys/src/lib/c/port/strstr.c | 4 +- sys/src/lib/c/port/strtod.c | 26 +- sys/src/lib/c/port/strtok.c | 4 +- sys/src/lib/c/port/strtol.c | 2 +- sys/src/lib/c/port/strtoll.c | 2 +- sys/src/lib/c/port/strtoul.c | 2 +- sys/src/lib/c/port/strtoull.c | 2 +- sys/src/lib/c/port/tan.c | 6 +- sys/src/lib/c/port/tanh.c | 8 +- sys/src/lib/c/port/tokenize.c | 12 +- sys/src/lib/c/port/toupper.c | 4 +- sys/src/lib/c/port/u16.c | 4 +- sys/src/lib/c/port/u32.c | 8 +- sys/src/lib/c/port/u64.c | 4 +- sys/src/lib/c/port/utfecpy.c | 4 +- sys/src/lib/c/port/utflen.c | 4 +- sys/src/lib/c/port/utfnlen.c | 6 +- sys/src/lib/c/port/utfrrune.c | 6 +- sys/src/lib/c/port/utfrune.c | 6 +- sys/src/lib/c/port/utfutf.c | 12 +- sys/src/lib/complete/complete.c | 2 +- sys/src/lib/control/box.c | 2 +- sys/src/lib/control/button.c | 2 +- sys/src/lib/control/cache.c | 2 +- sys/src/lib/control/control.c | 2 +- sys/src/lib/control/entry.c | 2 +- sys/src/lib/control/group.c | 2 +- sys/src/lib/control/keyboard.c | 2 +- sys/src/lib/control/label.c | 2 +- sys/src/lib/control/menu.c | 2 +- sys/src/lib/control/radiobutton.c | 2 +- sys/src/lib/control/slider.c | 2 +- sys/src/lib/control/tabs.c | 2 +- sys/src/lib/control/text.c | 2 +- sys/src/lib/control/textbutton.c | 2 +- sys/src/lib/control/textbutton3.c | 2 +- sys/src/lib/disk/disk.c | 2 +- sys/src/lib/disk/proto.c | 2 +- sys/src/lib/disk/scsi.c | 2 +- sys/src/lib/disk/scsierrs.c | 2 +- sys/src/lib/disk/test.c | 2 +- sys/src/lib/draw/alloc.c | 2 +- sys/src/lib/draw/allocimagemix.c | 2 +- sys/src/lib/draw/arith.c | 2 +- sys/src/lib/draw/bezier.c | 2 +- sys/src/lib/draw/border.c | 2 +- sys/src/lib/draw/buildfont.c | 2 +- sys/src/lib/draw/bytesperline.c | 2 +- sys/src/lib/draw/chan.c | 2 +- sys/src/lib/draw/cloadimage.c | 2 +- sys/src/lib/draw/computil.c | 2 +- sys/src/lib/draw/creadimage.c | 2 +- sys/src/lib/draw/debug.c | 2 +- sys/src/lib/draw/defont.c | 2 +- sys/src/lib/draw/draw.c | 2 +- sys/src/lib/draw/drawrepl.c | 2 +- sys/src/lib/draw/egetrect.c | 2 +- sys/src/lib/draw/ellipse.c | 2 +- sys/src/lib/draw/emenuhit.c | 2 +- sys/src/lib/draw/event.c | 2 +- sys/src/lib/draw/fmt.c | 2 +- sys/src/lib/draw/font.c | 2 +- sys/src/lib/draw/freesubfont.c | 2 +- sys/src/lib/draw/getdefont.c | 2 +- sys/src/lib/draw/getrect.c | 2 +- sys/src/lib/draw/getsubfont.c | 2 +- sys/src/lib/draw/init.c | 2 +- sys/src/lib/draw/keyboard.c | 2 +- sys/src/lib/draw/line.c | 2 +- sys/src/lib/draw/loadimage.c | 2 +- sys/src/lib/draw/menuhit.c | 2 +- sys/src/lib/draw/mkfont.c | 2 +- sys/src/lib/draw/mouse.c | 2 +- sys/src/lib/draw/namedimage.c | 2 +- sys/src/lib/draw/newwindow.c | 2 +- sys/src/lib/draw/openfont.c | 2 +- sys/src/lib/draw/poly.c | 2 +- sys/src/lib/draw/readcolmap.c | 2 +- sys/src/lib/draw/readimage.c | 2 +- sys/src/lib/draw/readsubfont.c | 2 +- sys/src/lib/draw/rectclip.c | 2 +- sys/src/lib/draw/replclipr.c | 2 +- sys/src/lib/draw/rgb.c | 2 +- sys/src/lib/draw/scroll.c | 2 +- sys/src/lib/draw/string.c | 2 +- sys/src/lib/draw/stringbg.c | 2 +- sys/src/lib/draw/stringsubfont.c | 2 +- sys/src/lib/draw/stringwidth.c | 2 +- sys/src/lib/draw/subfont.c | 2 +- sys/src/lib/draw/subfontcache.c | 2 +- sys/src/lib/draw/subfontname.c | 2 +- sys/src/lib/draw/test.c | 2 +- sys/src/lib/draw/unloadimage.c | 2 +- sys/src/lib/draw/window.c | 2 +- sys/src/lib/draw/writecolmap.c | 2 +- sys/src/lib/draw/writeimage.c | 2 +- sys/src/lib/draw/writesubfont.c | 2 +- sys/src/lib/flate/adler.c | 2 +- sys/src/lib/flate/crc.c | 2 +- sys/src/lib/flate/deflate.c | 2 +- sys/src/lib/flate/deflateblock.c | 2 +- sys/src/lib/flate/deflatezlib.c | 2 +- sys/src/lib/flate/deflatezlibblock.c | 2 +- sys/src/lib/flate/flateerr.c | 2 +- sys/src/lib/flate/inflate.c | 2 +- sys/src/lib/flate/inflateblock.c | 2 +- sys/src/lib/flate/inflatezlib.c | 2 +- sys/src/lib/flate/inflatezlibblock.c | 2 +- sys/src/lib/frame/frbox.c | 2 +- sys/src/lib/frame/frdelete.c | 2 +- sys/src/lib/frame/frdraw.c | 2 +- sys/src/lib/frame/frinit.c | 2 +- sys/src/lib/frame/frinsert.c | 2 +- sys/src/lib/frame/frptofchar.c | 2 +- sys/src/lib/frame/frselect.c | 2 +- sys/src/lib/frame/frstr.c | 2 +- sys/src/lib/frame/frutil.c | 2 +- sys/src/lib/ip/bo.c | 2 +- sys/src/lib/ip/classmask.c | 2 +- sys/src/lib/ip/eipfmt.c | 2 +- sys/src/lib/ip/equivip.c | 2 +- sys/src/lib/ip/ipaux.c | 2 +- sys/src/lib/ip/myetheraddr.c | 2 +- sys/src/lib/ip/myipaddr.c | 2 +- sys/src/lib/ip/parseether.c | 2 +- sys/src/lib/ip/parseip.c | 2 +- sys/src/lib/ip/readipifc.c | 2 +- sys/src/lib/ip/testreadipifc.c | 2 +- sys/src/lib/memdraw/alloc.c | 28 +- sys/src/lib/memdraw/arctest.c | 22 +- sys/src/lib/memdraw/cread.c | 40 +- sys/src/lib/memdraw/defont.c | 24 +- sys/src/lib/memdraw/draw.c | 152 +++--- sys/src/lib/memdraw/drawtest.c | 246 ++++----- sys/src/lib/memdraw/ellipse.c | 6 +- sys/src/lib/memdraw/fillpoly.c | 28 +- sys/src/lib/memdraw/line.c | 2 +- sys/src/lib/memdraw/load.c | 8 +- sys/src/lib/memdraw/mkcmap.c | 38 +- sys/src/lib/memdraw/openmemsubfont.c | 18 +- sys/src/lib/memdraw/read.c | 38 +- sys/src/lib/memdraw/string.c | 4 +- sys/src/lib/memdraw/subfont.c | 8 +- sys/src/lib/memdraw/unload.c | 2 +- sys/src/lib/memdraw/write.c | 38 +- sys/src/lib/memlayer/draw.c | 2 +- sys/src/lib/memlayer/lalloc.c | 2 +- sys/src/lib/memlayer/layerop.c | 2 +- sys/src/lib/memlayer/ldelete.c | 2 +- sys/src/lib/memlayer/lhide.c | 2 +- sys/src/lib/memlayer/line.c | 2 +- sys/src/lib/memlayer/load.c | 2 +- sys/src/lib/memlayer/lorigin.c | 2 +- sys/src/lib/memlayer/lsetrefresh.c | 2 +- sys/src/lib/memlayer/ltofront.c | 2 +- sys/src/lib/memlayer/ltorear.c | 2 +- sys/src/lib/memlayer/unload.c | 2 +- sys/src/lib/mp/bigtest.c | 26 +- sys/src/lib/mp/port/betomp.c | 2 +- sys/src/lib/mp/port/cnfield.c | 8 +- sys/src/lib/mp/port/crt.c | 12 +- sys/src/lib/mp/port/crttest.c | 10 +- sys/src/lib/mp/port/gmfield.c | 12 +- sys/src/lib/mp/port/letomp.c | 2 +- sys/src/lib/mp/port/mpadd.c | 2 +- sys/src/lib/mp/port/mpaux.c | 38 +- sys/src/lib/mp/port/mpcmp.c | 2 +- sys/src/lib/mp/port/mpdiv.c | 2 +- sys/src/lib/mp/port/mpeuclid.c | 2 +- sys/src/lib/mp/port/mpexp.c | 2 +- sys/src/lib/mp/port/mpextendedgcd.c | 6 +- sys/src/lib/mp/port/mpfactorial.c | 4 +- sys/src/lib/mp/port/mpfield.c | 2 +- sys/src/lib/mp/port/mpfmt.c | 26 +- sys/src/lib/mp/port/mpmodop.c | 2 +- sys/src/lib/mp/port/mpmul.c | 10 +- sys/src/lib/mp/port/mpnrand.c | 2 +- sys/src/lib/mp/port/mprand.c | 8 +- sys/src/lib/mp/port/mpsub.c | 2 +- sys/src/lib/mp/port/mptobe.c | 8 +- sys/src/lib/mp/port/mptober.c | 2 +- sys/src/lib/mp/port/mptoi.c | 2 +- sys/src/lib/mp/port/mptole.c | 6 +- sys/src/lib/mp/port/mptolel.c | 2 +- sys/src/lib/mp/port/mptoui.c | 2 +- sys/src/lib/mp/port/mptouv.c | 2 +- sys/src/lib/mp/port/mptov.c | 2 +- sys/src/lib/mp/port/strtomp.c | 20 +- sys/src/lib/mp/test.c | 122 ++--- sys/src/lib/ndb/csgetval.c | 2 +- sys/src/lib/ndb/csipinfo.c | 2 +- sys/src/lib/ndb/dnsquery.c | 2 +- sys/src/lib/ndb/ndbaux.c | 2 +- sys/src/lib/ndb/ndbcache.c | 2 +- sys/src/lib/ndb/ndbcat.c | 2 +- sys/src/lib/ndb/ndbconcatenate.c | 2 +- sys/src/lib/ndb/ndbdiscard.c | 2 +- sys/src/lib/ndb/ndbfree.c | 2 +- sys/src/lib/ndb/ndbgetipaddr.c | 2 +- sys/src/lib/ndb/ndbgetval.c | 2 +- sys/src/lib/ndb/ndbhash.c | 2 +- sys/src/lib/ndb/ndbipinfo.c | 2 +- sys/src/lib/ndb/ndblookval.c | 2 +- sys/src/lib/ndb/ndbopen.c | 2 +- sys/src/lib/ndb/ndbparse.c | 2 +- sys/src/lib/ndb/ndbreorder.c | 2 +- sys/src/lib/ndb/ndbsubstitute.c | 2 +- sys/src/lib/plumb/event.c | 14 +- sys/src/lib/plumb/mesg.c | 2 +- sys/src/lib/plumb/plumbsendtext.c | 2 +- sys/src/lib/regexp/regaux.c | 2 +- sys/src/lib/regexp/regcomp.c | 2 +- sys/src/lib/regexp/regerror.c | 2 +- sys/src/lib/regexp/regexec.c | 2 +- sys/src/lib/regexp/regsub.c | 2 +- sys/src/lib/regexp/rregexec.c | 2 +- sys/src/lib/regexp/rregsub.c | 2 +- sys/src/lib/sec/port/aes.c | 30 +- sys/src/lib/sec/port/aes_gcm.c | 12 +- sys/src/lib/sec/port/aesgcmtest.c | 28 +- sys/src/lib/sec/port/bftest.c | 72 +-- sys/src/lib/sec/port/blowfish.c | 14 +- sys/src/lib/sec/port/ccpoly.c | 4 +- sys/src/lib/sec/port/chacha.c | 8 +- sys/src/lib/sec/port/chachatest.c | 92 ++-- sys/src/lib/sec/port/crypt.c | 2 +- sys/src/lib/sec/port/curve25519.c | 22 +- sys/src/lib/sec/port/curve25519_dh.c | 4 +- sys/src/lib/sec/port/decodepem.c | 36 +- sys/src/lib/sec/port/des3CBC.c | 4 +- sys/src/lib/sec/port/desCBC.c | 4 +- sys/src/lib/sec/port/desmodes.c | 12 +- sys/src/lib/sec/port/dh.c | 4 +- sys/src/lib/sec/port/dsaalloc.c | 18 +- sys/src/lib/sec/port/dsagen.c | 2 +- sys/src/lib/sec/port/dsaprimes.c | 6 +- sys/src/lib/sec/port/dsasign.c | 2 +- sys/src/lib/sec/port/ecc.c | 26 +- sys/src/lib/sec/port/egalloc.c | 18 +- sys/src/lib/sec/port/egtest.c | 4 +- sys/src/lib/sec/port/fastrand.c | 2 +- sys/src/lib/sec/port/genrandom.c | 10 +- sys/src/lib/sec/port/hkdf.c | 6 +- sys/src/lib/sec/port/hmac.c | 4 +- sys/src/lib/sec/port/hmactest.c | 8 +- sys/src/lib/sec/port/md4.c | 14 +- sys/src/lib/sec/port/md4test.c | 6 +- sys/src/lib/sec/port/md5.c | 14 +- sys/src/lib/sec/port/md5pickle.c | 20 +- sys/src/lib/sec/port/nfastrand.c | 2 +- sys/src/lib/sec/port/pbkdf2.c | 4 +- sys/src/lib/sec/port/poly1305.c | 14 +- sys/src/lib/sec/port/primetest.c | 12 +- sys/src/lib/sec/port/prng.c | 2 +- sys/src/lib/sec/port/probably_prime.c | 2 +- sys/src/lib/sec/port/readcert.c | 20 +- sys/src/lib/sec/port/ripemd.c | 14 +- sys/src/lib/sec/port/rsaalloc.c | 12 +- sys/src/lib/sec/port/rsafill.c | 6 +- sys/src/lib/sec/port/rsatest.c | 24 +- sys/src/lib/sec/port/salsa.c | 12 +- sys/src/lib/sec/port/sha1.c | 14 +- sys/src/lib/sec/port/sha1pickle.c | 20 +- sys/src/lib/sec/port/sha2_128.c | 16 +- sys/src/lib/sec/port/sha2_64.c | 16 +- sys/src/lib/sec/port/sha2block128.c | 2 +- sys/src/lib/sec/port/sha2block64.c | 2 +- sys/src/lib/sec/port/sha2test.c | 34 +- sys/src/lib/sec/port/thumb.c | 34 +- sys/src/lib/sec/port/tlshand.c | 348 ++++++------- sys/src/lib/sec/port/tsmemcmp.c | 2 +- sys/src/lib/sec/port/x509.c | 200 ++++---- sys/src/lib/stdio/dtoa.c | 6 +- sys/src/lib/stdio/iolib.h | 2 +- sys/src/lib/thread/channel.c | 60 +-- sys/src/lib/thread/chanprint.c | 4 +- sys/src/lib/thread/create.c | 36 +- sys/src/lib/thread/debug.c | 20 +- sys/src/lib/thread/dial.c | 50 +- sys/src/lib/thread/example.c | 16 +- sys/src/lib/thread/exec.c | 4 +- sys/src/lib/thread/exit.c | 12 +- sys/src/lib/thread/id.c | 28 +- sys/src/lib/thread/iocall.c | 4 +- sys/src/lib/thread/iodial.c | 2 +- sys/src/lib/thread/ioproc.c | 8 +- sys/src/lib/thread/ioreadn.c | 2 +- sys/src/lib/thread/iosleep.c | 2 +- sys/src/lib/thread/kill.c | 22 +- sys/src/lib/thread/lib.c | 16 +- sys/src/lib/thread/main.c | 28 +- sys/src/lib/thread/note.c | 18 +- sys/src/lib/thread/ref.c | 4 +- sys/src/lib/thread/rendez.c | 18 +- sys/src/lib/thread/sched.c | 44 +- sys/src/lib/thread/test.c | 4 +- sys/src/lib/thread/tprimes.c | 6 +- 1195 files changed, 8385 insertions(+), 7803 deletions(-) create mode 100644 sys/include/lib9.h rename sys/src/lib/c/9sys/{sbrk.c => segbrk.c} (96%) create mode 100644 sys/src/lib/c/amd64/initlib.c create mode 100644 sys/src/lib/c/lib9.c diff --git a/qa/gnu/gcc/rune.c b/qa/gnu/gcc/rune.c index a687dcc..d5b4855 100644 --- a/qa/gnu/gcc/rune.c +++ b/qa/gnu/gcc/rune.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* Test rune assignment: should not produce any warning * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 diff --git a/qa/kern/alarm.c b/qa/kern/alarm.c index 43a87a0..fb19aa9 100644 --- a/qa/kern/alarm.c +++ b/qa/kern/alarm.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* Test alarm(2): * - alarms replace each other (the last one wins) diff --git a/qa/kern/args.c b/qa/kern/args.c index f7f060b..04e0c87 100644 --- a/qa/kern/args.c +++ b/qa/kern/args.c @@ -1,5 +1,5 @@ #include -#include +#include /* * The whole regression test I am after here is to call qa/kern/args with diff --git a/qa/kern/awake.c b/qa/kern/awake.c index ce3fe30..87ce299 100644 --- a/qa/kern/awake.c +++ b/qa/kern/awake.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include int verbose = 1; diff --git a/qa/kern/brk.c b/qa/kern/brk.c index b707195..26bdbf6 100644 --- a/qa/kern/brk.c +++ b/qa/kern/brk.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include void main(void) diff --git a/qa/kern/execl.c b/qa/kern/execl.c index ae112e6..043ba56 100644 --- a/qa/kern/execl.c +++ b/qa/kern/execl.c @@ -1,5 +1,5 @@ #include -#include +#include void main(int argc, char *argv[]) diff --git a/qa/kern/float.c b/qa/kern/float.c index 68335bb..7e360a4 100644 --- a/qa/kern/float.c +++ b/qa/kern/float.c @@ -1,5 +1,5 @@ #include -#include +#include #define DPRECSTR "0.0000004000000000125" #define DPREC 0.0000004000000000125 diff --git a/qa/kern/fork.c b/qa/kern/fork.c index 67d7afd..0df2941 100644 --- a/qa/kern/fork.c +++ b/qa/kern/fork.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(void) diff --git a/qa/kern/frexp.c b/qa/kern/frexp.c index aa6e8c0..7369c45 100644 --- a/qa/kern/frexp.c +++ b/qa/kern/frexp.c @@ -1,5 +1,5 @@ #include -#include +#include #define DEEPS ".5*2^-1073" #define DENEPS "-.5*2^-1073" diff --git a/qa/kern/getmainpid.c b/qa/kern/getmainpid.c index 68fcb7b..e9df7c5 100644 --- a/qa/kern/getmainpid.c +++ b/qa/kern/getmainpid.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include void main(void) diff --git a/qa/kern/getpid.c b/qa/kern/getpid.c index 50e53b2..487edb2 100644 --- a/qa/kern/getpid.c +++ b/qa/kern/getpid.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include void main(void) diff --git a/qa/kern/getppid.c b/qa/kern/getppid.c index e6b4142..32ba9ff 100644 --- a/qa/kern/getppid.c +++ b/qa/kern/getppid.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include void main(void) diff --git a/qa/kern/iphash.c b/qa/kern/iphash.c index 0685e11..6e75ff6 100644 --- a/qa/kern/iphash.c +++ b/qa/kern/iphash.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* from the kernel. Sorry. */ diff --git a/qa/kern/malloc1GiB.c b/qa/kern/malloc1GiB.c index 7fd2a1e..fceb147 100644 --- a/qa/kern/malloc1GiB.c +++ b/qa/kern/malloc1GiB.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #define GiB 1024*1024*1024 diff --git a/qa/kern/memoryisolation.c b/qa/kern/memoryisolation.c index 049872e..5385ecc 100644 --- a/qa/kern/memoryisolation.c +++ b/qa/kern/memoryisolation.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #define MSGTPL "Hello from %d!" diff --git a/qa/kern/memoryshare.c b/qa/kern/memoryshare.c index d1c7940..58f796d 100644 --- a/qa/kern/memoryshare.c +++ b/qa/kern/memoryshare.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #define MSGTPL "Hello from %d!" diff --git a/qa/kern/mixedfloat.c b/qa/kern/mixedfloat.c index 508897b..45c8f2c 100644 --- a/qa/kern/mixedfloat.c +++ b/qa/kern/mixedfloat.c @@ -1,5 +1,5 @@ #include -#include +#include #define INT 2 #define FLOAT 2.5 diff --git a/qa/kern/noexecmem.c b/qa/kern/noexecmem.c index 9ae02c2..55101bf 100644 --- a/qa/kern/noexecmem.c +++ b/qa/kern/noexecmem.c @@ -1,5 +1,5 @@ #include -#include +#include #define RET 0xc3 int success; diff --git a/qa/kern/notify.c b/qa/kern/notify.c index 0a347e3..7881c7b 100644 --- a/qa/kern/notify.c +++ b/qa/kern/notify.c @@ -1,5 +1,5 @@ #include -#include +#include #define RET 0xc3 void diff --git a/qa/kern/nsec.c b/qa/kern/nsec.c index 3118e57..c9c344e 100644 --- a/qa/kern/nsec.c +++ b/qa/kern/nsec.c @@ -1,5 +1,5 @@ #include -#include +#include int verbose = 0; void diff --git a/qa/kern/pipering.c b/qa/kern/pipering.c index be7d4df..a9e17e8 100644 --- a/qa/kern/pipering.c +++ b/qa/kern/pipering.c @@ -1,5 +1,5 @@ #include -#include +#include int nring = 32; int niter = 1024; diff --git a/qa/kern/postnote.c b/qa/kern/postnote.c index af7b9da..0815005 100644 --- a/qa/kern/postnote.c +++ b/qa/kern/postnote.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include int verbose = 0; int procNoteReceived; diff --git a/qa/kern/psx.c b/qa/kern/psx.c index bc480dc..b5cac3e 100644 --- a/qa/kern/psx.c +++ b/qa/kern/psx.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/qa/kern/sched0.c b/qa/kern/sched0.c index f00b76a..781b90b 100644 --- a/qa/kern/sched0.c +++ b/qa/kern/sched0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that the scheduler give each process a chance to run * with a single cpu (x86) this test do not pass on plan9/9front diff --git a/qa/kern/segattach.c b/qa/kern/segattach.c index f80c1bb..599c007 100644 --- a/qa/kern/segattach.c +++ b/qa/kern/segattach.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include int verbose = 1; diff --git a/qa/kern/syscall.c b/qa/kern/syscall.c index db3051f..222afbd 100644 --- a/qa/kern/syscall.c +++ b/qa/kern/syscall.c @@ -1,6 +1,6 @@ #include -#include +#include void main(void) diff --git a/qa/kern/sysstatread.c b/qa/kern/sysstatread.c index c2d92b6..a670cd2 100644 --- a/qa/kern/sysstatread.c +++ b/qa/kern/sysstatread.c @@ -1,5 +1,5 @@ #include -#include +#include // Change-Id: I1cfd642d29a3955499b3507f56f0449d1710700e // sys/src/nxm/port/devcons.c: diff --git a/qa/kern/tsemacquire.c b/qa/kern/tsemacquire.c index 45f6124..074dfba 100644 --- a/qa/kern/tsemacquire.c +++ b/qa/kern/tsemacquire.c @@ -1,5 +1,5 @@ #include -#include +#include int32_t nprocs = 32; int32_t nloops = 10000; diff --git a/qa/kern/waserror.c b/qa/kern/waserror.c index f135fdd..81a042a 100644 --- a/qa/kern/waserror.c +++ b/qa/kern/waserror.c @@ -3,7 +3,7 @@ // -- complete // Since we're going to improve waserror #include -#include +#include void main(void) diff --git a/qa/lib/c/asmscall.c b/qa/lib/c/asmscall.c index 262ae3a..4093dbe 100644 --- a/qa/lib/c/asmscall.c +++ b/qa/lib/c/asmscall.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include int verbose = 1; diff --git a/qa/lib/c/cleanname.c b/qa/lib/c/cleanname.c index bf1d8be..c2a5160 100644 --- a/qa/lib/c/cleanname.c +++ b/qa/lib/c/cleanname.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include void main(void) diff --git a/qa/lib/c/conswrite.c b/qa/lib/c/conswrite.c index 1bfa111..de5a244 100644 --- a/qa/lib/c/conswrite.c +++ b/qa/lib/c/conswrite.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #define BUFSZ (32*1024) void diff --git a/qa/lib/c/hcube.c b/qa/lib/c/hcube.c index be74a06..e032590 100644 --- a/qa/lib/c/hcube.c +++ b/qa/lib/c/hcube.c @@ -1,5 +1,5 @@ #include -#include +#include int dim = 6; diff --git a/qa/lib/c/lockt.c b/qa/lib/c/lockt.c index 630728f..b4698b5 100644 --- a/qa/lib/c/lockt.c +++ b/qa/lib/c/lockt.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include QLock rl; Rendez rStart; @@ -85,7 +85,7 @@ main(void) resInWaiter = 0xff; spawnWaiter(&l); - lock(&l); + jehanne_lock(&l); alarm(20000); /* global timeout, FAIL if reached */ if (!atnotify(failOnTimeout, 1)){ @@ -112,7 +112,7 @@ main(void) rwakeupall(&rStart); qunlock(&rl); sleep(1200); - unlock(&l); + jehanne_unlock(&l); qlock(&rl); while(elapsedInWaiter == 0) diff --git a/qa/lib/c/longjmp.c b/qa/lib/c/longjmp.c index 853f80e..2e2fa1b 100644 --- a/qa/lib/c/longjmp.c +++ b/qa/lib/c/longjmp.c @@ -1,6 +1,6 @@ #include -#include +#include enum { Njmps = 10000 diff --git a/qa/lib/c/privates.c b/qa/lib/c/privates.c index a0d47f6..24bfa62 100644 --- a/qa/lib/c/privates.c +++ b/qa/lib/c/privates.c @@ -8,7 +8,7 @@ */ #include -#include +#include extern void **_privates; extern int _nprivates; diff --git a/qa/lib/c/privates2.c b/qa/lib/c/privates2.c index 7d8c35a..af02b54 100644 --- a/qa/lib/c/privates2.c +++ b/qa/lib/c/privates2.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include int spin; int ok[2]; diff --git a/qa/lib/c/qlockt0.c b/qa/lib/c/qlockt0.c index 0b0945b..6c8a721 100644 --- a/qa/lib/c/qlockt0.c +++ b/qa/lib/c/qlockt0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that qlockt returns 0 on timeout */ diff --git a/qa/lib/c/qlockt1.c b/qa/lib/c/qlockt1.c index 8a4b536..1066051 100644 --- a/qa/lib/c/qlockt1.c +++ b/qa/lib/c/qlockt1.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that lockt returns 1 if the lock is released and * it can take it diff --git a/qa/lib/c/qlockt2.c b/qa/lib/c/qlockt2.c index f1acfc8..052d674 100644 --- a/qa/lib/c/qlockt2.c +++ b/qa/lib/c/qlockt2.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that qlockt returns 0 even on tight timeouts */ diff --git a/qa/lib/c/rlockt0.c b/qa/lib/c/rlockt0.c index 79732de..932037b 100644 --- a/qa/lib/c/rlockt0.c +++ b/qa/lib/c/rlockt0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rlockt returns 0 on timeout */ diff --git a/qa/lib/c/rlockt1.c b/qa/lib/c/rlockt1.c index f21e2e9..9f82837 100644 --- a/qa/lib/c/rlockt1.c +++ b/qa/lib/c/rlockt1.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rlockt returns 1 if the lock is released and * it can take it diff --git a/qa/lib/c/rlockt2.c b/qa/lib/c/rlockt2.c index edec15c..2bf3310 100644 --- a/qa/lib/c/rlockt2.c +++ b/qa/lib/c/rlockt2.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rlockt returns 0 even on tight timeouts */ diff --git a/qa/lib/c/rsleept0.c b/qa/lib/c/rsleept0.c index 8fde59b..60b475a 100644 --- a/qa/lib/c/rsleept0.c +++ b/qa/lib/c/rsleept0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rsleept returns 0 on timeout */ diff --git a/qa/lib/c/rsleept1.c b/qa/lib/c/rsleept1.c index 68b1ca6..02d06f4 100644 --- a/qa/lib/c/rsleept1.c +++ b/qa/lib/c/rsleept1.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that lockt returns 1 if the lock is released and * it can take it diff --git a/qa/lib/c/rsleept2.c b/qa/lib/c/rsleept2.c index 73cdf53..314b6a1 100644 --- a/qa/lib/c/rsleept2.c +++ b/qa/lib/c/rsleept2.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rsleept returns 0 on timeout */ diff --git a/qa/lib/c/rwakeup0.c b/qa/lib/c/rwakeup0.c index 3e3b972..1f5e3ee 100644 --- a/qa/lib/c/rwakeup0.c +++ b/qa/lib/c/rwakeup0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that rwakeup returns 0 on Rendez that has already been awaken */ diff --git a/qa/lib/c/sleep.c b/qa/lib/c/sleep.c index 8faa9ea..d3d26ee 100644 --- a/qa/lib/c/sleep.c +++ b/qa/lib/c/sleep.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* Test sleep(2): * - sleep cannot be interrupted diff --git a/qa/lib/c/sqrt.c b/qa/lib/c/sqrt.c index 403de18..e3650b7 100644 --- a/qa/lib/c/sqrt.c +++ b/qa/lib/c/sqrt.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* sqrtC returns the square root of its floating diff --git a/qa/lib/c/sysfatal.c b/qa/lib/c/sysfatal.c index 158bffd..20a94be 100644 --- a/qa/lib/c/sysfatal.c +++ b/qa/lib/c/sysfatal.c @@ -1,6 +1,6 @@ #include -#include +#include void main(void) diff --git a/qa/lib/c/va_copy.c b/qa/lib/c/va_copy.c index ae69174..60f4c76 100644 --- a/qa/lib/c/va_copy.c +++ b/qa/lib/c/va_copy.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/qa/lib/c/vseprint.c b/qa/lib/c/vseprint.c index 7541f04..d089248 100644 --- a/qa/lib/c/vseprint.c +++ b/qa/lib/c/vseprint.c @@ -9,7 +9,7 @@ */ #include -#include +#include void testvseprint(char *buf, int n, char *fmt, ...) { diff --git a/qa/lib/c/wlockt0.c b/qa/lib/c/wlockt0.c index d0f9731..b7c9115 100644 --- a/qa/lib/c/wlockt0.c +++ b/qa/lib/c/wlockt0.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that wlockt returns 0 on timeout */ diff --git a/qa/lib/c/wlockt1.c b/qa/lib/c/wlockt1.c index 49a5ff5..3800085 100644 --- a/qa/lib/c/wlockt1.c +++ b/qa/lib/c/wlockt1.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that wlockt returns 1 if the lock is released and * it can take it diff --git a/qa/lib/c/wlockt2.c b/qa/lib/c/wlockt2.c index d2a96a3..3151e70 100644 --- a/qa/lib/c/wlockt2.c +++ b/qa/lib/c/wlockt2.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include /* verify that wlockt returns 0 even on tight timeouts */ diff --git a/qa/lib/thread/thread.c b/qa/lib/thread/thread.c index a671994..8a8ed51 100644 --- a/qa/lib/thread/thread.c +++ b/qa/lib/thread/thread.c @@ -1,6 +1,6 @@ #include -#include +#include #include enum diff --git a/sys/include/9P2000.h b/sys/include/9P2000.h index 3e80272..15b16fd 100644 --- a/sys/include/9P2000.h +++ b/sys/include/9P2000.h @@ -147,6 +147,7 @@ extern unsigned int convS2M(Fcall*, uint8_t*, uint); extern unsigned int sizeS2M(Fcall*); extern int statcheck(uint8_t *abuf, uint nbuf); +extern int dirfmt(Fmt *fmt); extern int fcallfmt(Fmt*); extern int read9pmsg(int, void*, uint); diff --git a/sys/include/apw/errno.h b/sys/include/apw/errno.h index e69de29..651ce97 100644 --- a/sys/include/apw/errno.h +++ b/sys/include/apw/errno.h @@ -0,0 +1,215 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2016 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#ifndef _POSIX_ERRORS +#define _POSIX_ERRORS + +typedef enum PosixError +{ + PosixE2BIG = 2, /* Argument list too long. */ + PosixEACCES, /* Permission denied. */ + PosixEADDRINUSE, /* Address in use. */ + PosixEADDRNOTAVAIL, /* Address not available. */ + PosixEAFNOSUPPORT, /* Address family not supported. */ + PosixEAGAIN, /* Resource unavailable, try again (may be the same value as [EWOULDBLOCK]). */ + PosixEALREADY, /* Connection already in progress. */ + PosixEBADF, /* Bad file descriptor. */ + PosixEBADMSG, /* Bad message. */ + PosixEBUSY, /* Device or resource busy. */ + PosixECANCELED, /* Operation canceled. */ + PosixECHILD, /* No child processes. */ + PosixECONNABORTED, /* Connection aborted. */ + PosixECONNREFUSED, /* Connection refused. */ + PosixECONNRESET, /* Connection reset. */ + PosixEDEADLK, /* Resource deadlock would occur. */ + PosixEDESTADDRREQ, /* Destination address required. */ + PosixEDOM, /* Mathematics argument out of domain of function. */ + PosixEDQUOT, /* Reserved. */ + PosixEEXIST, /* File exists. */ + PosixEFAULT, /* Bad address. */ + PosixEFBIG, /* File too large. */ + PosixEHOSTUNREACH, /* Host is unreachable. */ + PosixEIDRM, /* Identifier removed. */ + PosixEILSEQ, /* Illegal byte sequence. */ + PosixEINPROGRESS, /* Operation in progress. */ + PosixEINTR, /* Interrupted function. */ + PosixEINVAL, /* Invalid argument. */ + PosixEIO, /* I/O error. */ + PosixEISCONN, /* Socket is connected. */ + PosixEISDIR, /* Idirectory. */ + PosixELOOP, /* Too many levels of symbolic links. */ + PosixEMFILE, /* File descriptor value too large. */ + PosixEMLINK, /* Too many links. */ + PosixEMSGSIZE, /* Message too large. */ + PosixEMULTIHOP, /* Reserved. */ + PosixENAMETOOLONG, /* Filename too long. */ + PosixENETDOWN, /* Network is down. */ + PosixENETRESET, /* Connection aborted by network. */ + PosixENETUNREACH, /* Network unreachable. */ + PosixENFILE, /* Too many files open in system. */ + PosixENOBUFS, /* No buffer space available. */ + PosixENODATA, /* No message is available on the STREAM head read queue. */ + PosixENODEV, /* No such device. */ + PosixENOENT, /* No such file or directory. */ + PosixENOEXEC, /* Executable file format error. */ + PosixENOLCK, /* No locks available. */ + PosixENOLINK, /* Reserved. */ + PosixENOMEM, /* Not enough space. */ + PosixENOMSG, /* No message of the desired type. */ + PosixENOPROTOOPT, /* Protocol not available. */ + PosixENOSPC, /* No space left on device. */ + PosixENOSR, /* No STREAM resources. */ + PosixENOSTR, /* Not a STREAM. */ + PosixENOSYS, /* Functionality not supported. */ + PosixENOTCONN, /* The socket is not connected. */ + PosixENOTDIR, /* Not a directory osymbolic link tdirectory. */ + PosixENOTEMPTY, /* Directory not empty. */ + PosixENOTRECOVERABLE, /* State not recoverable. */ + PosixENOTSOCK, /* Not a socket. */ + PosixENOTSUP, /* Not supported (may be the same value as [EOPNOTSUPP]). */ + PosixENOTTY, /* Inappropriate I/O control operation. */ + PosixENXIO, /* No such device or address. */ + PosixEOPNOTSUPP, /* Operation not supported on socket (may be the same value as [ENOTSUP]). */ + PosixEOVERFLOW, /* Value too large to be stored in data type. */ + PosixEOWNERDEAD, /* Previous owner died. */ + PosixEPERM, /* Operation not permitted. */ + PosixEPIPE, /* Broken pipe. */ + PosixEPROTO, /* Protocol error. */ + PosixEPROTONOSUPPORT, /* Protocol not supported. */ + PosixEPROTOTYPE, /* Protocol wrong type for socket. */ + PosixERANGE, /* Result too large. */ + PosixEROFS, /* Read-only file system. */ + PosixESPIPE, /* Invalid seek. */ + PosixESRCH, /* No such process. */ + PosixESTALE, /* Reserved. */ + PosixETIME, /* Stream ioctl() timeout. */ + PosixETIMEDOUT, /* Connection timed out. */ + PosixETXTBSY, /* Text file busy. */ + PosixEWOULDBLOCK, /* Operation would block (may be the same value as [EAGAIN]). */ + PosixEXDEV, /* Cross-device link. */ +} PosixError; + +#define ERRNO_FIRST PosixE2BIG /* Value of the first error constant */ +#define ERRNO_LAST PosixEXDEV /* Value of the last error constant */ + +#endif + +#ifndef _ERRNO_H +#define _ERRNO_H + +extern int __errno(); +#define errno __errno() + +/* See The Open Group Base Specifications Issue 7 + * IEEE Std 1003.1-2008, 2016 Edition got from + * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html#tag_13_10 + * + * NOTES: + * None of these errno will ever be set by the Jehanne kernel. + * It's possible however that a file server designed to mimic a Unix + * behaviour use them. + * + * The value 1 is reserved since -1 is the default return value of + * failing syscalls. + * + * The constant values are continuous, thus ERRNO_FIRST and ERRNO_LAST + * can be used to create a map from errors to descriptions. + */ + +#define E2BIG PosixE2BIG +#define EACCES PosixEACCES +#define EADDRINUSE PosixEADDRINUSE +#define EADDRNOTAVAIL PosixEADDRNOTAVAIL +#define EAFNOSUPPORT PosixEAFNOSUPPORT +#define EAGAIN PosixEAGAIN +#define EALREADY PosixEALREADY +#define EBADF PosixEBADF +#define EBADMSG PosixEBADMSG +#define EBUSY PosixEBUSY +#define ECANCELED PosixECANCELED +#define ECHILD PosixECHILD +#define ECONNABORTED PosixECONNABORTED +#define ECONNREFUSED PosixECONNREFUSED +#define ECONNRESET PosixECONNRESET +#define EDEADLK PosixEDEADLK +#define EDESTADDRREQ PosixEDESTADDRREQ +#define EDOM PosixEDOM +#define EDQUOT PosixEDQUOT +#define EEXIST PosixEEXIST +#define EFAULT PosixEFAULT +#define EFBIG PosixEFBIG +#define EHOSTUNREACH PosixEHOSTUNREACH +#define EIDRM PosixEIDRM +#define EILSEQ PosixEILSEQ +#define EINPROGRESS PosixEINPROGRESS +#define EINTR PosixEINTR +#define EINVAL PosixEINVAL +#define EIO PosixEIO +#define EISCONN PosixEISCONN +#define EISDIR PosixEISDIR +#define ELOOP PosixELOOP +#define EMFILE PosixEMFILE +#define EMLINK PosixEMLINK +#define EMSGSIZE PosixEMSGSIZE +#define EMULTIHOP PosixEMULTIHOP +#define ENAMETOOLONG PosixENAMETOOLONG +#define ENETDOWN PosixENETDOWN +#define ENETRESET PosixENETRESET +#define ENETUNREACH PosixENETUNREACH +#define ENFILE PosixENFILE +#define ENOBUFS PosixENOBUFS +#define ENODATA PosixENODATA +#define ENODEV PosixENODEV +#define ENOENT PosixENOENT +#define ENOEXEC PosixENOEXEC +#define ENOLCK PosixENOLCK +#define ENOLINK PosixENOLINK +#define ENOMEM PosixENOMEM +#define ENOMSG PosixENOMSG +#define ENOPROTOOPT PosixENOPROTOOPT +#define ENOSPC PosixENOSPC +#define ENOSR PosixENOSR +#define ENOSTR PosixENOSTR +#define ENOSYS PosixENOSYS +#define ENOTCONN PosixENOTCONN +#define ENOTDIR PosixENOTDIR +#define ENOTEMPTY PosixENOTEMPTY +#define ENOTRECOVERABLE PosixENOTRECOVERABLE +#define ENOTSOCK PosixENOTSOCK +#define ENOTSUP PosixENOTSUP +#define ENOTTY PosixENOTTY +#define ENXIO PosixENXIO +#define EOPNOTSUPP PosixEOPNOTSUPP +#define EOVERFLOW PosixEOVERFLOW +#define EOWNERDEAD PosixEOWNERDEAD +#define EPERM PosixEPERM +#define EPIPE PosixEPIPE +#define EPROTO PosixEPROTO +#define EPROTONOSUPPORT PosixEPROTONOSUPPORT +#define EPROTOTYPE PosixEPROTOTYPE +#define ERANGE PosixERANGE +#define EROFS PosixEROFS +#define ESPIPE PosixESPIPE +#define ESRCH PosixESRCH +#define ESTALE PosixESTALE +#define ETIME PosixETIME +#define ETIMEDOUT PosixETIMEDOUT +#define ETXTBSY PosixETXTBSY +#define EWOULDBLOCK PosixEWOULDBLOCK +#define EXDEV PosixEXDEV + +#endif diff --git a/sys/include/apw/stdlib.h b/sys/include/apw/stdlib.h index 0176301..594768a 100644 --- a/sys/include/apw/stdlib.h +++ b/sys/include/apw/stdlib.h @@ -22,7 +22,7 @@ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 // POSIX -#define __POSIX_EXIT_PREFIX "posix exit: " +#include // to get __POSIX_EXIT_PREFIX typedef struct { int quot; diff --git a/sys/include/ip.h b/sys/include/ip.h index 9942a4a..2095586 100644 --- a/sys/include/ip.h +++ b/sys/include/ip.h @@ -192,8 +192,8 @@ uint16_t ptclbsum(uint8_t*, int); int v6tov4(uint8_t*, uint8_t*); void v4tov6(uint8_t*, uint8_t*); -#define ipcmp(x, y) memcmp(x, y, IPaddrlen) -#define ipmove(x, y) memmove(x, y, IPaddrlen) +#define ipcmp(x, y) jehanne_memcmp(x, y, IPaddrlen) +#define ipmove(x, y) jehanne_memmove(x, y, IPaddrlen) extern uint8_t IPv4bcast[IPaddrlen]; extern uint8_t IPv4bcastobs[IPaddrlen]; diff --git a/sys/include/lib9.h b/sys/include/lib9.h new file mode 100644 index 0000000..6a17cbb --- /dev/null +++ b/sys/include/lib9.h @@ -0,0 +1,310 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ + +/* lib9.h provides macros to map Plan9's libc functions to Jehanne one */ + +#include + +#define memccpy jehanne_memccpy +#define memset jehanne_memset +#define memcmp jehanne_memcmp +#define memcpy jehanne_memcpy +#define memmove jehanne_memmove +#define memchr jehanne_memchr +#define strcat jehanne_strcat +#define strchr jehanne_strchr +#define strcmp jehanne_strcmp +#define strcpy jehanne_strcpy +#define strecpy jehanne_strecpy +#define strdup jehanne_strdup +#define strncat jehanne_strncat +#define strncpy jehanne_strncpy +#define strncmp jehanne_strncmp +#define strpbrk jehanne_strpbrk +#define strrchr jehanne_strrchr +#define strtok jehanne_strtok +#define strlen jehanne_strlen +#define strspn jehanne_strspn +#define strcspn jehanne_strcspn +#define strstr jehanne_strstr +#define cistrncmp jehanne_cistrncmp +#define cistrcmp jehanne_cistrcmp +#define cistrstr jehanne_cistrstr +#define tokenize jehanne_tokenize +#define runetochar jehanne_runetochar +#define chartorune jehanne_chartorune +#define runelen jehanne_runelen +#define runenlen jehanne_runenlen +#define fullrune jehanne_fullrune +#define utflen jehanne_utflen +#define utfnlen jehanne_utfnlen +#define utfrune jehanne_utfrune +#define utfrrune jehanne_utfrrune +#define utfutf jehanne_utfutf +#define utfecpy jehanne_utfecpy +#define runestrcat jehanne_runestrcat +#define runestrchr jehanne_runestrchr +#define runestrcmp jehanne_runestrcmp +#define runestrcpy jehanne_runestrcpy +#define runestrncpy jehanne_runestrncpy +#define runestrecpy jehanne_runestrecpy +#define runestrdup jehanne_runestrdup +#define runestrncat jehanne_runestrncat +#define runestrncmp jehanne_runestrncmp +#define runestrrchr jehanne_runestrrchr +#define runestrlen jehanne_runestrlen +#define runestrstr jehanne_runestrstr +#define tolowerrune jehanne_tolowerrune +#define totitlerune jehanne_totitlerune +#define toupperrune jehanne_toupperrune +#define tobaserune jehanne_tobaserune +#define isalpharune jehanne_isalpharune +#define isbaserune jehanne_isbaserune +#define isdigitrune jehanne_isdigitrune +#define islowerrune jehanne_islowerrune +#define isspacerune jehanne_isspacerune +#define istitlerune jehanne_istitlerune +#define isupperrune jehanne_isupperrune +#define malloc jehanne_malloc +#define malloc jehanne_malloc +#define mallocz jehanne_mallocz +#define free jehanne_free +#define msize jehanne_msize +#define mallocalign jehanne_mallocalign +#define calloc jehanne_calloc +#define realloc jehanne_realloc +#define setmalloctag jehanne_setmalloctag +#define setrealloctag jehanne_setrealloctag +#define getmalloctag jehanne_getmalloctag +#define getrealloctag jehanne_getrealloctag +#define malloctopoolblock jehanne_malloctopoolblock +#define print jehanne_print +#define print jehanne_print +#define seprint jehanne_seprint +#define vseprint jehanne_vseprint +#define snprint jehanne_snprint +#define vsnprint jehanne_vsnprint +#define smprint jehanne_smprint +#define vsmprint jehanne_vsmprint +#define sprint jehanne_sprint +#define fprint jehanne_fprint +#define vfprint jehanne_vfprint +#define runesprint jehanne_runesprint +#define runesnprint jehanne_runesnprint +#define runevsnprint jehanne_runevsnprint +#define runeseprint jehanne_runeseprint +#define runevseprint jehanne_runevseprint +#define runesmprint jehanne_runesmprint +#define runevsmprint jehanne_runevsmprint +#define fmtfdinit jehanne_fmtfdinit +#define fmtfdflush jehanne_fmtfdflush +#define fmtstrinit jehanne_fmtstrinit +#define fmtstrflush jehanne_fmtstrflush +#define runefmtstrinit jehanne_runefmtstrinit +#define runefmtstrflush jehanne_runefmtstrflush +#define fmtinstall jehanne_fmtinstall +#define dofmt jehanne_dofmt +#define dorfmt jehanne_dorfmt +#define fmtprint jehanne_fmtprint +#define fmtvprint jehanne_fmtvprint +#define fmtrune jehanne_fmtrune +#define fmtstrcpy jehanne_fmtstrcpy +#define fmtrunestrcpy jehanne_fmtrunestrcpy +#define errfmt jehanne_errfmt +#define unquotestrdup jehanne_unquotestrdup +#define unquoterunestrdup jehanne_unquoterunestrdup +#define quotestrdup jehanne_quotestrdup +#define quoterunestrdup jehanne_quoterunestrdup +#define quotestrfmt jehanne_quotestrfmt +#define quoterunestrfmt jehanne_quoterunestrfmt +#define quotefmtinstall jehanne_quotefmtinstall +#define needsrcquote jehanne_needsrcquote +#define srand jehanne_srand +#define rand jehanne_rand +#define nrand jehanne_nrand +#define lrand jehanne_lrand +#define lnrand jehanne_lnrand +#define frand jehanne_frand +#define truerand jehanne_truerand +#define ntruerand jehanne_ntruerand +#define getfcr jehanne_getfcr +#define setfsr jehanne_setfsr +#define setfcr jehanne_setfcr +#define NaN jehanne_NaN +#define Inf jehanne_Inf +#define isNaN jehanne_isNaN +#define isInf jehanne_isInf +#define umuldiv jehanne_umuldiv +#define muldiv jehanne_muldiv +#define pow jehanne_pow +#define atan2 jehanne_atan2 +#define fabs jehanne_fabs +#define atan jehanne_atan +#define log jehanne_log +#define log10 jehanne_log10 +#define exp jehanne_exp +#define floor jehanne_floor +#define ceil jehanne_ceil +#define hypot jehanne_hypot +#define sin jehanne_sin +#define cos jehanne_cos +#define tan jehanne_tan +#define asin jehanne_asin +#define acos jehanne_acos +#define sinh jehanne_sinh +#define cosh jehanne_cosh +#define tanh jehanne_tanh +#define sqrt jehanne_sqrt +#define fmod jehanne_fmod +#define gmtime jehanne_gmtime +#define localtime jehanne_localtime +#define asctime jehanne_asctime +#define ctime jehanne_ctime +#define cputime jehanne_cputime +#define times jehanne_times +#define tm2sec jehanne_tm2sec +#define nsec jehanne_nsec +#define _assert jehanne__assert +#define abs jehanne_abs +#define atexit jehanne_atexit +#define atexitdont jehanne_atexitdont +#define atnotify jehanne_atnotify +#define atof jehanne_atof +#define atoi jehanne_atoi +#define atol jehanne_atol +#define atoll jehanne_atoll +#define charstod jehanne_charstod +#define chdir jehanne_chdir +#define cleanname jehanne_cleanname +#define dec64 jehanne_dec64 +#define enc64 jehanne_enc64 +#define dec32 jehanne_dec32 +#define enc32 jehanne_enc32 +#define dec16 jehanne_dec16 +#define enc16 jehanne_enc16 +#define encodefmt jehanne_encodefmt +#define exits jehanne_exits +#define frexp jehanne_frexp +#define getcallerpc jehanne_getcallerpc +#define getenv jehanne_getenv +#define getfields jehanne_getfields +#define gettokens jehanne_gettokens +#define getuser jehanne_getuser +#define getwd jehanne_getwd +#define iounit jehanne_iounit +#define labs jehanne_labs +#define ldexp jehanne_ldexp +#define longjmp jehanne_longjmp +#define mktemp jehanne_mktemp +#define modf jehanne_modf +#define notejmp jehanne_notejmp +#define nsec jehanne_nsec +#define dup jehanne_dup +#define ocreate jehanne_ocreate +#define perror jehanne_perror +#define pipe jehanne_pipe +#define postnote jehanne_postnote +#define pow10 jehanne_pow10 +#define putenv jehanne_putenv +#define qsort jehanne_qsort +#define bsearch jehanne_bsearch +#define setjmp jehanne_setjmp +#define strtod jehanne_strtod +#define strtol jehanne_strtol +#define strtoul jehanne_strtoul +#define strtoll jehanne_strtoll +#define strtoull jehanne_strtoull +#define sysfatal jehanne_sysfatal +#define syslog jehanne_syslog +#define time jehanne_time +#define tolower jehanne_tolower +#define toupper jehanne_toupper +#define ainc jehanne_ainc +#define adec jehanne_adec +#define _tas jehanne__tas +#define lock jehanne_lock +#define lockt jehanne_lockt +#define unlock jehanne_unlock +#define canlock jehanne_canlock +#define lock; jehanne_lock; +#define qlock jehanne_qlock +#define qlockt jehanne_qlockt +#define qunlock jehanne_qunlock +#define canqlock jehanne_canqlock +#define _qlockinit jehanne__qlockinit +#define lock; jehanne_lock; +#define rlock jehanne_rlock +#define rlockt jehanne_rlockt +#define runlock jehanne_runlock +#define canrlock jehanne_canrlock +#define wlock jehanne_wlock +#define wlockt jehanne_wlockt +#define wunlock jehanne_wunlock +#define canwlock jehanne_canwlock +#define rsleep jehanne_rsleep +#define rsleept jehanne_rsleept +#define rwakeup jehanne_rwakeup +#define rwakeupall jehanne_rwakeupall +#define privalloc jehanne_privalloc +#define accept jehanne_accept +#define announce jehanne_announce +#define dial jehanne_dial +#define setnetmtpt jehanne_setnetmtpt +#define hangup jehanne_hangup +#define listen jehanne_listen +#define netmkaddr jehanne_netmkaddr +#define reject jehanne_reject +#define pushssl jehanne_pushssl +#define pushtls jehanne_pushtls +#define getnetconninfo jehanne_getnetconninfo +#define freenetconninfo jehanne_freenetconninfo +#define access jehanne_access +#define awakened jehanne_awakened +#define brk jehanne_brk +#define execl jehanne_execl +#define forgivewkp jehanne_forgivewkp +#define fork jehanne_fork +#define readn jehanne_readn +#define segbrk jehanne_segbrk +#define segbrk jehanne_segbrk +#define segattach jehanne_segattach +#define segdetach jehanne_segdetach +#define segfree jehanne_segfree +#define sleep jehanne_sleep +#define stat jehanne_stat +#define wait jehanne_wait +#define waitpid jehanne_waitpid +#define wstat jehanne_wstat +#define dirstat jehanne_dirstat +#define dirfstat jehanne_dirfstat +#define dirwstat jehanne_dirwstat +#define dirfwstat jehanne_dirfwstat +#define dirread jehanne_dirread +#define nulldir jehanne_nulldir +#define dirreadall jehanne_dirreadall +#define getpid jehanne_getpid +#define getppid jehanne_getppid +#define getmainpid jehanne_getmainpid +#define rerrstr jehanne_rerrstr +#define sysname jehanne_sysname +#define werrstr jehanne_werrstr +#define convM2D jehanne_convM2D +#define convD2M jehanne_convD2M +#define sizeD2M jehanne_sizeD2M +#define dirmodefmt jehanne_dirmodefmt +#define chartorune jehanne_chartorune diff --git a/sys/include/libc.h b/sys/include/libc.h index e40e300..de36b13 100644 --- a/sys/include/libc.h +++ b/sys/include/libc.h @@ -16,7 +16,7 @@ #define nelem(x) (sizeof(x)/sizeof((x)[0])) #define offsetof(s, m) (uintptr_t)(&(((s*)0)->m)) -#define assert(x) if(x){}else _assert(#x) +#define assert(x) if(x){}else jehanne__assert(#x) extern void (*_abort)(void); #define abort() if(_abort){_abort();}else{while(*(int*)0);} @@ -24,36 +24,36 @@ extern void (*_abort)(void); /* * mem routines */ -extern void* memccpy(void*, const void*, int, uint32_t); -extern void* memset(void*, int, uint32_t); -extern int memcmp(const void*, const void*, uint32_t); -extern void* memcpy(void*, const void*, size_t); -extern void* memmove(void*, const void*, size_t); -extern void* memchr(const void*, int, uint32_t); +extern void* jehanne_memccpy(void*, const void*, int, uint32_t); +extern void* jehanne_memset(void*, int, uint32_t); +extern int jehanne_memcmp(const void*, const void*, uint32_t); +extern void* jehanne_memcpy(void*, const void*, size_t); +extern void* jehanne_memmove(void*, const void*, size_t); +extern void* jehanne_memchr(const void*, int, uint32_t); /* * string routines */ -extern char* strcat(char*, const char*); -extern char* strchr(const char*, int); -extern int strcmp(const char*, const char*); -extern char* strcpy(char*, const char*); -extern char* strecpy(char*, char *, const char*); -extern char* strdup(const char*); -extern char* strncat(char*, const char*, int32_t); -extern char* strncpy(char*, const char*, uint32_t); -extern int strncmp(const char*, const char*, int32_t); -extern char* strpbrk(const char*, const char*); -extern char* strrchr(const char*, int); -extern char* strtok(char*, char*); -extern int strlen(const char*); -extern int32_t strspn(const char*, const char*); -extern int32_t strcspn(const char*, const char*); -extern char* strstr(const char*, const char*); -extern int cistrncmp(const char*, const char*, int); -extern int cistrcmp(const char*, const char*); -extern char* cistrstr(const char*, const char*); -extern int tokenize(char*, char**, int); +extern char* jehanne_strcat(char*, const char*); +extern char* jehanne_strchr(const char*, int); +extern int jehanne_strcmp(const char*, const char*); +extern char* jehanne_strcpy(char*, const char*); +extern char* jehanne_strecpy(char*, char *, const char*); +extern char* jehanne_strdup(const char*); +extern char* jehanne_strncat(char*, const char*, int32_t); +extern char* jehanne_strncpy(char*, const char*, uint32_t); +extern int jehanne_strncmp(const char*, const char*, int32_t); +extern char* jehanne_strpbrk(const char*, const char*); +extern char* jehanne_strrchr(const char*, int); +extern char* jehanne_strtok(char*, char*); +extern int jehanne_strlen(const char*); +extern int32_t jehanne_strspn(const char*, const char*); +extern int32_t jehanne_strcspn(const char*, const char*); +extern char* jehanne_strstr(const char*, const char*); +extern int jehanne_cistrncmp(const char*, const char*, int); +extern int jehanne_cistrcmp(const char*, const char*); +extern char* jehanne_cistrstr(const char*, const char*); +extern int jehanne_tokenize(char*, char**, int); enum { @@ -68,58 +68,58 @@ enum /* * rune routines */ -extern int runetochar(char*, const Rune*); -extern int chartorune(Rune*, const char*); -extern int runelen(Rune); -extern int runenlen(const Rune*, int); -extern int fullrune(const char*, int); -extern int utflen(const char*); -extern int utfnlen(const char*, int32_t); -extern char* utfrune(const char*, Rune); -extern char* utfrrune(const char*, Rune); -extern char* utfutf(const char*, const char*); -extern char* utfecpy(char*, char *, const char*); +extern int jehanne_runetochar(char*, const Rune*); +extern int jehanne_chartorune(Rune*, const char*); +extern int jehanne_runelen(Rune); +extern int jehanne_runenlen(const Rune*, int); +extern int jehanne_fullrune(const char*, int); +extern int jehanne_utflen(const char*); +extern int jehanne_utfnlen(const char*, int32_t); +extern char* jehanne_utfrune(const char*, Rune); +extern char* jehanne_utfrrune(const char*, Rune); +extern char* jehanne_utfutf(const char*, const char*); +extern char* jehanne_utfecpy(char*, char *, const char*); -extern Rune* runestrcat(Rune*, const Rune*); -extern Rune* runestrchr(const Rune*, Rune); -extern int runestrcmp(const Rune*, const Rune*); -extern Rune* runestrcpy(Rune*, const Rune*); -extern Rune* runestrncpy(Rune*, const Rune*, int32_t); -extern Rune* runestrecpy(Rune*, Rune*, const Rune*); -extern Rune* runestrdup(const Rune*); -extern Rune* runestrncat(Rune*, const Rune*, int32_t); -extern int runestrncmp(const Rune*, const Rune*, int32_t); -extern Rune* runestrrchr(const Rune*, Rune); -extern int32_t runestrlen(const Rune*); -extern Rune* runestrstr(const Rune*, const Rune*); +extern Rune* jehanne_runestrcat(Rune*, const Rune*); +extern Rune* jehanne_runestrchr(const Rune*, Rune); +extern int jehanne_runestrcmp(const Rune*, const Rune*); +extern Rune* jehanne_runestrcpy(Rune*, const Rune*); +extern Rune* jehanne_runestrncpy(Rune*, const Rune*, int32_t); +extern Rune* jehanne_runestrecpy(Rune*, Rune*, const Rune*); +extern Rune* jehanne_runestrdup(const Rune*); +extern Rune* jehanne_runestrncat(Rune*, const Rune*, int32_t); +extern int jehanne_runestrncmp(const Rune*, const Rune*, int32_t); +extern Rune* jehanne_runestrrchr(const Rune*, Rune); +extern int32_t jehanne_runestrlen(const Rune*); +extern Rune* jehanne_runestrstr(const Rune*, const Rune*); -extern Rune tolowerrune(Rune); -extern Rune totitlerune(Rune); -extern Rune toupperrune(Rune); -extern Rune tobaserune(Rune); -extern int isalpharune(Rune); -extern int isbaserune(Rune); -extern int isdigitrune(Rune); -extern int islowerrune(Rune); -extern int isspacerune(Rune); -extern int istitlerune(Rune); -extern int isupperrune(Rune); +extern Rune jehanne_tolowerrune(Rune); +extern Rune jehanne_totitlerune(Rune); +extern Rune jehanne_toupperrune(Rune); +extern Rune jehanne_tobaserune(Rune); +extern int jehanne_isalpharune(Rune); +extern int jehanne_isbaserune(Rune); +extern int jehanne_isdigitrune(Rune); +extern int jehanne_islowerrune(Rune); +extern int jehanne_isspacerune(Rune); +extern int jehanne_istitlerune(Rune); +extern int jehanne_isupperrune(Rune); /* * malloc */ -extern void* malloc(size_t); -extern void* mallocz(uint32_t, int); -extern void free(void*); -extern uint32_t msize(void*); -extern void* mallocalign(uint32_t, uint32_t, int32_t, uint32_t); -extern void* calloc(uint32_t, size_t); -extern void* realloc(void*, size_t); -void setmalloctag(void*, uintptr_t); -void setrealloctag(void*, uintptr_t); -uintptr_t getmalloctag(void*); -uintptr_t getrealloctag(void*); -void* malloctopoolblock(void*); +extern void* jehanne_malloc(size_t); +extern void* jehanne_mallocz(uint32_t, int); +extern void jehanne_free(void*); +extern uint32_t jehanne_msize(void*); +extern void* jehanne_mallocalign(uint32_t, uint32_t, int32_t, uint32_t); +extern void* jehanne_calloc(uint32_t, size_t); +extern void* jehanne_realloc(void*, size_t); +void jehanne_setmalloctag(void*, uintptr_t); +void jehanne_setrealloctag(void*, uintptr_t); +uintptr_t jehanne_getmalloctag(void*); +uintptr_t jehanne_getrealloctag(void*); +void* jehanne_malloctopoolblock(void*); /* * print routines @@ -158,164 +158,105 @@ enum{ FmtFlag = FmtByte << 1 }; -extern int print(const char*, ...); -extern char* seprint(char*, char*, const char*, ...); -extern char* vseprint(char*, char*, const char*, va_list); -extern int snprint(char*, int, const char*, ...); -extern int vsnprint(char*, int, const char*, va_list); -extern char* smprint(const char*, ...); -extern char* vsmprint(const char*, va_list); -extern int sprint(char*, const char*, ...); -extern int fprint(int, const char*, ...); -extern int vfprint(int, const char*, va_list); +extern int jehanne_print(const char*, ...); +extern char* jehanne_seprint(char*, char*, const char*, ...); +extern char* jehanne_vseprint(char*, char*, const char*, va_list); +extern int jehanne_snprint(char*, int, const char*, ...); +extern int jehanne_vsnprint(char*, int, const char*, va_list); +extern char* jehanne_smprint(const char*, ...); +extern char* jehanne_vsmprint(const char*, va_list); +extern int jehanne_sprint(char*, const char*, ...); +extern int jehanne_fprint(int, const char*, ...); +extern int jehanne_vfprint(int, const char*, va_list); -extern int runesprint(Rune*, const char*, ...); -extern int runesnprint(Rune*, int, const char*, ...); -extern int runevsnprint(Rune*, int, const char*, va_list); -extern Rune* runeseprint(Rune*, Rune*, const char*, ...); -extern Rune* runevseprint(Rune*, Rune*, const char*, va_list); -extern Rune* runesmprint(const char*, ...); -extern Rune* runevsmprint(const char*, va_list); +extern int jehanne_runesprint(Rune*, const char*, ...); +extern int jehanne_runesnprint(Rune*, int, const char*, ...); +extern int jehanne_runevsnprint(Rune*, int, const char*, va_list); +extern Rune* jehanne_runeseprint(Rune*, Rune*, const char*, ...); +extern Rune* jehanne_runevseprint(Rune*, Rune*, const char*, va_list); +extern Rune* jehanne_runesmprint(const char*, ...); +extern Rune* jehanne_runevsmprint(const char*, va_list); -extern int fmtfdinit(Fmt*, int, char*, int); -extern int fmtfdflush(Fmt*); -extern int fmtstrinit(Fmt*); -extern char* fmtstrflush(Fmt*); -extern int runefmtstrinit(Fmt*); -extern Rune* runefmtstrflush(Fmt*); +extern int jehanne_fmtfdinit(Fmt*, int, char*, int); +extern int jehanne_fmtfdflush(Fmt*); +extern int jehanne_fmtstrinit(Fmt*); +extern char* jehanne_fmtstrflush(Fmt*); +extern int jehanne_runefmtstrinit(Fmt*); +extern Rune* jehanne_runefmtstrflush(Fmt*); -#pragma varargck argpos fmtprint 2 -#pragma varargck argpos fprint 2 -#pragma varargck argpos print 1 -#pragma varargck argpos runeseprint 3 -#pragma varargck argpos runesmprint 1 -#pragma varargck argpos runesnprint 3 -#pragma varargck argpos runesprint 2 -#pragma varargck argpos seprint 3 -#pragma varargck argpos smprint 1 -#pragma varargck argpos snprint 3 -#pragma varargck argpos sprint 2 - -#pragma varargck type "lld" vlong -#pragma varargck type "llo" vlong -#pragma varargck type "llx" vlong -#pragma varargck type "llb" vlong -#pragma varargck type "lld" uvlong -#pragma varargck type "llo" uvlong -#pragma varargck type "llx" uvlong -#pragma varargck type "llb" uvlong -#pragma varargck type "ld" long -#pragma varargck type "lo" long -#pragma varargck type "lx" long -#pragma varargck type "lb" long -#pragma varargck type "ld" ulong -#pragma varargck type "lo" ulong -#pragma varargck type "lx" ulong -#pragma varargck type "lb" ulong -#pragma varargck type "d" int -#pragma varargck type "o" int -#pragma varargck type "x" int -#pragma varargck type "c" int -#pragma varargck type "C" int -#pragma varargck type "b" int -#pragma varargck type "d" uint32_t -#pragma varargck type "x" uint32_t -#pragma varargck type "c" uint32_t -#pragma varargck type "C" uint32_t -#pragma varargck type "b" uint32_t -#pragma varargck type "f" double -#pragma varargck type "e" double -#pragma varargck type "g" double -#pragma varargck type "s" char* -#pragma varargck type "q" char* -#pragma varargck type "S" Rune* -#pragma varargck type "Q" Rune* -#pragma varargck type "r" void -#pragma varargck type "%" void -#pragma varargck type "n" int* -#pragma varargck type "p" uintptr_t -#pragma varargck type "p" void* -#pragma varargck flag ',' -#pragma varargck flag ' ' -#pragma varargck flag 'h' -#pragma varargck type "<" void* -#pragma varargck type "[" void* -#pragma varargck type "H" void* -#pragma varargck type "lH" void* - -extern int fmtinstall(int, int (*)(Fmt*)); -extern int dofmt(Fmt*, const char*); -extern int dorfmt(Fmt*, const Rune*); -extern int fmtprint(Fmt*, const char*, ...); -extern int fmtvprint(Fmt*, const char*, va_list); -extern int fmtrune(Fmt*, int); -extern int fmtstrcpy(Fmt*, const char*); -extern int fmtrunestrcpy(Fmt*, const Rune*); +extern int jehanne_fmtinstall(int, int (*)(Fmt*)); +extern int jehanne_dofmt(Fmt*, const char*); +extern int jehanne_dorfmt(Fmt*, const Rune*); +extern int jehanne_fmtprint(Fmt*, const char*, ...); +extern int jehanne_fmtvprint(Fmt*, const char*, va_list); +extern int jehanne_fmtrune(Fmt*, int); +extern int jehanne_fmtstrcpy(Fmt*, const char*); +extern int jehanne_fmtrunestrcpy(Fmt*, const Rune*); /* * error string for %r * supplied on per os basis, not part of fmt library */ -extern int errfmt(Fmt *f); +extern int jehanne_errfmt(Fmt *f); /* * quoted strings */ -extern char *unquotestrdup(const char*); -extern Rune *unquoterunestrdup(const Rune*); -extern char *quotestrdup(const char*); -extern Rune *quoterunestrdup(const Rune*); -extern int quotestrfmt(Fmt*); -extern int quoterunestrfmt(Fmt*); -extern void quotefmtinstall(void); +extern char *jehanne_unquotestrdup(const char*); +extern Rune *jehanne_unquoterunestrdup(const Rune*); +extern char *jehanne_quotestrdup(const char*); +extern Rune *jehanne_quoterunestrdup(const Rune*); +extern int jehanne_quotestrfmt(Fmt*); +extern int jehanne_quoterunestrfmt(Fmt*); +extern void jehanne_quotefmtinstall(void); extern int (*doquote)(int); -extern int needsrcquote(int); +extern int jehanne_needsrcquote(int); /* * random number */ -extern void srand(int32_t); -extern int rand(void); -extern int nrand(int); -extern int32_t lrand(void); -extern int32_t lnrand(int32_t); -extern double frand(void); -extern uint32_t truerand(void); /* uses /dev/random */ -extern uint32_t ntruerand(uint32_t); /* uses /dev/random */ +extern void jehanne_srand(int32_t); +extern int jehanne_rand(void); +extern int jehanne_nrand(int); +extern int32_t jehanne_lrand(void); +extern int32_t jehanne_lnrand(int32_t); +extern double jehanne_frand(void); +extern uint32_t jehanne_truerand(void); /* uses /dev/random */ +extern uint32_t jehanne_ntruerand(uint32_t); /* uses /dev/random */ /* * math */ -extern uint32_t getfcr(void); -extern void setfsr(uint32_t); +extern uint32_t jehanne_getfcr(void); +extern void jehanne_setfsr(uint32_t); extern uint32_t getfsr(void); -extern void setfcr(uint32_t); -extern double NaN(void); -extern double Inf(int); -extern int isNaN(double); -extern int isInf(double, int); -extern uint32_t umuldiv(uint32_t, uint32_t, uint32_t); -extern int32_t muldiv(int32_t, int32_t, int32_t); +extern void jehanne_setfcr(uint32_t); +extern double jehanne_NaN(void); +extern double jehanne_Inf(int); +extern int jehanne_isNaN(double); +extern int jehanne_isInf(double, int); +extern uint32_t jehanne_umuldiv(uint32_t, uint32_t, uint32_t); +extern int32_t jehanne_muldiv(int32_t, int32_t, int32_t); -extern double pow(double, double); -extern double atan2(double, double); -extern double fabs(double); -extern double atan(double); -extern double log(double); -extern double log10(double); -extern double exp(double); -extern double floor(double); -extern double ceil(double); -extern double hypot(double, double); -extern double sin(double); -extern double cos(double); -extern double tan(double); -extern double asin(double); -extern double acos(double); -extern double sinh(double); -extern double cosh(double); -extern double tanh(double); -extern double sqrt(double); -extern double fmod(double, double); +extern double jehanne_pow(double, double); +extern double jehanne_atan2(double, double); +extern double jehanne_fabs(double); +extern double jehanne_atan(double); +extern double jehanne_log(double); +extern double jehanne_log10(double); +extern double jehanne_exp(double); +extern double jehanne_floor(double); +extern double jehanne_ceil(double); +extern double jehanne_hypot(double, double); +extern double jehanne_sin(double); +extern double jehanne_cos(double); +extern double jehanne_tan(double); +extern double jehanne_asin(double); +extern double jehanne_acos(double); +extern double jehanne_sinh(double); +extern double jehanne_cosh(double); +extern double jehanne_tanh(double); +extern double jehanne_sqrt(double); +extern double jehanne_fmod(double, double); #define HUGE 3.4028234e38 #define PIO2 1.570796326794896619231e0 @@ -340,14 +281,14 @@ struct Tm int tzoff; } Tm; -extern Tm* gmtime(int32_t); -extern Tm* localtime(int32_t); -extern char* asctime(Tm*); -extern char* ctime(int32_t); -extern double cputime(void); -extern int32_t times(int32_t*); -extern int32_t tm2sec(Tm*); -//extern int64_t nsec(void); +extern Tm* jehanne_gmtime(int32_t); +extern Tm* jehanne_localtime(int32_t); +extern char* jehanne_asctime(Tm*); +extern char* jehanne_ctime(int32_t); +extern double jehanne_cputime(void); +extern int32_t jehanne_times(int32_t*); +extern int32_t jehanne_tm2sec(Tm*); +//extern int64_t jehanne_nsec(void); extern void cycles(uint64_t*); /* 64-bit value of the cycle counter if there is one, 0 if there isn't */ @@ -360,73 +301,71 @@ enum PNGROUP = 2, }; -extern void _assert(const char*) __attribute__ ((noreturn)); -extern int abs(int); -extern int atexit(void(*)(void)); -extern void atexitdont(void(*)(void)); -extern int atnotify(int(*)(void*, char*), int); -extern double atof(const char*); -extern int atoi(const char*); -extern int32_t atol(const char*); -extern int64_t atoll(const char*); -extern double charstod(int(*)(void*), void*); -extern int chdir(const char *dirname); -extern char* cleanname(char*); +extern void jehanne__assert(const char*) __attribute__ ((noreturn)); +extern int jehanne_abs(int); +extern int jehanne_atexit(void(*)(void)); +extern void jehanne_atexitdont(void(*)(void)); +extern int jehanne_atnotify(int(*)(void*, char*), int); +extern double jehanne_atof(const char*); +extern int jehanne_atoi(const char*); +extern int32_t jehanne_atol(const char*); +extern int64_t jehanne_atoll(const char*); +extern double jehanne_charstod(int(*)(void*), void*); +extern int jehanne_chdir(const char *dirname); +extern char* jehanne_cleanname(char*); extern int decrypt(void*, void*, int); extern int encrypt(void*, void*, int); -extern int dec64(uint8_t*, int, const char*, int); -extern int enc64(char*, int, const uint8_t*, int); -extern int dec32(uint8_t*, int, const char*, int); -extern int enc32(char*, int, const uint8_t*, int); -extern int dec16(uint8_t*, int, const char*, int); -extern int enc16(char*, int, const uint8_t*, int); -extern int encodefmt(Fmt*); -extern void exits(const char*) __attribute__ ((noreturn)); -extern double frexp(double, int*); -extern uintptr_t getcallerpc(void); -extern char* getenv(const char*); -extern int getfields(char*, char**, int, int, const char*); -extern int gettokens(char *, char **, int, const char *); -extern char* getuser(void); -extern long getwd(char*, int); -extern int iounit(int); -extern int32_t labs(int32_t); -extern double ldexp(double, int); -extern void longjmp(jmp_buf, int); -extern char* mktemp(char*); -extern double modf(double, double*); -extern void notejmp(void*, jmp_buf, int); -extern unsigned long nsec(void); -extern int dup(int oldfd, int newfd); -extern int ocreate(const char* path, unsigned int omode, unsigned int perm); -extern void perror(const char*); -extern int pipe(int pipes[2]); -extern int postnote(int, int, const char *); -extern double pow10(int); -extern int putenv(const char*, const char*); -extern void qsort(void*, long, int, +extern int jehanne_dec64(uint8_t*, int, const char*, int); +extern int jehanne_enc64(char*, int, const uint8_t*, int); +extern int jehanne_dec32(uint8_t*, int, const char*, int); +extern int jehanne_enc32(char*, int, const uint8_t*, int); +extern int jehanne_dec16(uint8_t*, int, const char*, int); +extern int jehanne_enc16(char*, int, const uint8_t*, int); +extern int jehanne_encodefmt(Fmt*); +extern void jehanne_exits(const char*) __attribute__ ((noreturn)); +extern double jehanne_frexp(double, int*); +extern uintptr_t jehanne_getcallerpc(void); +extern char* jehanne_getenv(const char*); +extern int jehanne_getfields(char*, char**, int, int, const char*); +extern int jehanne_gettokens(char *, char **, int, const char *); +extern char* jehanne_getuser(void); +extern long jehanne_getwd(char*, int); +extern int jehanne_iounit(int); +extern int32_t jehanne_labs(int32_t); +extern double jehanne_ldexp(double, int); +extern void jehanne_longjmp(jmp_buf, int); +extern char* jehanne_mktemp(char*); +extern double jehanne_modf(double, double*); +extern void jehanne_notejmp(void*, jmp_buf, int); +extern unsigned long jehanne_nsec(void); +extern int jehanne_dup(int oldfd, int newfd); +extern int jehanne_ocreate(const char* path, unsigned int omode, unsigned int perm); +extern void jehanne_perror(const char*); +extern int jehanne_pipe(int pipes[2]); +extern int jehanne_postnote(int, int, const char *); +extern double jehanne_pow10(int); +extern int jehanne_putenv(const char*, const char*); +extern void jehanne_qsort(void*, long, int, int (*)(const void*, const void*)); -extern void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, +extern void* jehanne_bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); -extern int setjmp(jmp_buf); -extern double strtod(const char*, const char**); -extern int32_t strtol(const char*, char**, int); -extern uint32_t strtoul(const char*, char**, int); -extern int64_t strtoll(const char*, char**, int); -extern uint64_t strtoull(const char*, char**, int); -extern void sysfatal(const char*, ...); -#pragma varargck argpos sysfatal 1 -extern void syslog(int, const char*, const char*, ...); -#pragma varargck argpos syslog 3 -extern int32_t time(int32_t*); -extern int tolower(int); -extern int toupper(int); +extern int jehanne_setjmp(jmp_buf); +extern double jehanne_strtod(const char*, const char**); +extern int32_t jehanne_strtol(const char*, char**, int); +extern uint32_t jehanne_strtoul(const char*, char**, int); +extern int64_t jehanne_strtoll(const char*, char**, int); +extern uint64_t jehanne_strtoull(const char*, char**, int); +extern void jehanne_sysfatal(const char*, ...); +extern void jehanne_syslog(int, const char*, const char*, ...); +extern int32_t jehanne_time(int32_t*); +extern int jehanne_tolower(int); +extern int jehanne_toupper(int); /* * atomic */ -int32_t ainc(int32_t*); -int32_t adec(int32_t*); +int32_t jehanne_ainc(int32_t*); +int32_t jehanne_adec(int32_t*); #define cas(ptr, oldval, newval) __sync_bool_compare_and_swap(ptr, oldval, newval) #define casv(ptr, oldval, newval) __sync_val_compare_and_swap(ptr, oldval, newval) @@ -439,12 +378,12 @@ struct Lock { int32_t sem; } Lock; -extern int _tas(int*); +extern int jehanne__tas(int*); -extern void lock(Lock*); -extern int lockt(Lock*, uint32_t); -extern void unlock(Lock*); -extern int canlock(Lock*); +extern void jehanne_lock(Lock*); +extern int jehanne_lockt(Lock*, uint32_t); +extern void jehanne_unlock(Lock*); +extern int jehanne_canlock(Lock*); typedef struct QLp QLp; struct QLp @@ -462,11 +401,11 @@ struct QLock QLp *tail; } QLock; -extern void qlock(QLock*); -extern int qlockt(QLock*, uint32_t); -extern void qunlock(QLock*); -extern int canqlock(QLock*); -extern void _qlockinit(void* (*)(void*, void*)); /* called only by the thread library */ +extern void jehanne_qlock(QLock*); +extern int jehanne_qlockt(QLock*, uint32_t); +extern void jehanne_qunlock(QLock*); +extern int jehanne_canqlock(QLock*); +extern void jehanne__qlockinit(void* (*)(void*, void*)); /* called only by the thread library */ typedef struct RWLock @@ -478,14 +417,14 @@ struct RWLock QLp *tail; } RWLock; -extern void rlock(RWLock*); -extern int rlockt(RWLock*, uint32_t); -extern void runlock(RWLock*); -extern int canrlock(RWLock*); -extern void wlock(RWLock*); -extern int wlockt(RWLock*, uint32_t); -extern void wunlock(RWLock*); -extern int canwlock(RWLock*); +extern void jehanne_rlock(RWLock*); +extern int jehanne_rlockt(RWLock*, uint32_t); +extern void jehanne_runlock(RWLock*); +extern int jehanne_canrlock(RWLock*); +extern void jehanne_wlock(RWLock*); +extern int jehanne_wlockt(RWLock*, uint32_t); +extern void jehanne_wunlock(RWLock*); +extern int jehanne_canwlock(RWLock*); typedef struct Rendez @@ -495,31 +434,31 @@ struct Rendez QLp *tail; } Rendez; -extern void rsleep(Rendez*); /* unlocks r->l, sleeps, locks r->l again */ -extern int rsleept(Rendez*, uint32_t); /* unlocks r->l, sleeps (up to ms), locks r->l again (if not timedout) */ -extern int rwakeup(Rendez*); -extern int rwakeupall(Rendez*); -extern void** privalloc(void); +extern void jehanne_rsleep(Rendez*); /* unlocks r->l, sleeps, locks r->l again */ +extern int jehanne_rsleept(Rendez*, uint32_t); /* unlocks r->l, sleeps (up to ms), locks r->l again (if not timedout) */ +extern int jehanne_rwakeup(Rendez*); +extern int jehanne_rwakeupall(Rendez*); +extern void** jehanne_privalloc(void); /* * network dialing */ #define NETPATHLEN 40 -extern int accept(int, const char*); -extern int announce(const char*, char*); -extern int dial(const char*, const char*, char*, int*); -extern void setnetmtpt(char*, int, const char*); -extern int hangup(int); -extern int listen(const char*, char*); -extern char* netmkaddr(const char*, const char*, const char*); -extern int reject(int, const char*, const char*); +extern int jehanne_accept(int, const char*); +extern int jehanne_announce(const char*, char*); +extern int jehanne_dial(const char*, const char*, char*, int*); +extern void jehanne_setnetmtpt(char*, int, const char*); +extern int jehanne_hangup(int); +extern int jehanne_listen(const char*, char*); +extern char* jehanne_netmkaddr(const char*, const char*, const char*); +extern int jehanne_reject(int, const char*, const char*); /* * encryption */ -extern int pushssl(int, const char*, const char*, const char*, int*); -extern int pushtls(int, const char*, const char*, int, const char*, - char*); +extern int jehanne_pushssl(int, const char*, const char*, const char*, int*); +//extern int jehanne_pushtls(int, const char*, const char*, int, const char*, +// char*); /* * network services @@ -537,8 +476,8 @@ struct NetConnInfo char *laddr; /* local address */ char *raddr; /* remote address */ }; -extern NetConnInfo* getnetconninfo(const char*, int); -extern void freenetconninfo(NetConnInfo*); +extern NetConnInfo* jehanne_getnetconninfo(const char*, int); +extern void jehanne_freenetconninfo(NetConnInfo*); /* * system calls @@ -571,7 +510,7 @@ extern void freenetconninfo(NetConnInfo*); /* Access modes */ #define AEXIST 0 /* accessible: exists */ -#define AREAD 4 /* read access */ +#define AREAD 4 /* read ccess */ #define AWRITE 2 /* write access */ #define AEXEC 1 /* execute access */ #define AMASK (AEXIST|AREAD|AWRITE|AEXEC) @@ -656,47 +595,49 @@ struct Waitmsg char *msg; } Waitmsg; -extern int access(const char*, int); -extern int awakened(int64_t); -extern int brk(void*); -extern int execl(const char*, ...); -extern int forgivewkp(int64_t); -extern pid_t fork(void); -extern int32_t readn(int, void*, int32_t); -extern void* sbrk(uint32_t); -extern int32_t oseek(int, int32_t, int); -extern void* segattach(int, const char*, void*, unsigned long); -extern int segdetach(void*); -extern int segfree(void*, unsigned long); -extern void sleep(int32_t); -extern int stat(const char*, uint8_t*, int); -extern Waitmsg* wait(void); -extern int waitpid(void); -extern int wstat(const char*, uint8_t*, int); +extern int jehanne_access(const char*, int); +extern int jehanne_awakened(int64_t); +extern int jehanne_brk(void*); +extern int jehanne_execl(const char*, ...); +extern int jehanne_forgivewkp(int64_t); +extern pid_t jehanne_fork(void); +extern int32_t jehanne_readn(int, void*, int32_t); +extern void* jehanne_segbrk(uint32_t); +#define sbrk(incr) jehanne_segbrk(incr) +extern void* jehanne_segattach(int, const char*, void*, unsigned long); +extern int jehanne_segdetach(void*); +extern int jehanne_segfree(void*, unsigned long); +extern void jehanne_sleep(int32_t); +extern int jehanne_stat(const char*, uint8_t*, int); +extern Waitmsg* jehanne_wait(void); +extern int jehanne_waitpid(void); +extern int jehanne_wstat(const char*, uint8_t*, int); -extern Dir* dirstat(const char*); -extern Dir* dirfstat(int); -extern int dirwstat(const char*, Dir*); -extern int dirfwstat(int, Dir*); -extern int32_t dirread(int, Dir**); -extern void nulldir(Dir*); -extern int32_t dirreadall(int, Dir**); -extern int32_t getpid(void); -extern int32_t getppid(void); -extern int32_t getmainpid(void); -extern void rerrstr(char*, uint32_t); -extern char* sysname(void); -extern void werrstr(const char*, ...); -#pragma varargck argpos werrstr 1 +extern Dir* jehanne_dirstat(const char*); +extern Dir* jehanne_dirfstat(int); +extern int jehanne_dirwstat(const char*, Dir*); +extern int jehanne_dirfwstat(int, Dir*); +extern int32_t jehanne_dirread(int, Dir**); +extern void jehanne_nulldir(Dir*); +extern int32_t jehanne_dirreadall(int, Dir**); +extern int32_t jehanne_getpid(void); +extern int32_t jehanne_getppid(void); +extern int32_t jehanne_getmainpid(void); +extern void jehanne_rerrstr(char*, uint32_t); +extern char* jehanne_sysname(void); +extern void jehanne_werrstr(const char*, ...); +extern unsigned int jehanne_convM2D(uint8_t*, uint, Dir*, char*); +extern unsigned int jehanne_convD2M(Dir*, uint8_t*, uint); +extern unsigned int jehanne_sizeD2M(Dir*); +extern int jehanne_dirmodefmt(Fmt*); -extern unsigned int convM2D(uint8_t*, uint, Dir*, char*); -extern unsigned int convD2M(Dir*, uint8_t*, uint); -extern unsigned int sizeD2M(Dir*); -extern int dirfmt(Fmt*); -extern int dirmodefmt(Fmt*); -#pragma varargck type "D" Dir* +#ifndef NPRIVATES +# define NPRIVATES 16 +#endif +/* can be overwritten to do anything before calling main */ +extern void __libc_init(int argc, char *argv[]) __attribute__((weak, noreturn)); /* compiler directives on plan 9 */ #define SET(x) ((x)=0) @@ -723,7 +664,7 @@ extern char *argv0; argc--; argv++; break;\ }\ _argc = 0;\ - while(*_args && (_args += chartorune(&_argc, _args)))\ + while(*_args && (_args += jehanne_chartorune(&_argc, _args)))\ switch(_argc) /* #define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc); */ #define ARGEND SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc); @@ -734,6 +675,6 @@ extern char *argv0; #define ARGC() _argc -/* this is used by sbrk and brk, it's a really bad idea to redefine it */ +/* this is used by segbrk and brk, it's a really bad idea to redefine it */ extern char end[]; diff --git a/sys/src/cmd/acme/acme.c b/sys/src/cmd/acme/acme.c index ea54fe4..1373d9d 100644 --- a/sys/src/cmd/acme/acme.c +++ b/sys/src/cmd/acme/acme.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/addr.c b/sys/src/cmd/acme/addr.c index b90a417..5e09745 100644 --- a/sys/src/cmd/acme/addr.c +++ b/sys/src/cmd/acme/addr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/aux/awd.c b/sys/src/cmd/acme/aux/awd.c index f710728..286c844 100644 --- a/sys/src/cmd/acme/aux/awd.c +++ b/sys/src/cmd/acme/aux/awd.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * like fprint but be sure to deliver as a single write. diff --git a/sys/src/cmd/acme/aux/mkwnew.c b/sys/src/cmd/acme/aux/mkwnew.c index 99c084b..c3c66ee 100644 --- a/sys/src/cmd/acme/aux/mkwnew.c +++ b/sys/src/cmd/acme/aux/mkwnew.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/sys/src/cmd/acme/aux/win/fs.c b/sys/src/cmd/acme/aux/win/fs.c index c35f9fa..69ca6fc 100644 --- a/sys/src/cmd/acme/aux/win/fs.c +++ b/sys/src/cmd/acme/aux/win/fs.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/cmd/acme/aux/win/main.c b/sys/src/cmd/acme/aux/win/main.c index 7530034..c68b3a9 100644 --- a/sys/src/cmd/acme/aux/win/main.c +++ b/sys/src/cmd/acme/aux/win/main.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/acme/aux/win/pipe.c b/sys/src/cmd/acme/aux/win/pipe.c index a065769..bcaaf3b 100644 --- a/sys/src/cmd/acme/aux/win/pipe.c +++ b/sys/src/cmd/acme/aux/win/pipe.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/cmd/acme/aux/win/util.c b/sys/src/cmd/acme/aux/win/util.c index 2fb39c3..c541b8b 100644 --- a/sys/src/cmd/acme/aux/win/util.c +++ b/sys/src/cmd/acme/aux/win/util.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "dat.h" diff --git a/sys/src/cmd/acme/aux/win/win.c b/sys/src/cmd/acme/aux/win/win.c index 0655eec..c9909b9 100644 --- a/sys/src/cmd/acme/aux/win/win.c +++ b/sys/src/cmd/acme/aux/win/win.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "dat.h" diff --git a/sys/src/cmd/acme/buff.c b/sys/src/cmd/acme/buff.c index 2983142..c51ffbe 100644 --- a/sys/src/cmd/acme/buff.c +++ b/sys/src/cmd/acme/buff.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/cols.c b/sys/src/cmd/acme/cols.c index d3f649f..735cbb4 100644 --- a/sys/src/cmd/acme/cols.c +++ b/sys/src/cmd/acme/cols.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/disk.c b/sys/src/cmd/acme/disk.c index 369f2c0..a4498d8 100644 --- a/sys/src/cmd/acme/disk.c +++ b/sys/src/cmd/acme/disk.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/ecmd.c b/sys/src/cmd/acme/ecmd.c index a6dbfcc..2e99cc5 100644 --- a/sys/src/cmd/acme/ecmd.c +++ b/sys/src/cmd/acme/ecmd.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/edit.c b/sys/src/cmd/acme/edit.c index c54f464..9ccbee4 100644 --- a/sys/src/cmd/acme/edit.c +++ b/sys/src/cmd/acme/edit.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/elog.c b/sys/src/cmd/acme/elog.c index 31012cc..465bc77 100644 --- a/sys/src/cmd/acme/elog.c +++ b/sys/src/cmd/acme/elog.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/exec.c b/sys/src/cmd/acme/exec.c index 3c7ac8b..f6ff946 100644 --- a/sys/src/cmd/acme/exec.c +++ b/sys/src/cmd/acme/exec.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/file.c b/sys/src/cmd/acme/file.c index 3322cfe..6a6bd55 100644 --- a/sys/src/cmd/acme/file.c +++ b/sys/src/cmd/acme/file.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/fsys.c b/sys/src/cmd/acme/fsys.c index a8f1d26..f6e6274 100644 --- a/sys/src/cmd/acme/fsys.c +++ b/sys/src/cmd/acme/fsys.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/look.c b/sys/src/cmd/acme/look.c index 4bfe40f..5b174d3 100644 --- a/sys/src/cmd/acme/look.c +++ b/sys/src/cmd/acme/look.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/regx.c b/sys/src/cmd/acme/regx.c index e469705..c4985a7 100644 --- a/sys/src/cmd/acme/regx.c +++ b/sys/src/cmd/acme/regx.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/rows.c b/sys/src/cmd/acme/rows.c index 50322d9..7c28cf1 100644 --- a/sys/src/cmd/acme/rows.c +++ b/sys/src/cmd/acme/rows.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/scrl.c b/sys/src/cmd/acme/scrl.c index d4cb4c3..eb29507 100644 --- a/sys/src/cmd/acme/scrl.c +++ b/sys/src/cmd/acme/scrl.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/text.c b/sys/src/cmd/acme/text.c index 3292ca5..0de76c5 100644 --- a/sys/src/cmd/acme/text.c +++ b/sys/src/cmd/acme/text.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/time.c b/sys/src/cmd/acme/time.c index ea7abf2..b9d8839 100644 --- a/sys/src/cmd/acme/time.c +++ b/sys/src/cmd/acme/time.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/util.c b/sys/src/cmd/acme/util.c index f4cff29..9ba6475 100644 --- a/sys/src/cmd/acme/util.c +++ b/sys/src/cmd/acme/util.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/wind.c b/sys/src/cmd/acme/wind.c index 9f3d34c..09cc508 100644 --- a/sys/src/cmd/acme/wind.c +++ b/sys/src/cmd/acme/wind.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/acme/xfid.c b/sys/src/cmd/acme/xfid.c index a6d5ef9..26039d6 100644 --- a/sys/src/cmd/acme/xfid.c +++ b/sys/src/cmd/acme/xfid.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ascii.c b/sys/src/cmd/ascii.c index 27eafb0..9d9c9fa 100644 --- a/sys/src/cmd/ascii.c +++ b/sys/src/cmd/ascii.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #define MAXBASE 36 diff --git a/sys/src/cmd/auth/as.c b/sys/src/cmd/auth/as.c index fb5036d..51a45cb 100644 --- a/sys/src/cmd/auth/as.c +++ b/sys/src/cmd/auth/as.c @@ -4,7 +4,7 @@ * needs #¤/caphash and #¤/capuse. */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/asn12dsa.c b/sys/src/cmd/auth/asn12dsa.c index 2d1eb7a..d799f86 100644 --- a/sys/src/cmd/auth/asn12dsa.c +++ b/sys/src/cmd/auth/asn12dsa.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/asn12rsa.c b/sys/src/cmd/auth/asn12rsa.c index edd7ac4..5a05c44 100644 --- a/sys/src/cmd/auth/asn12rsa.c +++ b/sys/src/cmd/auth/asn12rsa.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/authsrv.c b/sys/src/cmd/auth/authsrv.c index 5e8dbc7..c2783f5 100644 --- a/sys/src/cmd/auth/authsrv.c +++ b/sys/src/cmd/auth/authsrv.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/challenge.c b/sys/src/cmd/auth/challenge.c index c990276..811308a 100644 --- a/sys/src/cmd/auth/challenge.c +++ b/sys/src/cmd/auth/challenge.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/auth/changeuser.c b/sys/src/cmd/auth/changeuser.c index af1ee3d..d340064 100644 --- a/sys/src/cmd/auth/changeuser.c +++ b/sys/src/cmd/auth/changeuser.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/convbio.c b/sys/src/cmd/auth/convbio.c index afca2f5..7e18cb3 100644 --- a/sys/src/cmd/auth/convbio.c +++ b/sys/src/cmd/auth/convbio.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/convkeys.c b/sys/src/cmd/auth/convkeys.c index 1267b3b..03b8220 100644 --- a/sys/src/cmd/auth/convkeys.c +++ b/sys/src/cmd/auth/convkeys.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/cron.c b/sys/src/cmd/auth/cron.c index 5f46dcb..e8aa75e 100644 --- a/sys/src/cmd/auth/cron.c +++ b/sys/src/cmd/auth/cron.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/debug.c b/sys/src/cmd/auth/debug.c index 0e4cd05..b2333a1 100644 --- a/sys/src/cmd/auth/debug.c +++ b/sys/src/cmd/auth/debug.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/dsa2pub.c b/sys/src/cmd/auth/dsa2pub.c index 7c516c6..08e72db 100644 --- a/sys/src/cmd/auth/dsa2pub.c +++ b/sys/src/cmd/auth/dsa2pub.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/dsa2ssh.c b/sys/src/cmd/auth/dsa2ssh.c index 9284c9f..7f2733f 100644 --- a/sys/src/cmd/auth/dsa2ssh.c +++ b/sys/src/cmd/auth/dsa2ssh.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/dsagen.c b/sys/src/cmd/auth/dsagen.c index d7ffa33..2853d0b 100644 --- a/sys/src/cmd/auth/dsagen.c +++ b/sys/src/cmd/auth/dsagen.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/auth/factotum/dat.h b/sys/src/cmd/auth/factotum/dat.h index a5cb62b..f994fe0 100644 --- a/sys/src/cmd/auth/factotum/dat.h +++ b/sys/src/cmd/auth/factotum/dat.h @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/guard.srv.c b/sys/src/cmd/auth/guard.srv.c index 9ab4ecb..966eea4 100644 --- a/sys/src/cmd/auth/guard.srv.c +++ b/sys/src/cmd/auth/guard.srv.c @@ -2,7 +2,7 @@ * guard service */ #include -#include +#include #include <9P2000.h> #include #include diff --git a/sys/src/cmd/auth/httpauth.c b/sys/src/cmd/auth/httpauth.c index c70216d..e4c83d5 100644 --- a/sys/src/cmd/auth/httpauth.c +++ b/sys/src/cmd/auth/httpauth.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/auth/keyfs.c b/sys/src/cmd/auth/keyfs.c index a9747c3..63c5dbf 100644 --- a/sys/src/cmd/auth/keyfs.c +++ b/sys/src/cmd/auth/keyfs.c @@ -2,7 +2,7 @@ * keyfs */ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/auth/lib/error.c b/sys/src/cmd/auth/lib/error.c index 784ae37..17aaa6a 100644 --- a/sys/src/cmd/auth/lib/error.c +++ b/sys/src/cmd/auth/lib/error.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/fs.c b/sys/src/cmd/auth/lib/fs.c index 35429d0..d65b3de 100644 --- a/sys/src/cmd/auth/lib/fs.c +++ b/sys/src/cmd/auth/lib/fs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/getauthkey.c b/sys/src/cmd/auth/lib/getauthkey.c index 48437e8..e84d0e5 100644 --- a/sys/src/cmd/auth/lib/getauthkey.c +++ b/sys/src/cmd/auth/lib/getauthkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/getexpiration.c b/sys/src/cmd/auth/lib/getexpiration.c index 1bc312f..af7f783 100644 --- a/sys/src/cmd/auth/lib/getexpiration.c +++ b/sys/src/cmd/auth/lib/getexpiration.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/lib/keyfmt.c b/sys/src/cmd/auth/lib/keyfmt.c index 0d33ea1..5be57ab 100644 --- a/sys/src/cmd/auth/lib/keyfmt.c +++ b/sys/src/cmd/auth/lib/keyfmt.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/log.c b/sys/src/cmd/auth/lib/log.c index bd4eaf1..828cd8e 100644 --- a/sys/src/cmd/auth/lib/log.c +++ b/sys/src/cmd/auth/lib/log.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/netcheck.c b/sys/src/cmd/auth/lib/netcheck.c index 89b4f78..e1f825a 100644 --- a/sys/src/cmd/auth/lib/netcheck.c +++ b/sys/src/cmd/auth/lib/netcheck.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/okpasswd.c b/sys/src/cmd/auth/lib/okpasswd.c index b904db5..8ec841e 100644 --- a/sys/src/cmd/auth/lib/okpasswd.c +++ b/sys/src/cmd/auth/lib/okpasswd.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/private.c b/sys/src/cmd/auth/lib/private.c index 392842c..b7cbe2c 100644 --- a/sys/src/cmd/auth/lib/private.c +++ b/sys/src/cmd/auth/lib/private.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/querybio.c b/sys/src/cmd/auth/lib/querybio.c index 90e54ae..081205e 100644 --- a/sys/src/cmd/auth/lib/querybio.c +++ b/sys/src/cmd/auth/lib/querybio.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/lib/rdbio.c b/sys/src/cmd/auth/lib/rdbio.c index 1d56c5d..15473c1 100644 --- a/sys/src/cmd/auth/lib/rdbio.c +++ b/sys/src/cmd/auth/lib/rdbio.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/lib/readarg.c b/sys/src/cmd/auth/lib/readarg.c index 238e825..e6b9b5b 100644 --- a/sys/src/cmd/auth/lib/readarg.c +++ b/sys/src/cmd/auth/lib/readarg.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/readln.c b/sys/src/cmd/auth/lib/readln.c index f47dc09..ccdc0cf 100644 --- a/sys/src/cmd/auth/lib/readln.c +++ b/sys/src/cmd/auth/lib/readln.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/readn.c b/sys/src/cmd/auth/lib/readn.c index 6f93249..dbbe952 100644 --- a/sys/src/cmd/auth/lib/readn.c +++ b/sys/src/cmd/auth/lib/readn.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/readwrite.c b/sys/src/cmd/auth/lib/readwrite.c index f115631..e20be1e 100644 --- a/sys/src/cmd/auth/lib/readwrite.c +++ b/sys/src/cmd/auth/lib/readwrite.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/lib/wrbio.c b/sys/src/cmd/auth/lib/wrbio.c index 202217f..70dd972 100644 --- a/sys/src/cmd/auth/lib/wrbio.c +++ b/sys/src/cmd/auth/lib/wrbio.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/login.c b/sys/src/cmd/auth/login.c index 7829fb0..a213438 100644 --- a/sys/src/cmd/auth/login.c +++ b/sys/src/cmd/auth/login.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/netkey.c b/sys/src/cmd/auth/netkey.c index 30ac560..f5c6747 100644 --- a/sys/src/cmd/auth/netkey.c +++ b/sys/src/cmd/auth/netkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/newns.c b/sys/src/cmd/auth/newns.c index 792e8e5..8b4b3cb 100644 --- a/sys/src/cmd/auth/newns.c +++ b/sys/src/cmd/auth/newns.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/auth/none.c b/sys/src/cmd/auth/none.c index df2a2e5..e74cc7d 100644 --- a/sys/src/cmd/auth/none.c +++ b/sys/src/cmd/auth/none.c @@ -1,5 +1,5 @@ #include -#include +#include #include char *namespace; diff --git a/sys/src/cmd/auth/passwd.c b/sys/src/cmd/auth/passwd.c index c7a5266..8290618 100644 --- a/sys/src/cmd/auth/passwd.c +++ b/sys/src/cmd/auth/passwd.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/pemdecode.c b/sys/src/cmd/auth/pemdecode.c index 2a9a927..53f1b2b 100644 --- a/sys/src/cmd/auth/pemdecode.c +++ b/sys/src/cmd/auth/pemdecode.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/pemencode.c b/sys/src/cmd/auth/pemencode.c index 5bbc2bd..ee2e434 100644 --- a/sys/src/cmd/auth/pemencode.c +++ b/sys/src/cmd/auth/pemencode.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/printnetkey.c b/sys/src/cmd/auth/printnetkey.c index 9b58978..3299256 100644 --- a/sys/src/cmd/auth/printnetkey.c +++ b/sys/src/cmd/auth/printnetkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authcmdlib.h" diff --git a/sys/src/cmd/auth/readnvram.c b/sys/src/cmd/auth/readnvram.c index 04c6470..407896d 100644 --- a/sys/src/cmd/auth/readnvram.c +++ b/sys/src/cmd/auth/readnvram.c @@ -1,6 +1,6 @@ /* readnvram */ #include -#include +#include #include #include diff --git a/sys/src/cmd/auth/respond.c b/sys/src/cmd/auth/respond.c index c663422..817a0b2 100644 --- a/sys/src/cmd/auth/respond.c +++ b/sys/src/cmd/auth/respond.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/auth/rsa2any.c b/sys/src/cmd/auth/rsa2any.c index b608be3..278b528 100644 --- a/sys/src/cmd/auth/rsa2any.c +++ b/sys/src/cmd/auth/rsa2any.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsa2csr.c b/sys/src/cmd/auth/rsa2csr.c index d5bc49f..f8f28c9 100644 --- a/sys/src/cmd/auth/rsa2csr.c +++ b/sys/src/cmd/auth/rsa2csr.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsa2pub.c b/sys/src/cmd/auth/rsa2pub.c index df3ac9a..ca08734 100644 --- a/sys/src/cmd/auth/rsa2pub.c +++ b/sys/src/cmd/auth/rsa2pub.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsa2ssh.c b/sys/src/cmd/auth/rsa2ssh.c index 781ae02..8d683de 100644 --- a/sys/src/cmd/auth/rsa2ssh.c +++ b/sys/src/cmd/auth/rsa2ssh.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsa2x509.c b/sys/src/cmd/auth/rsa2x509.c index de55463..4f14ed5 100644 --- a/sys/src/cmd/auth/rsa2x509.c +++ b/sys/src/cmd/auth/rsa2x509.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsafill.c b/sys/src/cmd/auth/rsafill.c index 95e583a..0ef1826 100644 --- a/sys/src/cmd/auth/rsafill.c +++ b/sys/src/cmd/auth/rsafill.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/rsagen.c b/sys/src/cmd/auth/rsagen.c index ec6bbb0..8ab255a 100644 --- a/sys/src/cmd/auth/rsagen.c +++ b/sys/src/cmd/auth/rsagen.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/auth/secstore/SConn.c b/sys/src/cmd/auth/secstore/SConn.c index 14d1b0a..bc6bd1f 100644 --- a/sys/src/cmd/auth/secstore/SConn.c +++ b/sys/src/cmd/auth/secstore/SConn.c @@ -1,6 +1,6 @@ #define PORTABLE_SYSCALLS #include -#include +#include #include #include #include "SConn.h" diff --git a/sys/src/cmd/auth/secstore/aescbc.c b/sys/src/cmd/auth/secstore/aescbc.c index c78be61..0c70b40 100644 --- a/sys/src/cmd/auth/secstore/aescbc.c +++ b/sys/src/cmd/auth/secstore/aescbc.c @@ -5,7 +5,7 @@ HMAC_SHA1(md5(key), AES-CBC(random | file)) */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/secstore/dirls.c b/sys/src/cmd/auth/secstore/dirls.c index 27a2037..679ebce 100644 --- a/sys/src/cmd/auth/secstore/dirls.c +++ b/sys/src/cmd/auth/secstore/dirls.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "SConn.h" diff --git a/sys/src/cmd/auth/secstore/pak.c b/sys/src/cmd/auth/secstore/pak.c index 635ea3f..2fc5b7e 100644 --- a/sys/src/cmd/auth/secstore/pak.c +++ b/sys/src/cmd/auth/secstore/pak.c @@ -12,7 +12,7 @@ // (All other EKE protocols are patented as well, by Lucent or others.) #define PORTABLE_SYSCALLS #include -#include +#include #include #include #include "SConn.h" diff --git a/sys/src/cmd/auth/secstore/password.c b/sys/src/cmd/auth/secstore/password.c index b57e90d..4925a92 100644 --- a/sys/src/cmd/auth/secstore/password.c +++ b/sys/src/cmd/auth/secstore/password.c @@ -1,6 +1,6 @@ /* password.c */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/secstore/secchk.c b/sys/src/cmd/auth/secstore/secchk.c index c6f306a..4c138b3 100644 --- a/sys/src/cmd/auth/secstore/secchk.c +++ b/sys/src/cmd/auth/secstore/secchk.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/auth/secstore/secstore.c b/sys/src/cmd/auth/secstore/secstore.c index ab24ad0..72593bb 100644 --- a/sys/src/cmd/auth/secstore/secstore.c +++ b/sys/src/cmd/auth/secstore/secstore.c @@ -1,7 +1,7 @@ /* secstore - network login client */ #define PORTABLE_SYSCALLS #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/secstore/secstored.c b/sys/src/cmd/auth/secstore/secstored.c index c8af433..6232a58 100644 --- a/sys/src/cmd/auth/secstore/secstored.c +++ b/sys/src/cmd/auth/secstore/secstored.c @@ -1,7 +1,7 @@ /* secstored - secure store daemon */ #define PORTABLE_SYSCALLS #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/secstore/secuser.c b/sys/src/cmd/auth/secstore/secuser.c index 3af23b7..0012148 100644 --- a/sys/src/cmd/auth/secstore/secuser.c +++ b/sys/src/cmd/auth/secstore/secuser.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "SConn.h" diff --git a/sys/src/cmd/auth/secstore/util.c b/sys/src/cmd/auth/secstore/util.c index 9d74345..b9cc655 100644 --- a/sys/src/cmd/auth/secstore/util.c +++ b/sys/src/cmd/auth/secstore/util.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "SConn.h" diff --git a/sys/src/cmd/auth/secureidcheck.c b/sys/src/cmd/auth/secureidcheck.c index 6f690fa..c3fc54f 100644 --- a/sys/src/cmd/auth/secureidcheck.c +++ b/sys/src/cmd/auth/secureidcheck.c @@ -11,7 +11,7 @@ */ /* RFC2138 */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/uniq.c b/sys/src/cmd/auth/uniq.c index 3ba4dc6..98b4362 100644 --- a/sys/src/cmd/auth/uniq.c +++ b/sys/src/cmd/auth/uniq.c @@ -1,5 +1,5 @@ #include -#include +#include #include typedef struct Who Who; diff --git a/sys/src/cmd/auth/userpasswd.c b/sys/src/cmd/auth/userpasswd.c index ec97411..e847349 100644 --- a/sys/src/cmd/auth/userpasswd.c +++ b/sys/src/cmd/auth/userpasswd.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/auth/warning.c b/sys/src/cmd/auth/warning.c index 0dde57c..611be5c 100644 --- a/sys/src/cmd/auth/warning.c +++ b/sys/src/cmd/auth/warning.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/auth/wrkey.c b/sys/src/cmd/auth/wrkey.c index e383d37..c692699 100644 --- a/sys/src/cmd/auth/wrkey.c +++ b/sys/src/cmd/auth/wrkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/awk/awk.h b/sys/src/cmd/awk/awk.h index 18d5b8e..9d876d3 100644 --- a/sys/src/cmd/awk/awk.h +++ b/sys/src/cmd/awk/awk.h @@ -11,7 +11,7 @@ typedef double Awkfloat; #define DEBUG #ifdef DEBUG /* uses have to be doubly parenthesized */ -# define dprint(x) if (dbg) print x +# define dprint(x) if (dbg) jehanne_print x #else # define dprint(x) #endif diff --git a/sys/src/cmd/awk/awkgram.y b/sys/src/cmd/awk/awkgram.y index 7ddf608..784c7ef 100644 --- a/sys/src/cmd/awk/awkgram.y +++ b/sys/src/cmd/awk/awkgram.y @@ -24,7 +24,7 @@ THIS SOFTWARE. %{ #include -#include +#include #include #include "awk.h" diff --git a/sys/src/cmd/awk/lex.c b/sys/src/cmd/awk/lex.c index 557ec56..cad2b37 100644 --- a/sys/src/cmd/awk/lex.c +++ b/sys/src/cmd/awk/lex.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include #include "awk.h" diff --git a/sys/src/cmd/awk/lib.c b/sys/src/cmd/awk/lib.c index 9f9da9a..10ab12d 100644 --- a/sys/src/cmd/awk/lib.c +++ b/sys/src/cmd/awk/lib.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include #include "awk.h" diff --git a/sys/src/cmd/awk/main.c b/sys/src/cmd/awk/main.c index 2695de5..a8198de 100644 --- a/sys/src/cmd/awk/main.c +++ b/sys/src/cmd/awk/main.c @@ -50,12 +50,18 @@ int curpfile = 0; /* current filename */ int safe = 0; /* 1 => "safe" mode */ +void* +memcpy(void* a, const void* b, size_t c) +{ + return jehanne_memcpy(a,b,c); +} + void main(int argc, char *argv[]) { char *fs = nil, *marg; int temp; - setfcr(getfcr() & ~FPINVAL); + jehanne_setfcr(jehanne_getfcr() & ~FPINVAL); Binit(&stdin, 0, OREAD); Binit(&stdout, 1, OWRITE); @@ -64,21 +70,21 @@ void main(int argc, char *argv[]) cmdname = argv[0]; if (argc == 1) { Bprint(&stderr, "Usage: %s [-F fieldsep] [-mf n] [-mr n] [-v var=value] [-f programfile | 'program'] [file ...]\n", cmdname); - exits("usage"); + jehanne_exits("usage"); } - atnotify(handler, 1); + jehanne_atnotify(handler, 1); yyin = nil; symtab = makesymtab(NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { - if (strcmp(argv[1], "--") == 0) { /* explicit end of args */ + if (jehanne_strcmp(argv[1], "--") == 0) { /* explicit end of args */ argc--; argv++; break; } switch (argv[1][1]) { case 's': - if (strcmp(argv[1], "-safe") == 0) + if (jehanne_strcmp(argv[1], "-safe") == 0) safe = 1; break; case 'f': /* next argument is program filename */ @@ -112,10 +118,10 @@ void main(int argc, char *argv[]) /* no longer needed */ marg = argv[1]; if (argv[1][3]) - temp = atoi(&argv[1][3]); + temp = jehanne_atoi(&argv[1][3]); else { argv++; argc--; - temp = atoi(&argv[1][0]); + temp = jehanne_atoi(&argv[1][0]); } switch (marg[2]) { case 'r': recsize = temp; break; @@ -124,14 +130,14 @@ void main(int argc, char *argv[]) } break; case 'd': - dbg = atoi(&argv[1][2]); + dbg = jehanne_atoi(&argv[1][2]); if (dbg == 0) dbg = 1; - print("awk %s\n", version); + jehanne_print("awk %s\n", version); break; case 'V': /* added for exptools "standard" */ - print("awk %s\n", version); - exits(0); + jehanne_print("awk %s\n", version); + jehanne_exits(0); break; default: WARNING("unknown option %s ignored", argv[1]); @@ -144,7 +150,7 @@ void main(int argc, char *argv[]) if (npfile == 0) { /* no -f; first argument is program */ if (argc <= 1) { if (dbg) - exits(0); + jehanne_exits(0); FATAL("no program given"); } dprint( ("program = |%s|\n", argv[1]) ); @@ -168,8 +174,8 @@ void main(int argc, char *argv[]) } else bracecheck(); if(errorflag) - exits("error"); - exits(0); + jehanne_exits("error"); + jehanne_exits(0); } int pgetc(void) /* get 1 character from awk program */ @@ -180,7 +186,7 @@ int pgetc(void) /* get 1 character from awk program */ if (yyin == nil) { if (curpfile >= npfile) return Beof; - if (strcmp(pfile[curpfile], "-") == 0) + if (jehanne_strcmp(pfile[curpfile], "-") == 0) yyin = &stdin; else if ((yyin = Bopen(pfile[curpfile], OREAD)) == nil) FATAL("can't open file %s", pfile[curpfile]); diff --git a/sys/src/cmd/awk/maketab.c b/sys/src/cmd/awk/maketab.c index 5e8e426..015a7fa 100644 --- a/sys/src/cmd/awk/maketab.c +++ b/sys/src/cmd/awk/maketab.c @@ -29,7 +29,7 @@ THIS SOFTWARE. */ #include -#include +#include #include #include "awk.h" #include "y.tab.h" @@ -118,7 +118,7 @@ void main(int _, char** __) char *buf, *toks[3]; print("#include \n"); - print("#include \n"); + print("#include \n"); print("#include \n"); print("#include \"awk.h\"\n"); print("#include \"y.tab.h\"\n\n"); diff --git a/sys/src/cmd/awk/maketab.go b/sys/src/cmd/awk/maketab.go index d2634e5..2ca33ee 100644 --- a/sys/src/cmd/awk/maketab.go +++ b/sys/src/cmd/awk/maketab.go @@ -151,7 +151,7 @@ func main() { tmpl, err := template.New("proctab.c").Parse(`/* automatically generated by maketab */ #include -#include +#include #include #include "awk.h" #include "y.tab.h" diff --git a/sys/src/cmd/awk/parse.c b/sys/src/cmd/awk/parse.c index 8cb1c5e..5e2ef29 100644 --- a/sys/src/cmd/awk/parse.c +++ b/sys/src/cmd/awk/parse.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include "awk.h" #include "y.tab.h" diff --git a/sys/src/cmd/awk/popen.c b/sys/src/cmd/awk/popen.c index bcb769e..111bf36 100644 --- a/sys/src/cmd/awk/popen.c +++ b/sys/src/cmd/awk/popen.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "awk.h" diff --git a/sys/src/cmd/awk/re.c b/sys/src/cmd/awk/re.c index 3d13386..acb2dc3 100644 --- a/sys/src/cmd/awk/re.c +++ b/sys/src/cmd/awk/re.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/awk/run.c b/sys/src/cmd/awk/run.c index 6a5e478..3913c0b 100644 --- a/sys/src/cmd/awk/run.c +++ b/sys/src/cmd/awk/run.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include #include "awk.h" diff --git a/sys/src/cmd/awk/tran.c b/sys/src/cmd/awk/tran.c index 8c4cb21..a911145 100644 --- a/sys/src/cmd/awk/tran.c +++ b/sys/src/cmd/awk/tran.c @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ #include -#include +#include #include #include #include "awk.h" diff --git a/sys/src/cmd/basename.c b/sys/src/cmd/basename.c index 4cc1716..6b9afe8 100644 --- a/sys/src/cmd/basename.c +++ b/sys/src/cmd/basename.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/sys/src/cmd/bind.c b/sys/src/cmd/bind.c index 0221261..b3324da 100644 --- a/sys/src/cmd/bind.c +++ b/sys/src/cmd/bind.c @@ -8,7 +8,7 @@ */ #include -#include +#include void usage(void); diff --git a/sys/src/cmd/cal.c b/sys/src/cmd/cal.c index b14a52f..6874462 100644 --- a/sys/src/cmd/cal.c +++ b/sys/src/cmd/cal.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include char dayw[] = diff --git a/sys/src/cmd/cat.c b/sys/src/cmd/cat.c index 41a2a23..703de1b 100644 --- a/sys/src/cmd/cat.c +++ b/sys/src/cmd/cat.c @@ -8,7 +8,7 @@ */ #include -#include +#include void cat(int f, char *s) diff --git a/sys/src/cmd/chgrp.c b/sys/src/cmd/chgrp.c index b5ed4fc..99c09b0 100644 --- a/sys/src/cmd/chgrp.c +++ b/sys/src/cmd/chgrp.c @@ -8,7 +8,7 @@ */ #include -#include +#include int readgid(char*); int uflag; diff --git a/sys/src/cmd/chmod.c b/sys/src/cmd/chmod.c index 102a666..e3166c8 100644 --- a/sys/src/cmd/chmod.c +++ b/sys/src/cmd/chmod.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define U(x) (x<<6) #define G(x) (x<<3) diff --git a/sys/src/cmd/cleanname.c b/sys/src/cmd/cleanname.c index ea4c3d3..3d153d7 100644 --- a/sys/src/cmd/cleanname.c +++ b/sys/src/cmd/cleanname.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char **argv) diff --git a/sys/src/cmd/cmds.json b/sys/src/cmd/cmds.json index 2c4e001..e6bdd8e 100644 --- a/sys/src/cmd/cmds.json +++ b/sys/src/cmd/cmds.json @@ -82,7 +82,9 @@ "-DYYSIZE_T=size_t" ], "Install": "/arch/$ARCH/cmd/", - "SourceFilesCmd": [ + "Program": "mpc", + "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "mpc.c" ] }, diff --git a/sys/src/cmd/cp.c b/sys/src/cmd/cp.c index c60b26d..93987a0 100644 --- a/sys/src/cmd/cp.c +++ b/sys/src/cmd/cp.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define DEFB (8*1024) diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c index bca24de..e2df8f1 100644 --- a/sys/src/cmd/cpu.c +++ b/sys/src/cmd/cpu.c @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> @@ -808,16 +808,16 @@ kick(int fd) int rv; for(;;){ - lock(&nfs); + jehanne_lock(&nfs); rp = nfs.rfirst; np = nfs.nfirst; if(rp == nil || np == nil){ - unlock(&nfs); + jehanne_unlock(&nfs); break; } nfs.rfirst = rp->next; nfs.nfirst = np->next; - unlock(&nfs); + jehanne_unlock(&nfs); rp->f.type = Rread; rp->f.count = strlen(np->msg); @@ -836,17 +836,17 @@ flushreq(int tag) { Request **l, *rp; - lock(&nfs); + jehanne_lock(&nfs); for(l = &nfs.rfirst; *l != nil; l = &(*l)->next){ rp = *l; if(rp->f.tag == tag){ *l = rp->next; - unlock(&nfs); + jehanne_unlock(&nfs); free(rp); return; } } - unlock(&nfs); + jehanne_unlock(&nfs); } Fid* @@ -917,13 +917,13 @@ fsread(int fd, Fid *fid, Fcall *f) if(rp == nil) return -1; rp->f = *f; - lock(&nfs); + jehanne_lock(&nfs); if(nfs.rfirst == nil) nfs.rfirst = rp; else nfs.rlast->next = rp; nfs.rlast = rp; - unlock(&nfs); + jehanne_unlock(&nfs); return kick(fd);; } } @@ -1154,13 +1154,13 @@ lclnoteproc(int netfd) np = mallocz(sizeof(Note), 1); if(np != nil){ strcpy(np->msg, notebuf); - lock(&nfs); + jehanne_lock(&nfs); if(nfs.nfirst == nil) nfs.nfirst = np; else nfs.nlast->next = np; nfs.nlast = np; - unlock(&nfs); + jehanne_unlock(&nfs); kick(pfd[0]); } unlock(&nfs); diff --git a/sys/src/cmd/date.c b/sys/src/cmd/date.c index 23fd066..2ffa37e 100644 --- a/sys/src/cmd/date.c +++ b/sys/src/cmd/date.c @@ -8,7 +8,7 @@ */ #include -#include +#include int uflg, nflg; diff --git a/sys/src/cmd/dd.c b/sys/src/cmd/dd.c index 7a38914..da7c892 100644 --- a/sys/src/cmd/dd.c +++ b/sys/src/cmd/dd.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define BIG ((1UL<<31)-1) #define VBIG ((1ULL<<63)-1) diff --git a/sys/src/cmd/disk/format.c b/sys/src/cmd/disk/format.c index f556abc..076c5ac 100644 --- a/sys/src/cmd/disk/format.c +++ b/sys/src/cmd/disk/format.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/disk/mkext.c b/sys/src/cmd/disk/mkext.c index 561b508..185cd8b 100644 --- a/sys/src/cmd/disk/mkext.c +++ b/sys/src/cmd/disk/mkext.c @@ -1,5 +1,5 @@ #include -#include +#include #include enum{ diff --git a/sys/src/cmd/disk/mkfs.c b/sys/src/cmd/disk/mkfs.c index 5e0c806..ee00621 100644 --- a/sys/src/cmd/disk/mkfs.c +++ b/sys/src/cmd/disk/mkfs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/disk/prep/calc.y b/sys/src/cmd/disk/prep/calc.y index 9630d8b..bc1f711 100644 --- a/sys/src/cmd/disk/prep/calc.y +++ b/sys/src/cmd/disk/prep/calc.y @@ -55,7 +55,7 @@ expr: NUMBER %% -#include +#include #include #include "disk.h" #include "edit.h" diff --git a/sys/src/cmd/disk/prep/edit.c b/sys/src/cmd/disk/prep/edit.c index ad7d365..2fbff23 100644 --- a/sys/src/cmd/disk/prep/edit.c +++ b/sys/src/cmd/disk/prep/edit.c @@ -2,7 +2,7 @@ * disk partition editor */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/disk/prep/fdisk.c b/sys/src/cmd/disk/prep/fdisk.c index 33917e0..b00b8de 100644 --- a/sys/src/cmd/disk/prep/fdisk.c +++ b/sys/src/cmd/disk/prep/fdisk.c @@ -11,7 +11,7 @@ * fdisk - edit dos disk partition table */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/disk/prep/fdisk.json b/sys/src/cmd/disk/prep/fdisk.json index 5a6b795..02c00f0 100644 --- a/sys/src/cmd/disk/prep/fdisk.json +++ b/sys/src/cmd/disk/prep/fdisk.json @@ -12,6 +12,7 @@ ], "Program": "fdisk", "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "fdisk.c", "edit.c", "y.tab.c" diff --git a/sys/src/cmd/disk/prep/prep.c b/sys/src/cmd/disk/prep/prep.c index 3b05924..b3782eb 100644 --- a/sys/src/cmd/disk/prep/prep.c +++ b/sys/src/cmd/disk/prep/prep.c @@ -87,8 +87,8 @@ Auto autox[] = void usage(void) { - fprint(2, "usage: disk/prep [-bcfprw] [-a partname]... [-s sectorsize] /dev/sdC0/plan9\n"); - exits("usage"); + jehanne_fprint(2, "usage: disk/prep [-bcfprw] [-a partname]... [-s sectorsize] /dev/sdC0/plan9\n"); + jehanne_exits("usage"); } void @@ -104,9 +104,9 @@ main(int argc, char **argv) case 'a': p = EARGF(usage()); for(i=0; isecsize = secsize; @@ -180,7 +180,7 @@ main(int argc, char **argv) if(printflag) { runcmd(&edit, (char[]){"P"}); - exits(0); + jehanne_exits(0); } if(doautox) @@ -188,12 +188,12 @@ main(int argc, char **argv) if(dowrite) { runcmd(&edit, (char[]){"w"}); - exits(0); + jehanne_exits(0); } runcmd(&edit, (char[]){"p"}); for(;;) { - fprint(2, ">>> "); + jehanne_fprint(2, ">>> "); runcmd(&edit, getline(&edit)); } } @@ -223,16 +223,16 @@ cmdsum(Edit *edit, Part *p, int64_t a, int64_t b) div = KB; }else{ if (sz < 0) - fprint(2, "%s: negative size!\n", argv0); + jehanne_fprint(2, "%s: negative size!\n", argv0); suf = "B "; div = 1; } if(div == 1) - print("%c %-12s %*lld %-*lld (%lld sectors, %lld %s)\n", c, name, + jehanne_print("%c %-12s %*lld %-*lld (%lld sectors, %lld %s)\n", c, name, edit->disk->width, a, edit->disk->width, b, b-a, sz, suf); else - print("%c %-12s %*lld %-*lld (%lld sectors, %lld.%.2d %s)\n", c, name, + jehanne_print("%c %-12s %*lld %-*lld (%lld sectors, %lld.%.2d %s)\n", c, name, edit->disk->width, a, edit->disk->width, b, b-a, sz/div, (int)(((sz%div)*100)/div), suf); } @@ -240,7 +240,7 @@ cmdsum(Edit *edit, Part *p, int64_t a, int64_t b) static char* cmdadd(Edit *edit, char *name, int64_t start, int64_t end) { - if(start < 2 && strcmp(name, "9fat") != 0) + if(start < 2 && jehanne_strcmp(name, "9fat") != 0) return "overlaps with the pbs and/or the partition table"; return addpart(edit, mkpart(name, start, end, 1)); @@ -305,39 +305,39 @@ rdpart(Edit *edit) disk = edit->disk; seek(disk->fd, disk->secsize, 0); - if(readn(disk->fd, osecbuf, disk->secsize) != disk->secsize) + if(jehanne_readn(disk->fd, osecbuf, disk->secsize) != disk->secsize) return; osecbuf[disk->secsize] = '\0'; - memmove(secbuf, osecbuf, disk->secsize+1); + jehanne_memmove(secbuf, osecbuf, disk->secsize+1); - if(strncmp(secbuf, "part", 4) != 0){ - fprint(2, "no plan9 partition table found\n"); + if(jehanne_strncmp(secbuf, "part", 4) != 0){ + jehanne_fprint(2, "no plan9 partition table found\n"); return; } waserr = 0; - nline = getfields(secbuf, line, nelem(line), 1, "\n"); + nline = jehanne_getfields(secbuf, line, nelem(line), 1, "\n"); for(i=0; i= b) goto Error; if(err = addpart(edit, mkpart(f[1], a, b, 0))) { - fprint(2, "?%s: not continuing\n", err); - exits("partition"); + jehanne_fprint(2, "?%s: not continuing\n", err); + jehanne_exits("partition"); } } } @@ -352,7 +352,7 @@ autoxpart(Edit *edit) if(edit->npart > 0) { if(doautox) - fprint(2, "partitions already exist; not repartitioning\n"); + jehanne_fprint(2, "partitions already exist; not repartitioning\n"); return; } secs = edit->disk->secs; @@ -373,7 +373,7 @@ autoxpart(Edit *edit) break; if(secs <= 0){ - fprint(2, "ran out of disk space during autoxpartition.\n"); + jehanne_fprint(2, "ran out of disk space during autoxpartition.\n"); return; } @@ -435,9 +435,9 @@ autoxpart(Edit *edit) e = (s + autox[i].size); if((e + pa) % stride) e += stride - (e + pa) % stride; if(e>secs) e = secs - stride + (secs + pa) % stride; - print("%s %llud\n", autox[i].name, e - s); + jehanne_print("%s %llud\n", autox[i].name, e - s); if(err = addpart(edit, mkpart(autox[i].name, s, e, 1))) - fprint(2, "addpart %s: %s\n", autox[i].name, err); + jehanne_fprint(2, "addpart %s: %s\n", autox[i].name, err); s = e; } } @@ -449,28 +449,28 @@ restore(Edit *edit, int ctlfd) int64_t offset; offset = edit->disk->offset; - fprint(2, "attempting to restore partitions to previous state\n"); + jehanne_fprint(2, "attempting to restore partitions to previous state\n"); if(seek(edit->disk->wfd, edit->disk->secsize, 0) != 0){ - fprint(2, "cannot restore: error seeking on disk\n"); - exits("inconsistent"); + jehanne_fprint(2, "cannot restore: error seeking on disk\n"); + jehanne_exits("inconsistent"); } if(write(edit->disk->wfd, osecbuf, edit->disk->secsize) != edit->disk->secsize){ - fprint(2, "cannot restore: couldn't write old partition table to disk\n"); - exits("inconsistent"); + jehanne_fprint(2, "cannot restore: couldn't write old partition table to disk\n"); + jehanne_exits("inconsistent"); } if(ctlfd >= 0){ for(i=0; inpart; i++) - fprint(ctlfd, "delpart %s", edit->part[i]->name); + jehanne_fprint(ctlfd, "delpart %s", edit->part[i]->name); for(i=0; iname, opart[i]->start+offset, opart[i]->end+offset) < 0){ - fprint(2, "restored disk partition table but not kernel; reboot\n"); - exits("inconsistent"); + if(jehanne_fprint(ctlfd, "part %s %lld %lld", opart[i]->name, opart[i]->start+offset, opart[i]->end+offset) < 0){ + jehanne_fprint(2, "restored disk partition table but not kernel; reboot\n"); + jehanne_exits("inconsistent"); } } } - exits("restored"); + jehanne_exits("restored"); } static void @@ -481,24 +481,24 @@ wrpart(Edit *edit) disk = edit->disk; - memset(secbuf, 0, disk->secsize); + jehanne_memset(secbuf, 0, disk->secsize); n = 0; for(i=0; inpart; i++) - n += snprint(secbuf+n, disk->secsize-n, "part %s %lld %lld\n", + n += jehanne_snprint(secbuf+n, disk->secsize-n, "part %s %lld %lld\n", edit->part[i]->name, edit->part[i]->start, edit->part[i]->end); if(seek(disk->wfd, disk->secsize, 0) != disk->secsize){ - fprint(2, "error seeking %d %lld on disk: %r\n", disk->wfd, disk->secsize); - exits("seek"); + jehanne_fprint(2, "error seeking %d %lld on disk: %r\n", disk->wfd, disk->secsize); + jehanne_exits("seek"); } if(write(disk->wfd, secbuf, disk->secsize) != disk->secsize){ - fprint(2, "error writing partition table to disk\n"); + jehanne_fprint(2, "error writing partition table to disk\n"); restore(edit, -1); } if(ctldiff(edit, disk->ctlfd) < 0) - fprint(2, "?warning: partitions could not be updated in devsd\n"); + jehanne_fprint(2, "?warning: partitions could not be updated in devsd\n"); } /* @@ -518,11 +518,11 @@ checkfat(Disk *disk) if(buf[0] != 0xEB || buf[1] != 0x3C || buf[2] != 0x90) return; - fprint(2, + jehanne_fprint(2, "there's a fat partition where the\n" "plan9 partition table would go.\n" "if you really want to overwrite it, zero\n" "the second sector of the disk and try again\n"); - exits("fat partition"); + jehanne_exits("fat partition"); } diff --git a/sys/src/cmd/disk/prep/prep.json b/sys/src/cmd/disk/prep/prep.json index 3385d64..1409ebc 100644 --- a/sys/src/cmd/disk/prep/prep.json +++ b/sys/src/cmd/disk/prep/prep.json @@ -12,6 +12,7 @@ ], "Program": "prep", "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "prep.c", "edit.c", "y.tab.c" diff --git a/sys/src/cmd/disk/rofs/mkrofs.c b/sys/src/cmd/disk/rofs/mkrofs.c index f7b894f..48262d6 100644 --- a/sys/src/cmd/disk/rofs/mkrofs.c +++ b/sys/src/cmd/disk/rofs/mkrofs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/disk/rofs/rofs.c b/sys/src/cmd/disk/rofs/rofs.c index f97ca9e..11d52b2 100644 --- a/sys/src/cmd/disk/rofs/rofs.c +++ b/sys/src/cmd/disk/rofs/rofs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/cmd/dossrv/chat.c b/sys/src/cmd/dossrv/chat.c index e025344..4b0d31b 100644 --- a/sys/src/cmd/dossrv/chat.c +++ b/sys/src/cmd/dossrv/chat.c @@ -25,7 +25,7 @@ chat(char *fmt, ...) if (!chatty) return; va_start(arg, fmt); - vfprint(2, fmt, arg); + jehanne_vfprint(2, fmt, arg); va_end(arg); } @@ -34,12 +34,12 @@ panic(char *fmt, ...) { va_list arg; - fprint(2, "%s %d: panic ", argv0, getpid()); + jehanne_fprint(2, "%s %d: panic ", argv0, jehanne_getpid()); va_start(arg, fmt); - vfprint(2, fmt, arg); + jehanne_vfprint(2, fmt, arg); va_end(arg); - fprint(2, ": %r\n"); + jehanne_fprint(2, ": %r\n"); if(doabort) abort(); - exits("panic"); + jehanne_exits("panic"); } diff --git a/sys/src/cmd/dossrv/devio.c b/sys/src/cmd/dossrv/devio.c index 96fde93..95d4cec 100644 --- a/sys/src/cmd/dossrv/devio.c +++ b/sys/src/cmd/dossrv/devio.c @@ -25,7 +25,7 @@ deverror(char *name, Xfs *xf, int32_t addr, int32_t n, int32_t nret) xf->dev = -1; return -1; } - fprint(2, "dev %d sector %ld, %s: %ld, should be %ld\n", xf->dev, addr, name, nret, n); + jehanne_fprint(2, "dev %d sector %ld, %s: %ld, should be %ld\n", xf->dev, addr, name, nret, n); return -1; } diff --git a/sys/src/cmd/dossrv/dosfs.c b/sys/src/cmd/dossrv/dosfs.c index 7238f06..7ed7d41 100644 --- a/sys/src/cmd/dossrv/dosfs.c +++ b/sys/src/cmd/dossrv/dosfs.c @@ -62,7 +62,7 @@ rattach(void) root->qid.path = 0; root->qid.vers = 0; root->xf->rootqid = root->qid; - dp = malloc(sizeof(Dosptr)); + dp = jehanne_malloc(sizeof(Dosptr)); if(dp == nil){ errno = Enomem; goto error; @@ -87,7 +87,7 @@ doclone(Xfile *of, int newfid) errno = Enomem; return nil; } - dp = malloc(sizeof(Dosptr)); + dp = jehanne_malloc(sizeof(Dosptr)); if(dp == nil){ errno = Enomem; return nil; @@ -98,7 +98,7 @@ doclone(Xfile *of, int newfid) nf->fid = req->newfid; nf->ptr = dp; refxfs(nf->xf, 1); - memmove(dp, of->ptr, sizeof(Dosptr)); + jehanne_memmove(dp, of->ptr, sizeof(Dosptr)); dp->p = nil; dp->d = nil; return nf; @@ -129,21 +129,21 @@ rwalk(void) } saveqid = f->qid; - memmove(savedp, f->ptr, sizeof(Dosptr)); + jehanne_memmove(savedp, f->ptr, sizeof(Dosptr)); for(; rep->nwqid < req->nwname && rep->nwqid < MAXWELEM; rep->nwqid++){ chat("\twalking %s\n", req->wname[rep->nwqid]); if(!(f->qid.type & QTDIR)){ chat("\tnot dir: type=%#x\n", f->qid.type); goto error; } - if(strcmp(req->wname[rep->nwqid], ".") == 0){ + if(jehanne_strcmp(req->wname[rep->nwqid], ".") == 0){ ; - }else if(strcmp(req->wname[rep->nwqid], "..") == 0){ + }else if(jehanne_strcmp(req->wname[rep->nwqid], "..") == 0){ if(f->qid.path != f->xf->rootqid.path){ r = walkup(f, dp); if(r < 0) goto error; - memmove(f->ptr, dp, sizeof(Dosptr)); + jehanne_memmove(f->ptr, dp, sizeof(Dosptr)); if(isroot(dp->addr)) f->qid.path = f->xf->rootqid.path; else @@ -163,7 +163,7 @@ rwalk(void) putfile(f); if(r < 0) goto error; - memmove(f->ptr, dp, sizeof(Dosptr)); + jehanne_memmove(f->ptr, dp, sizeof(Dosptr)); f->qid.path = QIDPATH(dp); f->qid.type = QTFILE; if(isroot(dp->addr)) @@ -183,7 +183,7 @@ rwalk(void) return; error: f->qid = saveqid; - memmove(f->ptr, savedp, sizeof(Dosptr)); + jehanne_memmove(f->ptr, savedp, sizeof(Dosptr)); if(nf != nil) xfile(req->newfid, Clunk); error2: @@ -274,7 +274,7 @@ mk8dot3name(Xfile *f, Dosptr *ndp, char *name, char *sname) Dosptr tmpdp; int i, longtype; - if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) + if(jehanne_strcmp(name, ".") == 0 || jehanne_strcmp(name, "..") == 0) return Invalid; /* @@ -294,7 +294,7 @@ mk8dot3name(Xfile *f, Dosptr *ndp, char *name, char *sname) * alias is the upper-case version, which we * already know does not exist. */ - strcpy(sname, name); + jehanne_strcpy(sname, name); for(i=0; sname[i]; i++) if('a' <= sname[i] && sname[i] <= 'z') sname[i] += 'A'-'a'; @@ -334,7 +334,7 @@ mkdentry(Xfs *xf, Dosptr *ndp, char *name, char *sname, int longtype, ndp->d = (Dosdir *)&ndp->p->iobuf[ndp->offset]; nd = ndp->d; - memset(nd, 0, DOSDIRSIZE); + jehanne_memset(nd, 0, DOSDIRSIZE); if(longtype!=Short) name = sname; @@ -408,7 +408,7 @@ badperm: * check the name, find the slot for the dentry, * and find a good alias for a long name */ - ndp = malloc(sizeof(Dosptr)); + ndp = jehanne_malloc(sizeof(Dosptr)); if(ndp == nil){ putfile(f); errno = Enomem; @@ -417,7 +417,7 @@ badperm: longtype = mk8dot3name(f, ndp, req->name, sname); chat("rcreate %s longtype %d...\n", req->name, longtype); if(longtype == Invalid){ - free(ndp); + jehanne_free(ndp); goto badperm; } @@ -432,7 +432,7 @@ badperm: start = falloc(f->xf); unmlock(bp); if(start <= 0){ - free(ndp); + jehanne_free(ndp); putfile(f); errno = Eio; return; @@ -451,7 +451,7 @@ badperm: if(mkdentry(f->xf, ndp, req->name, sname, longtype, nattr, start, 0) < 0){ if(ndp->p != nil) putsect(ndp->p); - free(ndp); + jehanne_free(ndp); if(start > 0) ffree(f->xf, start); putfile(f); @@ -479,18 +479,18 @@ badperm: goto badio; } xd = (Dosdir *)&xp->iobuf[0]; - memmove(xd, ndp->d, DOSDIRSIZE); - memset(xd->name, ' ', sizeof xd->name+sizeof xd->ext); + jehanne_memmove(xd, ndp->d, DOSDIRSIZE); + jehanne_memset(xd->name, ' ', sizeof xd->name+sizeof xd->ext); xd->name[0] = '.'; xd = (Dosdir *)&xp->iobuf[DOSDIRSIZE]; if(pd) - memmove(xd, pd, DOSDIRSIZE); + jehanne_memmove(xd, pd, DOSDIRSIZE); else{ - memset(xd, 0, DOSDIRSIZE); + jehanne_memset(xd, 0, DOSDIRSIZE); puttime(xd, 0); xd->attr = DDIR; } - memset(xd->name, ' ', sizeof xd->name+sizeof xd->ext); + jehanne_memset(xd->name, ' ', sizeof xd->name+sizeof xd->ext); xd->name[0] = '.'; xd->name[1] = '.'; xp->flags |= BMOD; @@ -504,7 +504,7 @@ badperm: badio: putfile(f); putsect(pdp->p); - free(pdp); + jehanne_free(pdp); } void @@ -657,7 +657,7 @@ dostat(Xfile *f, Dir *d) dp = f->ptr; if(isroot(dp->addr)){ - memset(d, 0, sizeof(Dir)); + jehanne_memset(d, 0, sizeof(Dir)); d->name = "/"; d->qid.type = QTDIR; d->qid.path = f->xf->rootqid.path; @@ -688,7 +688,7 @@ dostat(Xfile *f, Dir *d) } getdir(f->xf, d, dp->d, dp->addr, dp->offset); if(islong && sum == -1 && nameok(namebuf)) - strcpy(d->name, namebuf); + jehanne_strcpy(d->name, namebuf); } } @@ -707,7 +707,7 @@ rstat(void) dir.name = repdata; dostat(f, &dir); - rep->nstat = convD2M(&dir, statbuf, sizeof statbuf); + rep->nstat = jehanne_convD2M(&dir, statbuf, sizeof statbuf); rep->stat = statbuf; putfile(f); } @@ -740,7 +740,7 @@ rwstat(void) changes = 0; dir.name = repdata; dostat(f, &dir); - if(convM2D(req->stat, req->nstat, &wdir, (char*)statbuf) != req->nstat){ + if(jehanne_convM2D(req->stat, req->nstat, &wdir, (char*)statbuf) != req->nstat){ errno = Ebadstat; goto out; } @@ -759,8 +759,8 @@ rwstat(void) /* * no chown or chgrp */ - if(wdir.uid[0] != '\0' && strcmp(dir.uid, wdir.uid) != 0 - || wdir.gid[0] != '\0' && strcmp(dir.gid, wdir.gid) != 0){ + if(wdir.uid[0] != '\0' && jehanne_strcmp(dir.uid, wdir.uid) != 0 + || wdir.gid[0] != '\0' && jehanne_strcmp(dir.gid, wdir.gid) != 0){ errno = Eperm; goto out; } @@ -806,8 +806,8 @@ rwstat(void) * we need to remove the old entry before creating the new one * to avoid a lock loop. */ - if(wdir.name[0] != '\0' && strcmp(dir.name, wdir.name) != 0){ - if(utflen(wdir.name) >= DOSNAMELEN){ + if(wdir.name[0] != '\0' && jehanne_strcmp(dir.name, wdir.name) != 0){ + if(jehanne_utflen(wdir.name) >= DOSNAMELEN){ errno = Etoolong; goto out; } @@ -847,7 +847,7 @@ rwstat(void) */ putfile(f); pf = *f; - memset(&pdp, 0, sizeof(Dosptr)); + jehanne_memset(&pdp, 0, sizeof(Dosptr)); pdp.prevaddr = -1; pdp.naddr = -1; pdp.addr = dp->paddr; diff --git a/sys/src/cmd/dossrv/dossubs.c b/sys/src/cmd/dossrv/dossubs.c index 5cb18d4..5fc704a 100644 --- a/sys/src/cmd/dossrv/dossubs.c +++ b/sys/src/cmd/dossrv/dossubs.c @@ -40,7 +40,7 @@ isdosfs(uint8_t *buf) if(buf[0] == 0xEB && buf[2] == 0x90 /* && buf[1] >= 0x30 */) return 1; if(chatty) - fprint(2, "bad sig %.2ux %.2ux %.2uxn", buf[0], buf[1], buf[2]); + jehanne_fprint(2, "bad sig %.2ux %.2ux %.2uxn", buf[0], buf[1], buf[2]); return 0; } @@ -91,8 +91,8 @@ dosfs(Xfs *xf) return -1; } - bp = malloc(sizeof(Dosbpb)); - memset(bp, 0, sizeof(Dosbpb)); /* clear lock */ + bp = jehanne_malloc(sizeof(Dosbpb)); + jehanne_memset(bp, 0, sizeof(Dosbpb)); /* clear lock */ xf->ptr = bp; xf->fmt = 1; @@ -119,7 +119,7 @@ dosfs(Xfs *xf) if(bp->fatsize == 0){ putsect(p); if(chatty) - fprint(2, "fatsize 0\n"); + jehanne_fprint(2, "fatsize 0\n"); return -1; } bp->dataaddr = bp->fataddr + bp->nfats*bp->fatsize; @@ -197,7 +197,7 @@ rootfile(Xfile *f) Dosptr *dp; dp = f->ptr; - memset(dp, 0, sizeof(Dosptr)); + jehanne_memset(dp, 0, sizeof(Dosptr)); dp->prevaddr = -1; } @@ -422,7 +422,7 @@ classifyname(char *buf) else if(c == '.'){ dot = p; ndot++; - }else if(strchr("+,:;=[] ", c)) + }else if(jehanne_strchr("+,:;=[] ", c)) isextended = 1; else if(!isdos[c]) return Invalid; @@ -451,9 +451,9 @@ mkalias(char *name, char *sname, int id) char *s, *e, sid[10]; int i, esuf, v; - e = strrchr(name, '.'); + e = jehanne_strrchr(name, '.'); if(e == nil) - e = strchr(name, '\0'); + e = jehanne_strchr(name, '\0'); s = name; i = 0; @@ -461,14 +461,14 @@ mkalias(char *name, char *sname, int id) if(isdos[(uint8_t)*s]) sname[i++] = *s++; else - s += chartorune(&r, s); + s += jehanne_chartorune(&r, s); } - v = snprint(sid, 10, "%d", id); + v = jehanne_snprint(sid, 10, "%d", id); if(i + 1 + v > 8) i = 8 - 1 - v; sname[i++] = '~'; - strcpy(&sname[i], sid); + jehanne_strcpy(&sname[i], sid); i += v; sname[i++] = '.'; @@ -479,7 +479,7 @@ mkalias(char *name, char *sname, int id) if(isdos[(uint8_t)*e]) sname[i++] = *e++; else - e += chartorune(&r, e); + e += jehanne_chartorune(&r, e); } if(sname[i-1] == '.') i--; @@ -538,9 +538,9 @@ searchdir(Xfile *f, char *name, Dosptr *dp, int cflag, int longtype) need = 1; if(longtype!=Short && cflag) - need += (utflen(name) + DOSRUNE-1) / DOSRUNE; + need += (jehanne_utflen(name) + DOSRUNE-1) / DOSRUNE; - memset(dp, 0, sizeof(Dosptr)); + jehanne_memset(dp, 0, sizeof(Dosptr)); dp->prevaddr = -1; dp->naddr = -1; dp->paddr = ((Dosptr *)f->ptr)->addr; @@ -594,7 +594,7 @@ searchdir(Xfile *f, char *name, Dosptr *dp, int cflag, int longtype) } if(d->name[0] == DOSEMPTY){ if(chatty) - fprint(2, "empty dir\n"); + jehanne_fprint(2, "empty dir\n"); have++; if(addr1 == -1){ @@ -619,15 +619,15 @@ searchdir(Xfile *f, char *name, Dosptr *dp, int cflag, int longtype) islong = 0; continue; } - if(islong != 1 || sum != aliassum(d) || cistrcmp(bname, name) != 0){ + if(islong != 1 || sum != aliassum(d) || jehanne_cistrcmp(bname, name) != 0){ bname = buf; getname(buf, d); } islong = 0; - if(cistrcmp(bname, name) != 0) + if(jehanne_cistrcmp(bname, name) != 0) continue; if(chatty) - fprint(2, "found\n"); + jehanne_fprint(2, "found\n"); if(cflag){ putsect(p); return -1; @@ -740,7 +740,7 @@ readdir(Xfile *f, void *vbuf, int32_t offset, int32_t count) if(islong == 1 && nameok(name) && sum == aliassum(d)) dir.name = name; islong = 0; - n = convD2M(&dir, &buf[rcnt], count - rcnt); + n = jehanne_convD2M(&dir, &buf[rcnt], count - rcnt); name = nil; if(n <= BIT16SZ){ /* no room for next entry */ putsect(p); @@ -778,7 +778,7 @@ walkup(Xfile *f, Dosptr *ndp) bp = f->xf->ptr; dp = f->ptr; - memset(ndp, 0, sizeof(Dosptr)); + jehanne_memset(ndp, 0, sizeof(Dosptr)); ndp->prevaddr = -1; ndp->naddr = -1; ndp->addr = dp->paddr; @@ -960,7 +960,7 @@ readfile(Xfile *f, void *vbuf, int32_t offset, int32_t count) p = getsect(xf, addr); if(p == 0) return -1; - memmove(&buf[rcnt], &p->iobuf[o], c); + jehanne_memmove(&buf[rcnt], &p->iobuf[o], c); putsect(p); count -= c; rcnt += c; @@ -999,7 +999,7 @@ writefile(Xfile *f, void *vbuf, int32_t offset, int32_t count) if(p == nil) return -1; } - memmove(&p->iobuf[o], &buf[rcnt], c); + jehanne_memmove(&p->iobuf[o], &buf[rcnt], c); p->flags |= BMOD; putsect(p); count -= c; @@ -1149,21 +1149,21 @@ getnamerunes(char *dst, uint8_t *buf, int step) r = 1; for(i = 1; r && i < 11; i += 2){ r = buf[i] | (buf[i+1] << 8); - d += runetochar(d, &r); + d += jehanne_runetochar(d, &r); } for(i = 14; r && i < 26; i += 2){ r = buf[i] | (buf[i+1] << 8); - d += runetochar(d, &r); + d += jehanne_runetochar(d, &r); } for(i = 28; r && i < 32; i += 2){ r = buf[i] | (buf[i+1] << 8); - d += runetochar(d, &r); + d += jehanne_runetochar(d, &r); } if(step == 1) dst -= d - dbuf; - memmove(dst, dbuf, d - dbuf); + jehanne_memmove(dst, dbuf, d - dbuf); if(step == -1){ dst += d - dbuf; @@ -1222,18 +1222,18 @@ putname(char *p, Dosdir *d) { int i; - memset(d->name, ' ', sizeof d->name+sizeof d->ext); + jehanne_memset(d->name, ' ', sizeof d->name+sizeof d->ext); for(i=0; iname; i++){ if(*p == 0 || *p == '.') break; - d->name[i] = toupper(*p++); + d->name[i] = jehanne_toupper(*p++); } - p = strrchr(p, '.'); + p = jehanne_strrchr(p, '.'); if(p){ for(i=0; iext; i++){ if(*++p == 0) break; - d->ext[i] = toupper(*p); + d->ext[i] = jehanne_toupper(*p); } } } @@ -1245,7 +1245,7 @@ putnamesect(uint8_t *slot, Rune *longname, int curslot, int first, int sum) Dosdir ds; int i, j; - memset(&ds, 0xff, sizeof ds); + jehanne_memset(&ds, 0xff, sizeof ds); ds.attr = 0xf; ds.reserved[0] = 0; ds.reserved[1] = sum; @@ -1255,7 +1255,7 @@ putnamesect(uint8_t *slot, Rune *longname, int curslot, int first, int sum) ds.name[0] = 0x40 | curslot; else ds.name[0] = curslot; - memmove(slot, &ds, sizeof ds); + jehanne_memmove(slot, &ds, sizeof ds); j = (curslot-1) * DOSRUNE; @@ -1620,7 +1620,7 @@ makecontig(Xfile *f, int nextra) return -1; wp = getosect(xf, ws); assert(wp != nil); - memmove(wp->iobuf, rp->iobuf, bp->sectsize); + jehanne_memmove(wp->iobuf, rp->iobuf, bp->sectsize); wp->flags = BMOD; putsect(rp); putsect(wp); @@ -1688,7 +1688,7 @@ falloc(Xfs *xf) k = clust2sect(bp, n); for(i=0; iclustsize; i++){ p = getosect(xf, k+i); - memset(p->iobuf, 0, bp->sectsize); + jehanne_memset(p->iobuf, 0, bp->sectsize); p->flags = BMOD; putsect(p); } @@ -1724,8 +1724,8 @@ puttime(Dosdir *d, int32_t s) uint16_t x; if(s == 0) - s = time(0); - t = localtime(s); + s = jehanne_time(0); + t = jehanne_localtime(s); x = (t->hour<<11) | (t->min<<5) | (t->sec>>1); PSHORT(d->time, x); @@ -1751,7 +1751,7 @@ gtime(Dosdir *dp) tm.tzoff = 0; tm.yday = 0; - return tm2sec(&tm); + return jehanne_tm2sec(&tm); } /* @@ -1827,38 +1827,38 @@ bootsecdump32(int fd, Xfs *xf, Dosboot32 *b32) Iosect *p1; int fisec, bsec, res; - fprint(fd, "\nfat32\n"); + jehanne_fprint(fd, "\nfat32\n"); bootdump32(fd, b32); res = GSHORT(b32->nresrv); bsec = GSHORT(b32->backupboot); if(bsec < res && bsec != 0){ p1 = getsect(xf, bsec); if(p1 == nil) - fprint(fd, "\ncouldn't get backup boot sector: %r\n"); + jehanne_fprint(fd, "\ncouldn't get backup boot sector: %r\n"); else{ - fprint(fd, "\nbackup boot\n"); + jehanne_fprint(fd, "\nbackup boot\n"); bootdump32(fd, (Dosboot32*)p1->iobuf); putsect(p1); } }else if(bsec != 0xffff) - fprint(fd, "bad backup boot sector: %d reserved %d\n", bsec, res); + jehanne_fprint(fd, "bad backup boot sector: %d reserved %d\n", bsec, res); fisec = GSHORT(b32->infospec); if(fisec < res && fisec != 0){ p1 = getsect(xf, fisec); if(p1 == nil) - fprint(fd, "\ncouldn't get fat info sector: %r\n"); + jehanne_fprint(fd, "\ncouldn't get fat info sector: %r\n"); else{ - fprint(fd, "\nfat info %d\n", fisec); + jehanne_fprint(fd, "\nfat info %d\n", fisec); fi = (Fatinfo*)p1->iobuf; - fprint(fd, "sig1: 0x%lux sb 0x%lux\n", GLONG(fi->sig1), FATINFOSIG1); - fprint(fd, "sig: 0x%lux sb 0x%lux\n", GLONG(fi->sig), FATINFOSIG); - fprint(fd, "freeclust: %lud\n", GLONG(fi->freeclust)); - fprint(fd, "nextfree: %lud\n", GLONG(fi->nextfree)); - fprint(fd, "reserved: %lud %lud %lud\n", GLONG(fi->resrv), GLONG(fi->resrv+4), GLONG(fi->resrv+8)); + jehanne_fprint(fd, "sig1: 0x%lux sb 0x%lux\n", GLONG(fi->sig1), FATINFOSIG1); + jehanne_fprint(fd, "sig: 0x%lux sb 0x%lux\n", GLONG(fi->sig), FATINFOSIG); + jehanne_fprint(fd, "freeclust: %lud\n", GLONG(fi->freeclust)); + jehanne_fprint(fd, "nextfree: %lud\n", GLONG(fi->nextfree)); + jehanne_fprint(fd, "reserved: %lud %lud %lud\n", GLONG(fi->resrv), GLONG(fi->resrv+4), GLONG(fi->resrv+8)); putsect(p1); } }else if(fisec != 0xffff) - fprint(2, "bad fat info sector: %d reserved %d\n", bsec, res); + jehanne_fprint(2, "bad fat info sector: %d reserved %d\n", bsec, res); } void @@ -1882,27 +1882,27 @@ dirdump(void *vdbuf) name = namebuf + DOSNAMELEN; *--name = '\0'; name = getnamerunes(name, dbuf, 1); - seprint(buf, ebuf, "\"%s\" %2.2x %2.2ux %2.2ux %d", name, dbuf[0], dbuf[12], dbuf[13], GSHORT(d->start)); + jehanne_seprint(buf, ebuf, "\"%s\" %2.2x %2.2ux %2.2ux %d", name, dbuf[0], dbuf[12], dbuf[13], GSHORT(d->start)); }else{ - s = seprint(buf, ebuf, "\"%.8s.%.3s\" ", (char*)d->name, + s = jehanne_seprint(buf, ebuf, "\"%.8s.%.3s\" ", (char*)d->name, (char*)d->ext); for(i=7; i>=0; i--) *s++ = d->attr&(1<time); - s = seprint(s, ebuf, " %2.2d:%2.2d:%2.2d", i>>11, (i>>5)&63, (i&31)<<1); + s = jehanne_seprint(s, ebuf, " %2.2d:%2.2d:%2.2d", i>>11, (i>>5)&63, (i&31)<<1); i = GSHORT(d->date); - s = seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); + s = jehanne_seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); i = GSHORT(d->ctime); - s = seprint(s, ebuf, " %2.2d:%2.2d:%2.2d", i>>11, (i>>5)&63, (i&31)<<1); + s = jehanne_seprint(s, ebuf, " %2.2d:%2.2d:%2.2d", i>>11, (i>>5)&63, (i&31)<<1); i = GSHORT(d->cdate); - s = seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); + s = jehanne_seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); i = GSHORT(d->adate); - s = seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); + s = jehanne_seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31); - seprint(s, ebuf, " %d %d", GSHORT(d->start), GSHORT(d->length)); + jehanne_seprint(s, ebuf, " %d %d", GSHORT(d->start), GSHORT(d->length)); } chat("%s\n", buf); } @@ -1941,7 +1941,7 @@ utftorunes(Rune *rr, char *s, int n) *r = c; s++; }else - s += chartorune(r, s); + s += jehanne_chartorune(r, s); r++; if(r >= re) break; diff --git a/sys/src/cmd/dossrv/fns.h b/sys/src/cmd/dossrv/fns.h index 2b531e5..d6af2cc 100644 --- a/sys/src/cmd/dossrv/fns.h +++ b/sys/src/cmd/dossrv/fns.h @@ -14,7 +14,7 @@ void bootsecdump32(int fd, Xfs *xf, Dosboot32 *b32); int cfalloc(Xfile*); void chat(char*, ...); #pragma varargck argpos chat 1 -int cistrcmp(const char*, const char*); +int jehanne_cistrcmp(const char*, const char*); int classifyname(char*); Xfile *clean(Xfile*); int32_t clust2sect(Dosbpb*, int32_t); diff --git a/sys/src/cmd/dossrv/iotrack.c b/sys/src/cmd/dossrv/iotrack.c index 1800885..4c2d1ee 100644 --- a/sys/src/cmd/dossrv/iotrack.c +++ b/sys/src/cmd/dossrv/iotrack.c @@ -139,7 +139,7 @@ loop: } unmlock(&mp->lock); if(p == mp){ - print("iotrack all ref'd\n"); + jehanne_print("iotrack all ref'd\n"); goto loop; } if(p->flags & BMOD){ @@ -235,7 +235,7 @@ tread(Iotrack *t) } for(i=0; itp->p[i] == 0){ - memmove(t->tp->buf[i], buf[i], Sectorsize); + jehanne_memmove(t->tp->buf[i], buf[i], Sectorsize); chat("%d ", i); } chat("done]"); @@ -293,7 +293,7 @@ iotrack_init(void) p->prev = p->next = p; TOFRONT(mp, p); p->tp = sbrk(sizeof(Track)); - memset(p->tp->p, 0, sizeof p->tp->p); + jehanne_memset(p->tp->p, 0, sizeof p->tp->p); } } @@ -309,7 +309,7 @@ newsect(void) if(p = freelist) /* assign = */ freelist = p->next; else - p = malloc(sizeof(Iosect)); + p = jehanne_malloc(sizeof(Iosect)); unmlock(&freelock); p->next = 0; return p; diff --git a/sys/src/cmd/dossrv/xfile.c b/sys/src/cmd/dossrv/xfile.c index 3408755..592d7ac 100644 --- a/sys/src/cmd/dossrv/xfile.c +++ b/sys/src/cmd/dossrv/xfile.c @@ -56,9 +56,9 @@ getxfs(char *user, char *name) * of a boot manager programme at the beginning of the disc. */ offset = 0; - if(p = strrchr(name, ':')){ + if(p = jehanne_strrchr(name, ':')){ *p++ = 0; - offset = strtol(p, &q, 0); + offset = jehanne_strtol(p, &q, 0); chat("name %s, offset %ld\n", p, offset); if(offset < 0 || p == q){ errno = Enofilsys; @@ -83,7 +83,7 @@ getxfs(char *user, char *name) errno = Eerrstr; return 0; } - dir = dirfstat(fd); + dir = jehanne_dirfstat(fd); if(dir == nil){ errno = Eio; close(fd); @@ -91,7 +91,7 @@ getxfs(char *user, char *name) } dqid = dir->qid; - free(dir); + jehanne_free(dir); mlock(&xlock); for(fxf=0,xf=xhead; xf; xf=xf->next){ if(xf->ref == 0){ @@ -101,7 +101,7 @@ getxfs(char *user, char *name) } if(!eqqid(xf->qid, dqid)) continue; - if(strcmp(xf->name, name) != 0 || xf->dev < 0) + if(jehanne_strcmp(xf->name, name) != 0 || xf->dev < 0) continue; if(devcheck(xf) < 0) /* look for media change */ continue; @@ -114,7 +114,7 @@ getxfs(char *user, char *name) return xf; } if(fxf == nil){ - fxf = malloc(sizeof(Xfs)); + fxf = jehanne_malloc(sizeof(Xfs)); if(fxf == nil){ unmlock(&xlock); close(fd); @@ -125,7 +125,7 @@ getxfs(char *user, char *name) xhead = fxf; } chat("alloc \"%s\", dev=%d...", name, fd); - fxf->name = strdup(name); + fxf->name = jehanne_strdup(name); fxf->ref = 1; fxf->qid = dqid; fxf->dev = fd; @@ -145,8 +145,8 @@ refxfs(Xfs *xf, int delta) xf->ref += delta; if(xf->ref == 0){ chat("free \"%s\", dev=%d...", xf->name, xf->dev); - free(xf->name); - free(xf->ptr); + jehanne_free(xf->name); + jehanne_free(xf->ptr); purgebuf(xf); if(xf->dev >= 0){ close(xf->dev); @@ -206,7 +206,7 @@ xfile(int fid, int flag) unmlock(&freelock); } else { unmlock(&freelock); - f = malloc(sizeof(Xfile)); + f = jehanne_malloc(sizeof(Xfile)); if(f == nil){ errno = Enomem; return nil; @@ -228,7 +228,7 @@ Xfile * clean(Xfile *f) { if(f->ptr){ - free(f->ptr); + jehanne_free(f->ptr); f->ptr = nil; } if(f->xf){ @@ -256,7 +256,7 @@ dosptrreloc(Xfile *f, Dosptr *dp, uint32_t addr, uint32_t offset) xdp = p->ptr; if(p != f && p->xf == f->xf && xdp != nil && xdp->addr == addr && xdp->offset == offset){ - memmove(xdp, dp, sizeof(Dosptr)); + jehanne_memmove(xdp, dp, sizeof(Dosptr)); xdp->p = nil; xdp->d = nil; p->qid.path = QIDPATH(xdp); diff --git a/sys/src/cmd/dossrv/xfssrv.c b/sys/src/cmd/dossrv/xfssrv.c index 94f5550..aa2225a 100644 --- a/sys/src/cmd/dossrv/xfssrv.c +++ b/sys/src/cmd/dossrv/xfssrv.c @@ -52,8 +52,8 @@ void (*fcalls[])(void) = { void usage(void) { - fprint(2, "usage: %s [-v] [-s] [-f devicefile] [srvname]\n", argv0); - exits("usage"); + jehanne_fprint(2, "usage: %s [-v] [-s] [-f devicefile] [srvname]\n", argv0); + jehanne_exits("usage"); } void @@ -61,8 +61,8 @@ main(int argc, char **argv) { int stdio, srvfd, pipefd[2]; - rep = malloc(sizeof(Fcall)); - req = malloc(Reqsize); + rep = jehanne_malloc(sizeof(Fcall)); + req = jehanne_malloc(Reqsize); if(rep == nil || req == nil) panic("out of memory"); stdio = 0; @@ -90,9 +90,9 @@ main(int argc, char **argv) }ARGEND if(argc == 0) - strcpy(srvfile, "#s/dos"); + jehanne_strcpy(srvfile, "#s/dos"); else if(argc == 1) - snprint(srvfile, sizeof srvfile, "#s/%s", argv[0]); + jehanne_snprint(srvfile, sizeof srvfile, "#s/%s", argv[0]); else usage(); @@ -104,15 +104,15 @@ main(int argc, char **argv) close(1); open("/dev/null", OREAD); open("/dev/null", OWRITE); - if(pipe(pipefd) < 0) + if(jehanne_pipe(pipefd) < 0) panic("pipe"); - srvfd = ocreate(srvfile, OWRITE|ORCLOSE, 0600); + srvfd = jehanne_ocreate(srvfile, OWRITE|ORCLOSE, 0600); if(srvfd < 0) panic(srvfile); - fprint(srvfd, "%d", pipefd[0]); + jehanne_fprint(srvfd, "%d", pipefd[0]); close(pipefd[0]); - atexit(rmservice); - fprint(2, "%s: serving %s\n", argv0, srvfile); + jehanne_atexit(rmservice); + jehanne_fprint(2, "%s: serving %s\n", argv0, srvfile); } srvfd = pipefd[1]; @@ -133,7 +133,7 @@ main(int argc, char **argv) } io(srvfd); - exits(0); + jehanne_exits(0); } void @@ -141,9 +141,9 @@ io(int srvfd) { int n, pid; - pid = getpid(); + pid = jehanne_getpid(); - fmtinstall('F', fcallfmt); + jehanne_fmtinstall('F', fcallfmt); for(;;){ /* * reading from a pipe or a network device @@ -162,7 +162,7 @@ io(int srvfd) continue; if(chatty) - fprint(2, "dossrv %d:<-%F\n", pid, req); + jehanne_fprint(2, "dossrv %d:<-%F\n", pid, req); errno = 0; if(!fcalls[req->type]) @@ -178,7 +178,7 @@ io(int srvfd) } rep->tag = req->tag; if(chatty) - fprint(2, "dossrv %d:->%F\n", pid, rep); + jehanne_fprint(2, "dossrv %d:->%F\n", pid, rep); n = convS2M(rep, mdata, sizeof mdata); if(n == 0) panic("convS2M error on write"); diff --git a/sys/src/cmd/du.c b/sys/src/cmd/du.c index b5fe0c0..3b33328 100644 --- a/sys/src/cmd/du.c +++ b/sys/src/cmd/du.c @@ -11,7 +11,7 @@ * du - print disk usage */ #include -#include +#include #include extern int64_t du(char*, Dir*); diff --git a/sys/src/cmd/echo.c b/sys/src/cmd/echo.c index eeea8eb..67861d5 100644 --- a/sys/src/cmd/echo.c +++ b/sys/src/cmd/echo.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/sys/src/cmd/ed.c b/sys/src/cmd/ed.c index 87b9321..cb243b6 100644 --- a/sys/src/cmd/ed.c +++ b/sys/src/cmd/ed.c @@ -11,7 +11,7 @@ * Editor */ #include -#include +#include #include #include diff --git a/sys/src/cmd/exportfs/exportfs.c b/sys/src/cmd/exportfs/exportfs.c index bc35b7d..7042f1b 100644 --- a/sys/src/cmd/exportfs/exportfs.c +++ b/sys/src/cmd/exportfs/exportfs.c @@ -11,7 +11,7 @@ * exportfs - Export a plan 9 name space across a network */ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/cmd/exportfs/exportsrv.c b/sys/src/cmd/exportfs/exportsrv.c index 5d74ba5..35d9127 100644 --- a/sys/src/cmd/exportfs/exportsrv.c +++ b/sys/src/cmd/exportfs/exportsrv.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include <9P2000.h> #include "exportfs.h" diff --git a/sys/src/cmd/exportfs/pattern.c b/sys/src/cmd/exportfs/pattern.c index a227cd6..e3d4df3 100644 --- a/sys/src/cmd/exportfs/pattern.c +++ b/sys/src/cmd/exportfs/pattern.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> #include #include diff --git a/sys/src/cmd/fcp.c b/sys/src/cmd/fcp.c index 0968dff..739d3af 100644 --- a/sys/src/cmd/fcp.c +++ b/sys/src/cmd/fcp.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define DEFB (8*1024) #define Nwork 16 diff --git a/sys/src/cmd/field.c b/sys/src/cmd/field.c index 79945b8..2c96fdf 100644 --- a/sys/src/cmd/field.c +++ b/sys/src/cmd/field.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/flip.c b/sys/src/cmd/flip.c index 41a55b5..26a0759 100644 --- a/sys/src/cmd/flip.c +++ b/sys/src/cmd/flip.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include void diff --git a/sys/src/cmd/grep/build.json b/sys/src/cmd/grep/build.json index 3ddde8a..018c2f6 100644 --- a/sys/src/cmd/grep/build.json +++ b/sys/src/cmd/grep/build.json @@ -12,6 +12,7 @@ ], "Program": "grep", "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "comp.c", "main.c", "sub.c", diff --git a/sys/src/cmd/grep/grep.h b/sys/src/cmd/grep/grep.h index 761623d..845111a 100644 --- a/sys/src/cmd/grep/grep.h +++ b/sys/src/cmd/grep/grep.h @@ -8,7 +8,7 @@ */ #include -#include +#include #include #ifndef EXTERN diff --git a/sys/src/cmd/hget.c b/sys/src/cmd/hget.c index 60f500c..d33b21f 100644 --- a/sys/src/cmd/hget.c +++ b/sys/src/cmd/hget.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/hjfs/9p.c b/sys/src/cmd/hjfs/9p.c index ad65771..36a2e76 100644 --- a/sys/src/cmd/hjfs/9p.c +++ b/sys/src/cmd/hjfs/9p.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/hjfs/auth.c b/sys/src/cmd/hjfs/auth.c index a011f92..c36ade6 100644 --- a/sys/src/cmd/hjfs/auth.c +++ b/sys/src/cmd/hjfs/auth.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include "dat.h" diff --git a/sys/src/cmd/hjfs/buf.c b/sys/src/cmd/hjfs/buf.c index 9f7cb6f..176f700 100644 --- a/sys/src/cmd/hjfs/buf.c +++ b/sys/src/cmd/hjfs/buf.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hjfs/cons.c b/sys/src/cmd/hjfs/cons.c index a8ecd39..0d8766b 100644 --- a/sys/src/cmd/hjfs/cons.c +++ b/sys/src/cmd/hjfs/cons.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/cmd/hjfs/conv.c b/sys/src/cmd/hjfs/conv.c index 7015520..8998921 100644 --- a/sys/src/cmd/hjfs/conv.c +++ b/sys/src/cmd/hjfs/conv.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hjfs/dev.c b/sys/src/cmd/hjfs/dev.c index 8740471..440a339 100644 --- a/sys/src/cmd/hjfs/dev.c +++ b/sys/src/cmd/hjfs/dev.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hjfs/dump.c b/sys/src/cmd/hjfs/dump.c index 9401050..f631b52 100644 --- a/sys/src/cmd/hjfs/dump.c +++ b/sys/src/cmd/hjfs/dump.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include "dat.h" diff --git a/sys/src/cmd/hjfs/fs1.c b/sys/src/cmd/hjfs/fs1.c index 04b7d46..9233fea 100644 --- a/sys/src/cmd/hjfs/fs1.c +++ b/sys/src/cmd/hjfs/fs1.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include "dat.h" diff --git a/sys/src/cmd/hjfs/fs2.c b/sys/src/cmd/hjfs/fs2.c index dd4cfb3..b70bde8 100644 --- a/sys/src/cmd/hjfs/fs2.c +++ b/sys/src/cmd/hjfs/fs2.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include "dat.h" diff --git a/sys/src/cmd/hjfs/main.c b/sys/src/cmd/hjfs/main.c index a2fa7ad..eb862d8 100644 --- a/sys/src/cmd/hjfs/main.c +++ b/sys/src/cmd/hjfs/main.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "dat.h" diff --git a/sys/src/cmd/hmi/console/buffer.c b/sys/src/cmd/hmi/console/buffer.c index 5dfffa7..b0bbbed 100644 --- a/sys/src/cmd/hmi/console/buffer.c +++ b/sys/src/cmd/hmi/console/buffer.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/cga.c b/sys/src/cmd/hmi/console/cga.c index a7f8343..b847752 100644 --- a/sys/src/cmd/hmi/console/cga.c +++ b/sys/src/cmd/hmi/console/cga.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/comconsole.c b/sys/src/cmd/hmi/console/comconsole.c index 4e89da1..8b50cd3 100644 --- a/sys/src/cmd/hmi/console/comconsole.c +++ b/sys/src/cmd/hmi/console/comconsole.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/keyboard.c b/sys/src/cmd/hmi/console/keyboard.c index 1fb0667..0bfafed 100644 --- a/sys/src/cmd/hmi/console/keyboard.c +++ b/sys/src/cmd/hmi/console/keyboard.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/passthrough.c b/sys/src/cmd/hmi/console/passthrough.c index 6c3dbd9..875cfa6 100644 --- a/sys/src/cmd/hmi/console/passthrough.c +++ b/sys/src/cmd/hmi/console/passthrough.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/pipeconsole.c b/sys/src/cmd/hmi/console/pipeconsole.c index b96ca19..736defd 100644 --- a/sys/src/cmd/hmi/console/pipeconsole.c +++ b/sys/src/cmd/hmi/console/pipeconsole.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/screenconsole.c b/sys/src/cmd/hmi/console/screenconsole.c index f8ef2f5..b9a4890 100644 --- a/sys/src/cmd/hmi/console/screenconsole.c +++ b/sys/src/cmd/hmi/console/screenconsole.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include "console.h" diff --git a/sys/src/cmd/hmi/console/serve9p.c b/sys/src/cmd/hmi/console/serve9p.c index f18e589..1bea3e8 100644 --- a/sys/src/cmd/hmi/console/serve9p.c +++ b/sys/src/cmd/hmi/console/serve9p.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include <9P2000.h> #include "console.h" diff --git a/sys/src/cmd/hmi/console/utils.c b/sys/src/cmd/hmi/console/utils.c index a74c10c..6536ed3 100644 --- a/sys/src/cmd/hmi/console/utils.c +++ b/sys/src/cmd/hmi/console/utils.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include <9P2000.h> #include "console.h" diff --git a/sys/src/cmd/hmi/mouse.c b/sys/src/cmd/hmi/mouse.c index 13aa4f8..a3cb4df 100644 --- a/sys/src/cmd/hmi/mouse.c +++ b/sys/src/cmd/hmi/mouse.c @@ -8,7 +8,7 @@ */ #include -#include +#include enum { diff --git a/sys/src/cmd/hmi/realemu/arg.c b/sys/src/cmd/hmi/realemu/arg.c index 0e5ea49..599c6eb 100644 --- a/sys/src/cmd/hmi/realemu/arg.c +++ b/sys/src/cmd/hmi/realemu/arg.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/debug.c b/sys/src/cmd/hmi/realemu/debug.c index 86df988..a83fdbf 100644 --- a/sys/src/cmd/hmi/realemu/debug.c +++ b/sys/src/cmd/hmi/realemu/debug.c @@ -5,7 +5,7 @@ * Arch-independent kernel debugging */ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/decode.c b/sys/src/cmd/hmi/realemu/decode.c index 05bf3fe..bd04a9b 100644 --- a/sys/src/cmd/hmi/realemu/decode.c +++ b/sys/src/cmd/hmi/realemu/decode.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/fmt.c b/sys/src/cmd/hmi/realemu/fmt.c index 88b0c29..1c530ab 100644 --- a/sys/src/cmd/hmi/realemu/fmt.c +++ b/sys/src/cmd/hmi/realemu/fmt.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/loadcom.c b/sys/src/cmd/hmi/realemu/loadcom.c index f6a349e..10adf6f 100644 --- a/sys/src/cmd/hmi/realemu/loadcom.c +++ b/sys/src/cmd/hmi/realemu/loadcom.c @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/sys/src/cmd/hmi/realemu/main.c b/sys/src/cmd/hmi/realemu/main.c index 931dce3..f7dc2b0 100644 --- a/sys/src/cmd/hmi/realemu/main.c +++ b/sys/src/cmd/hmi/realemu/main.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/pit.c b/sys/src/cmd/hmi/realemu/pit.c index 93f571f..07d15c6 100644 --- a/sys/src/cmd/hmi/realemu/pit.c +++ b/sys/src/cmd/hmi/realemu/pit.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/realemu/xec.c b/sys/src/cmd/hmi/realemu/xec.c index b2254bc..d9379bd 100644 --- a/sys/src/cmd/hmi/realemu/xec.c +++ b/sys/src/cmd/hmi/realemu/xec.c @@ -1,5 +1,5 @@ #include -#include +#include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hmi/vga/ch9294.c b/sys/src/cmd/hmi/vga/ch9294.c index 4418834..02e0072 100644 --- a/sys/src/cmd/hmi/vga/ch9294.c +++ b/sys/src/cmd/hmi/vga/ch9294.c @@ -12,7 +12,7 @@ * CH9294 Dual Enhanced Graphics Clock Generator. */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/clgd542x.c b/sys/src/cmd/hmi/vga/clgd542x.c index 99d16b8..ebb4767 100644 --- a/sys/src/cmd/hmi/vga/clgd542x.c +++ b/sys/src/cmd/hmi/vga/clgd542x.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/clgd546x.c b/sys/src/cmd/hmi/vga/clgd546x.c index ce2ea80..1413840 100644 --- a/sys/src/cmd/hmi/vga/clgd546x.c +++ b/sys/src/cmd/hmi/vga/clgd546x.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/data.c b/sys/src/cmd/hmi/vga/data.c index e0be121..89d3ca3 100644 --- a/sys/src/cmd/hmi/vga/data.c +++ b/sys/src/cmd/hmi/vga/data.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/db.c b/sys/src/cmd/hmi/vga/db.c index 7a713f2..cd7825c 100644 --- a/sys/src/cmd/hmi/vga/db.c +++ b/sys/src/cmd/hmi/vga/db.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/hmi/vga/error.c b/sys/src/cmd/hmi/vga/error.c index 9b454b3..3f6e0cc 100644 --- a/sys/src/cmd/hmi/vga/error.c +++ b/sys/src/cmd/hmi/vga/error.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/icd2061a.c b/sys/src/cmd/hmi/vga/icd2061a.c index a739712..c94d42e 100644 --- a/sys/src/cmd/hmi/vga/icd2061a.c +++ b/sys/src/cmd/hmi/vga/icd2061a.c @@ -11,7 +11,7 @@ * IC Designs ICD2061A Dual Programmable Graphics Clock Generator. */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/ics2494.c b/sys/src/cmd/hmi/vga/ics2494.c index 9fef7b7..659bee7 100644 --- a/sys/src/cmd/hmi/vga/ics2494.c +++ b/sys/src/cmd/hmi/vga/ics2494.c @@ -12,7 +12,7 @@ * ICS2494[A] Dual Video/Memory Clock Generator. */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/ics534x.c b/sys/src/cmd/hmi/vga/ics534x.c index 0baf9f5..c04ea43 100644 --- a/sys/src/cmd/hmi/vga/ics534x.c +++ b/sys/src/cmd/hmi/vga/ics534x.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/io.c b/sys/src/cmd/hmi/vga/io.c index 5363ea2..6d23768 100644 --- a/sys/src/cmd/hmi/vga/io.c +++ b/sys/src/cmd/hmi/vga/io.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/main.c b/sys/src/cmd/hmi/vga/main.c index bab06f6..19324cb 100644 --- a/sys/src/cmd/hmi/vga/main.c +++ b/sys/src/cmd/hmi/vga/main.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/nvidia.c b/sys/src/cmd/hmi/vga/nvidia.c index 1765edc..611621b 100644 --- a/sys/src/cmd/hmi/vga/nvidia.c +++ b/sys/src/cmd/hmi/vga/nvidia.c @@ -49,7 +49,7 @@ \***************************************************************************/ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/palette.c b/sys/src/cmd/hmi/vga/palette.c index 1945bd4..98abd06 100644 --- a/sys/src/cmd/hmi/vga/palette.c +++ b/sys/src/cmd/hmi/vga/palette.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/pci.c b/sys/src/cmd/hmi/vga/pci.c index d9693b3..b5062dc 100644 --- a/sys/src/cmd/hmi/vga/pci.c +++ b/sys/src/cmd/hmi/vga/pci.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/radeon.c b/sys/src/cmd/hmi/vga/radeon.c index 62652f6..f213d7d 100644 --- a/sys/src/cmd/hmi/vga/radeon.c +++ b/sys/src/cmd/hmi/vga/radeon.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/rgb524.c b/sys/src/cmd/hmi/vga/rgb524.c index 41ff41c..f348a38 100644 --- a/sys/src/cmd/hmi/vga/rgb524.c +++ b/sys/src/cmd/hmi/vga/rgb524.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/rgb524mn.c b/sys/src/cmd/hmi/vga/rgb524mn.c index 4815d1a..940e9f3 100644 --- a/sys/src/cmd/hmi/vga/rgb524mn.c +++ b/sys/src/cmd/hmi/vga/rgb524mn.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/s3801.c b/sys/src/cmd/hmi/vga/s3801.c index 9dba04f..14ee108 100644 --- a/sys/src/cmd/hmi/vga/s3801.c +++ b/sys/src/cmd/hmi/vga/s3801.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/s3928.c b/sys/src/cmd/hmi/vga/s3928.c index 2115e91..3428f4a 100644 --- a/sys/src/cmd/hmi/vga/s3928.c +++ b/sys/src/cmd/hmi/vga/s3928.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/s3clock.c b/sys/src/cmd/hmi/vga/s3clock.c index b169c36..a3c11b5 100644 --- a/sys/src/cmd/hmi/vga/s3clock.c +++ b/sys/src/cmd/hmi/vga/s3clock.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/s3generic.c b/sys/src/cmd/hmi/vga/s3generic.c index 25a4f08..95c8483 100644 --- a/sys/src/cmd/hmi/vga/s3generic.c +++ b/sys/src/cmd/hmi/vga/s3generic.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/s3hwgc.c b/sys/src/cmd/hmi/vga/s3hwgc.c index 1bdc0c7..375f6cf 100644 --- a/sys/src/cmd/hmi/vga/s3hwgc.c +++ b/sys/src/cmd/hmi/vga/s3hwgc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/sc15025.c b/sys/src/cmd/hmi/vga/sc15025.c index 98b467e..b6a5625 100644 --- a/sys/src/cmd/hmi/vga/sc15025.c +++ b/sys/src/cmd/hmi/vga/sc15025.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/stg1702.c b/sys/src/cmd/hmi/vga/stg1702.c index 73b7dbb..e47602e 100644 --- a/sys/src/cmd/hmi/vga/stg1702.c +++ b/sys/src/cmd/hmi/vga/stg1702.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/t2r4.c b/sys/src/cmd/hmi/vga/t2r4.c index 26371af..9c97e86 100644 --- a/sys/src/cmd/hmi/vga/t2r4.c +++ b/sys/src/cmd/hmi/vga/t2r4.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/template.c b/sys/src/cmd/hmi/vga/template.c index 5dc8f1c..5967b1b 100644 --- a/sys/src/cmd/hmi/vga/template.c +++ b/sys/src/cmd/hmi/vga/template.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/trio64.c b/sys/src/cmd/hmi/vga/trio64.c index 04ada4b..5549939 100644 --- a/sys/src/cmd/hmi/vga/trio64.c +++ b/sys/src/cmd/hmi/vga/trio64.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/tvp3020.c b/sys/src/cmd/hmi/vga/tvp3020.c index 2f143f9..7931bbf 100644 --- a/sys/src/cmd/hmi/vga/tvp3020.c +++ b/sys/src/cmd/hmi/vga/tvp3020.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/tvp3025.c b/sys/src/cmd/hmi/vga/tvp3025.c index 097d7ce..42d2af3 100644 --- a/sys/src/cmd/hmi/vga/tvp3025.c +++ b/sys/src/cmd/hmi/vga/tvp3025.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/tvp3025clock.c b/sys/src/cmd/hmi/vga/tvp3025clock.c index 597861e..f46896b 100644 --- a/sys/src/cmd/hmi/vga/tvp3025clock.c +++ b/sys/src/cmd/hmi/vga/tvp3025clock.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/tvp3026.c b/sys/src/cmd/hmi/vga/tvp3026.c index 6da9f00..2c4b67c 100644 --- a/sys/src/cmd/hmi/vga/tvp3026.c +++ b/sys/src/cmd/hmi/vga/tvp3026.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/tvp3026clock.c b/sys/src/cmd/hmi/vga/tvp3026clock.c index a29ae33..632113b 100644 --- a/sys/src/cmd/hmi/vga/tvp3026clock.c +++ b/sys/src/cmd/hmi/vga/tvp3026clock.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/vesa.c b/sys/src/cmd/hmi/vga/vesa.c index a784fb4..be951ad 100644 --- a/sys/src/cmd/hmi/vga/vesa.c +++ b/sys/src/cmd/hmi/vga/vesa.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include // hacks from 386 age typedef struct VGAreg VGAreg; diff --git a/sys/src/cmd/hmi/vga/vesadb.c b/sys/src/cmd/hmi/vga/vesadb.c index bf139ce..1e06ad5 100644 --- a/sys/src/cmd/hmi/vga/vesadb.c +++ b/sys/src/cmd/hmi/vga/vesadb.c @@ -10,7 +10,7 @@ /* this file was automatically generated from vesa.txt */ #include -#include +#include #include #include "pci.h" #include "vga.h" diff --git a/sys/src/cmd/hmi/vga/vga.c b/sys/src/cmd/hmi/vga/vga.c index c323cb0..9cbe38c 100644 --- a/sys/src/cmd/hmi/vga/vga.c +++ b/sys/src/cmd/hmi/vga/vga.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/virge.c b/sys/src/cmd/hmi/vga/virge.c index 8d0a5d1..4a22e73 100644 --- a/sys/src/cmd/hmi/vga/virge.c +++ b/sys/src/cmd/hmi/vga/virge.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/vision864.c b/sys/src/cmd/hmi/vga/vision864.c index ff830d7..2c52d14 100644 --- a/sys/src/cmd/hmi/vga/vision864.c +++ b/sys/src/cmd/hmi/vga/vision864.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/vision964.c b/sys/src/cmd/hmi/vga/vision964.c index fd2dc6a..37cf0de 100644 --- a/sys/src/cmd/hmi/vga/vision964.c +++ b/sys/src/cmd/hmi/vga/vision964.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/vision968.c b/sys/src/cmd/hmi/vga/vision968.c index 5893be4..7892443 100644 --- a/sys/src/cmd/hmi/vga/vision968.c +++ b/sys/src/cmd/hmi/vga/vision968.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hmi/vga/vmware.c b/sys/src/cmd/hmi/vga/vmware.c index 4f2cb0d..fdfa894 100644 --- a/sys/src/cmd/hmi/vga/vmware.c +++ b/sys/src/cmd/hmi/vga/vmware.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "pci.h" diff --git a/sys/src/cmd/hoc/build.json b/sys/src/cmd/hoc/build.json index 3bfa839..d743343 100644 --- a/sys/src/cmd/hoc/build.json +++ b/sys/src/cmd/hoc/build.json @@ -12,6 +12,7 @@ ], "Program": "hoc", "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "code.c", "init.c", "math.c", diff --git a/sys/src/cmd/hoc/code.c b/sys/src/cmd/hoc/code.c index 0251c85..465b6b2 100644 --- a/sys/src/cmd/hoc/code.c +++ b/sys/src/cmd/hoc/code.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "hoc.h" #include "y.tab.h" diff --git a/sys/src/cmd/hoc/hoc.y b/sys/src/cmd/hoc/hoc.y index 631662e..a0aaaf2 100644 --- a/sys/src/cmd/hoc/hoc.y +++ b/sys/src/cmd/hoc/hoc.y @@ -1,6 +1,6 @@ %{ #include -#include +#include #define YYSIZE_T size_t void yyerror(char* s); /* report compile-time error */ diff --git a/sys/src/cmd/hoc/init.c b/sys/src/cmd/hoc/init.c index dc5b7d4..64c2995 100644 --- a/sys/src/cmd/hoc/init.c +++ b/sys/src/cmd/hoc/init.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "hoc.h" #include "y.tab.h" diff --git a/sys/src/cmd/hoc/math.c b/sys/src/cmd/hoc/math.c index bb57088..d5107a9 100644 --- a/sys/src/cmd/hoc/math.c +++ b/sys/src/cmd/hoc/math.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "hoc.h" diff --git a/sys/src/cmd/hoc/symbol.c b/sys/src/cmd/hoc/symbol.c index d8569ba..79c318f 100644 --- a/sys/src/cmd/hoc/symbol.c +++ b/sys/src/cmd/hoc/symbol.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "hoc.h" #include "y.tab.h" diff --git a/sys/src/cmd/import.c b/sys/src/cmd/import.c index edda6a3..5c4ee2e 100644 --- a/sys/src/cmd/import.c +++ b/sys/src/cmd/import.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/init.c b/sys/src/cmd/init.c index 93860b9..8f1f31b 100644 --- a/sys/src/cmd/init.c +++ b/sys/src/cmd/init.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/ip/dhcpclient.c b/sys/src/cmd/ip/dhcpclient.c index 546e7f5..4797bf6 100644 --- a/sys/src/cmd/ip/dhcpclient.c +++ b/sys/src/cmd/ip/dhcpclient.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "dhcp.h" diff --git a/sys/src/cmd/ip/dhcpd/db.c b/sys/src/cmd/ip/dhcpd/db.c index f63bd68..e5a61ca 100644 --- a/sys/src/cmd/ip/dhcpd/db.c +++ b/sys/src/cmd/ip/dhcpd/db.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/dhcpd.c b/sys/src/cmd/ip/dhcpd/dhcpd.c index a2e1312..d0cb965 100644 --- a/sys/src/cmd/ip/dhcpd/dhcpd.c +++ b/sys/src/cmd/ip/dhcpd/dhcpd.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/dhcpleases.c b/sys/src/cmd/ip/dhcpd/dhcpleases.c index e4b9691..fc5b629 100644 --- a/sys/src/cmd/ip/dhcpd/dhcpleases.c +++ b/sys/src/cmd/ip/dhcpd/dhcpleases.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/ndb.c b/sys/src/cmd/ip/dhcpd/ndb.c index 9f7b8c2..63b0f9f 100644 --- a/sys/src/cmd/ip/dhcpd/ndb.c +++ b/sys/src/cmd/ip/dhcpd/ndb.c @@ -2,7 +2,7 @@ * this currently only works for ethernet bootp's -- presotto */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/ping.c b/sys/src/cmd/ip/dhcpd/ping.c index 35fddd5..50642b9 100644 --- a/sys/src/cmd/ip/dhcpd/ping.c +++ b/sys/src/cmd/ip/dhcpd/ping.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "../icmp.h" diff --git a/sys/src/cmd/ip/dhcpd/testlook.c b/sys/src/cmd/ip/dhcpd/testlook.c index 08776e7..4feef13 100644 --- a/sys/src/cmd/ip/dhcpd/testlook.c +++ b/sys/src/cmd/ip/dhcpd/testlook.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/testlookup.c b/sys/src/cmd/ip/dhcpd/testlookup.c index 8ca4652..94fd019 100644 --- a/sys/src/cmd/ip/dhcpd/testlookup.c +++ b/sys/src/cmd/ip/dhcpd/testlookup.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/dhcpd/testping.c b/sys/src/cmd/ip/dhcpd/testping.c index b5ca90c..e481179 100644 --- a/sys/src/cmd/ip/dhcpd/testping.c +++ b/sys/src/cmd/ip/dhcpd/testping.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/gping.c b/sys/src/cmd/ip/gping.c index 8bdfd98..b21522f 100644 --- a/sys/src/cmd/ip/gping.c +++ b/sys/src/cmd/ip/gping.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> @@ -511,7 +511,7 @@ pingsend(Machine *m) ip->seq[1] = m->seq>>8; r->seq = m->seq; r->next = nil; - lock(m); + jehanne_lock(m); pingclean(m, -1, nsec(), 0); if(m->first == nil) m->first = r; @@ -519,7 +519,7 @@ pingsend(Machine *m) m->last->next = r; m->last = r; r->time = nsec(); - unlock(m); + jehanne_unlock(m); if(write(m->pingfd, buf, MSGLEN) < MSGLEN){ errstr(err, sizeof err); if(strstr(err, "unreach")||strstr(err, "exceed")) @@ -558,9 +558,9 @@ pingrcv(void *arg) x = (ip->seq[1]<<8) | ip->seq[0]; if(ip->type != EchoReply || ip->code != 0) continue; - lock(m); + jehanne_lock(m); pingclean(m, x, now, ip4->ttl); - unlock(m); + jehanne_unlock(m); } } diff --git a/sys/src/cmd/ip/hogports.c b/sys/src/cmd/ip/hogports.c index e95493f..ba30571 100644 --- a/sys/src/cmd/ip/hogports.c +++ b/sys/src/cmd/ip/hogports.c @@ -8,7 +8,7 @@ */ #include -#include +#include void hogport(char *proto, int port) diff --git a/sys/src/cmd/ip/ipconfig/ipv6.c b/sys/src/cmd/ip/ipconfig/ipv6.c index ad22217..83907bd 100644 --- a/sys/src/cmd/ip/ipconfig/ipv6.c +++ b/sys/src/cmd/ip/ipconfig/ipv6.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include "ipconfig.h" diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c index cf80d6e..d057674 100644 --- a/sys/src/cmd/ip/ipconfig/main.c +++ b/sys/src/cmd/ip/ipconfig/main.c @@ -2,7 +2,7 @@ * ipconfig - configure parameters of an ip stack */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/ipconfig/ppp.c b/sys/src/cmd/ip/ipconfig/ppp.c index 82d5a55..0edc90c 100644 --- a/sys/src/cmd/ip/ipconfig/ppp.c +++ b/sys/src/cmd/ip/ipconfig/ppp.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/linklocal.c b/sys/src/cmd/ip/linklocal.c index b9e26c1..812f3ea 100644 --- a/sys/src/cmd/ip/linklocal.c +++ b/sys/src/cmd/ip/linklocal.c @@ -13,7 +13,7 @@ */ #include -#include +#include #include enum { diff --git a/sys/src/cmd/ip/listen.c b/sys/src/cmd/ip/listen.c index 4d9640c..638a9b3 100644 --- a/sys/src/cmd/ip/listen.c +++ b/sys/src/cmd/ip/listen.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #define NAMELEN 64 /* reasonable upper limit for name elements */ diff --git a/sys/src/cmd/ip/listen1.c b/sys/src/cmd/ip/listen1.c index 6c41796..360f73a 100644 --- a/sys/src/cmd/ip/listen1.c +++ b/sys/src/cmd/ip/listen1.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int verbose; diff --git a/sys/src/cmd/ip/ping.c b/sys/src/cmd/ip/ping.c index d7a02fa..19934d8 100644 --- a/sys/src/cmd/ip/ping.c +++ b/sys/src/cmd/ip/ping.c @@ -9,7 +9,7 @@ /* ping for ip v4 and v6 */ #include -#include +#include #include #include #include @@ -167,7 +167,7 @@ clean(uint16_t seq, int64_t now, void *v) else ttl = ((Ip6hdr *)v)->ttl; } - lock(&listlock); + jehanne_lock(&listlock); last = nil; for(l = &first; *l; ){ r = *l; @@ -191,7 +191,7 @@ clean(uint16_t seq, int64_t now, void *v) l = &r->next; } } - unlock(&listlock); + jehanne_unlock(&listlock); } static uint8_t loopbacknet[IPaddrlen] = { @@ -291,13 +291,13 @@ sender(int fd, int msglen, int interval, int n) r->next = nil; r->replied = 0; r->time = nsec(); /* avoid early free in reply! */ - lock(&listlock); + jehanne_lock(&listlock); if(first == nil) first = r; else last->next = r; last = r; - unlock(&listlock); + jehanne_unlock(&listlock); r->time = nsec(); if(write(fd, buf, msglen) < msglen){ fprint(2, "%s: write failed: %r\n", argv0); @@ -349,11 +349,11 @@ rcvr(int fd, int msglen, int interval, int nmsg) clean(x, now, buf); } - lock(&listlock); + jehanne_lock(&listlock); for(r = first; r; r = r->next) if(r->replied == 0) lostmsgs++; - unlock(&listlock); + jehanne_unlock(&listlock); if(!quiet && lostmsgs) print("%d out of %d messages lost\n", lostmsgs, diff --git a/sys/src/cmd/ip/rip.c b/sys/src/cmd/ip/rip.c index b739369..563661b 100644 --- a/sys/src/cmd/ip/rip.c +++ b/sys/src/cmd/ip/rip.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/ip/timesync.c b/sys/src/cmd/ip/timesync.c index 9f21b9f..4984979 100644 --- a/sys/src/cmd/ip/timesync.c +++ b/sys/src/cmd/ip/timesync.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/traceroute.c b/sys/src/cmd/ip/traceroute.c index 9d9cf98..0b809a3 100644 --- a/sys/src/cmd/ip/traceroute.c +++ b/sys/src/cmd/ip/traceroute.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ip/trampoline.c b/sys/src/cmd/ip/trampoline.c index f9e3dda..0abcfe3 100644 --- a/sys/src/cmd/ip/trampoline.c +++ b/sys/src/cmd/ip/trampoline.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/join.c b/sys/src/cmd/join.c index 7050fc4..cab4cfe 100644 --- a/sys/src/cmd/join.c +++ b/sys/src/cmd/join.c @@ -9,7 +9,7 @@ /* join F1 F2 on stuff */ #include -#include +#include #include #include diff --git a/sys/src/cmd/lock.c b/sys/src/cmd/lock.c index 32641d6..1eeec1b 100644 --- a/sys/src/cmd/lock.c +++ b/sys/src/cmd/lock.c @@ -24,8 +24,8 @@ void notifyf(void *c, char*); static void usage(void) { - fprint(2, "usage: %s [-dw] lock [command [file]...]\n", argv0); - exits("usage"); + jehanne_fprint(2, "usage: %s [-dw] lock [command [file]...]\n", argv0); + jehanne_exits("usage"); } static Waitmsg * @@ -35,10 +35,10 @@ waitfor(int pid) Waitmsg *w; for (;;) { - w = wait(); + w = jehanne_wait(); if (w == nil){ errstr(err, sizeof err); - if(strcmp(err, "interrupted") == 0) + if(jehanne_strcmp(err, "interrupted") == 0) continue; return nil; } @@ -54,24 +54,24 @@ openlock(char *lock) Dir *dir; /* first ensure that the lock file has the lock bit set */ - dir = dirstat(lock); + dir = jehanne_dirstat(lock); if (dir == nil) - sysfatal("can't stat %s: %r", lock); + jehanne_sysfatal("can't stat %s: %r", lock); if (!(dir->mode & DMEXCL)) { dir->mode |= DMEXCL; dir->qid.type |= QTEXCL; - if (dirwstat(lock, dir) < 0) - sysfatal("can't make %s exclusive access: %r", lock); + if (jehanne_dirwstat(lock, dir) < 0) + jehanne_sysfatal("can't make %s exclusive access: %r", lock); } - free(dir); + jehanne_free(dir); if (lockwait) while ((lckfd = open(lock, ORDWR)) < 0) - sleep(1000); + jehanne_sleep(1000); else lckfd = open(lock, ORDWR); if (lckfd < 0) - sysfatal("can't open %s read/write: %r", lock); + jehanne_sysfatal("can't open %s read/write: %r", lock); return lckfd; } @@ -110,16 +110,16 @@ main(int argc, char *argv[]) /* set up lock and process to keep it alive */ lock = argv[0]; lckfd = openlock(lock); - lckpid = fork(); + lckpid = jehanne_fork(); switch(lckpid){ case -1: error("fork"); case 0: /* keep lock alive until killed */ for (;;) { - sleep(60*1000); + jehanne_sleep(60*1000); seek(lckfd, 0, 0); - fprint(lckfd, "\n"); + jehanne_fprint(lckfd, "\n"); } } @@ -129,15 +129,15 @@ main(int argc, char *argv[]) case -1: error("fork"); case 0: - fd = ocreate("/env/prompt", OWRITE, 0666); + fd = jehanne_ocreate("/env/prompt", OWRITE, 0666); if (fd >= 0) { - fprint(fd, "%s%% ", lock); + jehanne_fprint(fd, "%s%% ", lock); close(fd); } exec(cmd, args); - if(cmd[0] != '/' && strncmp(cmd, "./", 2) != 0 && - strncmp(cmd, "../", 3) != 0) - exec(smprint("/cmd/%s", cmd), args); + if(cmd[0] != '/' && jehanne_strncmp(cmd, "./", 2) != 0 && + jehanne_strncmp(cmd, "../", 3) != 0) + exec(jehanne_smprint("/cmd/%s", cmd), args); error(cmd); } @@ -147,33 +147,33 @@ main(int argc, char *argv[]) if (w == nil) error("wait"); - postnote(PNPROC, lckpid, "die"); + jehanne_postnote(PNPROC, lckpid, "die"); waitfor(lckpid); if(w->msg[0]){ - p = utfrune(w->msg, ':'); + p = jehanne_utfrune(w->msg, ':'); if(p && p[1]) p++; else p = w->msg; while (isspace(*p)) p++; - fprint(2, "%s: %s # status=%s\n", argv0, cmd, p); + jehanne_fprint(2, "%s: %s # status=%s\n", argv0, cmd, p); } - exits(w->msg); + jehanne_exits(w->msg); } void error(char *s) { - fprint(2, "%s: %s: %r\n", argv0, s); - exits(s); + jehanne_fprint(2, "%s: %s: %r\n", argv0, s); + jehanne_exits(s); } void notifyf(void *a, char *s) { USED(a); - if(strcmp(s, "interrupt") == 0) + if(jehanne_strcmp(s, "interrupt") == 0) noted(NCONT); noted(NDFLT); } diff --git a/sys/src/cmd/look.c b/sys/src/cmd/look.c index 03ad245..505d400 100644 --- a/sys/src/cmd/look.c +++ b/sys/src/cmd/look.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* Macros for Rune support of ctype.h-like functions */ @@ -24,6 +24,7 @@ #define isspace(r) ((r) == L' ' || (r) == L'\t' \ || (0x0A <= (r) && (r) <= 0x0D)) +#undef tolower #define tolower(r) ((r)-'A'+'a') #define sgn(v) ((v) < 0 ? -1 : ((v) > 0 ? 1 : 0)) diff --git a/sys/src/cmd/ls.c b/sys/src/cmd/ls.c index 684cd55..00ef9f9 100644 --- a/sys/src/cmd/ls.c +++ b/sys/src/cmd/ls.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include <9P2000.h> diff --git a/sys/src/cmd/mc.c b/sys/src/cmd/mc.c index 75f5525..d85269d 100644 --- a/sys/src/cmd/mc.c +++ b/sys/src/cmd/mc.c @@ -17,7 +17,7 @@ * */ #include -#include +#include #include #include diff --git a/sys/src/cmd/mkdir.c b/sys/src/cmd/mkdir.c index 0364b8c..f25d130 100644 --- a/sys/src/cmd/mkdir.c +++ b/sys/src/cmd/mkdir.c @@ -8,7 +8,7 @@ */ #include -#include +#include char *e; uint32_t mode = 0777L; diff --git a/sys/src/cmd/mntgen.c b/sys/src/cmd/mntgen.c index 22de58e..53e8653 100644 --- a/sys/src/cmd/mntgen.c +++ b/sys/src/cmd/mntgen.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/cmd/mount.c b/sys/src/cmd/mount.c index ce066fa..a68314d 100644 --- a/sys/src/cmd/mount.c +++ b/sys/src/cmd/mount.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void usage(void); diff --git a/sys/src/cmd/mpc.y b/sys/src/cmd/mpc.y index eca24d3..9c46ddb 100644 --- a/sys/src/cmd/mpc.y +++ b/sys/src/cmd/mpc.y @@ -1,7 +1,7 @@ %{ #include -#include +#include #include #include diff --git a/sys/src/cmd/ms.c b/sys/src/cmd/ms.c index 11c7332..b7c1a66 100644 --- a/sys/src/cmd/ms.c +++ b/sys/src/cmd/ms.c @@ -11,7 +11,7 @@ * Count bytes within runes, if it fits in a uint64_t, and other things. */ #include -#include +#include static int packetsize = 3; void main(int argc, char *argv[]) diff --git a/sys/src/cmd/mtime.c b/sys/src/cmd/mtime.c index 62817e8..c7fb3dd 100644 --- a/sys/src/cmd/mtime.c +++ b/sys/src/cmd/mtime.c @@ -8,7 +8,7 @@ */ #include -#include +#include void usage(void) diff --git a/sys/src/cmd/mv.c b/sys/src/cmd/mv.c index 7662bdc..d37b642 100644 --- a/sys/src/cmd/mv.c +++ b/sys/src/cmd/mv.c @@ -8,7 +8,7 @@ */ #include -#include +#include int copy1(int fdf, int fdt, char *from, char *to); void hardremove(char *); diff --git a/sys/src/cmd/ndb/convDNS2M.c b/sys/src/cmd/ndb/convDNS2M.c index 07a81d4..76a9dca 100644 --- a/sys/src/cmd/ndb/convDNS2M.c +++ b/sys/src/cmd/ndb/convDNS2M.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/convM2DNS.c b/sys/src/cmd/ndb/convM2DNS.c index 623b152..6af8d72 100644 --- a/sys/src/cmd/ndb/convM2DNS.c +++ b/sys/src/cmd/ndb/convM2DNS.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c index bc5969c..2be341c 100644 --- a/sys/src/cmd/ndb/cs.c +++ b/sys/src/cmd/ndb/cs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/cmd/ndb/csquery.c b/sys/src/cmd/ndb/csquery.c index 6a32402..819a576 100644 --- a/sys/src/cmd/ndb/csquery.c +++ b/sys/src/cmd/ndb/csquery.c @@ -1,5 +1,5 @@ #include -#include +#include #include char *server; diff --git a/sys/src/cmd/ndb/dblookup.c b/sys/src/cmd/ndb/dblookup.c index 7b00c9e..e10a9b4 100644 --- a/sys/src/cmd/ndb/dblookup.c +++ b/sys/src/cmd/ndb/dblookup.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -122,7 +122,7 @@ dblookup(char *name, int class, int type, int auth, int ttl) return rp; } - lock(&dblock); + jehanne_lock(&dblock); dp = idnlookup(name, class, 1); if(opendatabase() < 0) @@ -166,7 +166,7 @@ out: dp->respcode = err; } - unlock(&dblock); + jehanne_unlock(&dblock); return rp; } @@ -684,10 +684,10 @@ db2cache(int doit) refresh_areas(owned); - lock(&dblock); + jehanne_lock(&dblock); if(opendatabase() < 0){ - unlock(&dblock); + jehanne_unlock(&dblock); return; } @@ -746,7 +746,7 @@ db2cache(int doit) createptrs(); } - unlock(&dblock); + jehanne_unlock(&dblock); } extern char mntpt[Maxpath]; /* net mountpoint */ @@ -770,13 +770,13 @@ lookupinfo(char *attr) snprint(buf, sizeof buf, "%I", ipaddr); a[0] = attr; - lock(&dblock); + jehanne_lock(&dblock); if(opendatabase() < 0){ - unlock(&dblock); + jehanne_unlock(&dblock); return nil; } t = ndbipinfo(db, "ip", buf, a, 1); - unlock(&dblock); + jehanne_unlock(&dblock); return t; } @@ -1174,11 +1174,11 @@ insideaddr(char *dom) if (dom[0] == '\0' || strcmp(dom, ".") == 0) /* dns root? */ return 1; /* hack for initialisation */ - lock(&dblock); + jehanne_lock(&dblock); if (indoms == nil) loaddomsrvs(); if (indoms == nil) { - unlock(&dblock); + jehanne_unlock(&dblock); return 1; /* no "inside-dom" sys, try inside nameservers */ } @@ -1196,7 +1196,7 @@ insideaddr(char *dom) break; } } - unlock(&dblock); + jehanne_unlock(&dblock); return rv; } diff --git a/sys/src/cmd/ndb/dn.c b/sys/src/cmd/ndb/dn.c index 8f01316..2d1cce8 100644 --- a/sys/src/cmd/ndb/dn.c +++ b/sys/src/cmd/ndb/dn.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "dns.h" @@ -193,19 +193,19 @@ dnlookup(char *name, int class, int enter) DN *dp; l = &ht[dnhash(name)]; - lock(&dnlock); + jehanne_lock(&dnlock); for(dp = *l; dp; dp = dp->next) { assert(dp->magic == DNmagic); if(dp->class == class && cistrcmp(dp->name, name) == 0){ dp->referenced = now; - unlock(&dnlock); + jehanne_unlock(&dnlock); return dp; } l = &dp->next; } if(!enter){ - unlock(&dnlock); + jehanne_unlock(&dnlock); return 0; } dnvars.names++; @@ -218,7 +218,7 @@ dnlookup(char *name, int class, int enter) /* add new DN to tail of the hash list. *l points to last next ptr. */ dp->next = nil; *l = dp; - unlock(&dnlock); + jehanne_unlock(&dnlock); return dp; } @@ -285,9 +285,9 @@ dnstats(char *file) fprint(fd, "# negative answers cached\t%lud\n", stats.negcached); qunlock(&stats); - lock(&dnlock); + jehanne_lock(&dnlock); fprint(fd, "\n# domain names %lud target %lud\n", dnvars.names, target); - unlock(&dnlock); + jehanne_unlock(&dnlock); close(fd); } @@ -305,7 +305,7 @@ dndump(char *file) if(fd < 0) return; - lock(&dnlock); + jehanne_lock(&dnlock); for(i = 0; i < HTLEN; i++) for(dp = ht[i]; dp; dp = dp->next){ fprint(fd, "%s\n", dp->name); @@ -317,7 +317,7 @@ dndump(char *file) fprint(fd, "*** duplicate:\n"); } } - unlock(&dnlock); + jehanne_unlock(&dnlock); close(fd); } @@ -331,7 +331,7 @@ dnpurge(void) RR *rp, *srp; int i; - lock(&dnlock); + jehanne_lock(&dnlock); for(i = 0; i < HTLEN; i++) for(dp = ht[i]; dp; dp = dp->next){ @@ -342,7 +342,7 @@ dnpurge(void) rrfreelist(srp); } - unlock(&dnlock); + jehanne_unlock(&dnlock); } /* @@ -398,7 +398,7 @@ dnagenever(DN *dp) { RR *rp; - lock(&dnlock); + jehanne_lock(&dnlock); /* mark all referenced domain names */ MARK(dp); @@ -453,7 +453,7 @@ dnagenever(DN *dp) } } - unlock(&dnlock); + jehanne_unlock(&dnlock); } #define REF(dp) { if (dp) (dp)->mark |= 1; } @@ -488,7 +488,7 @@ dnageall(int doit) else nextage = now + (uint32_t)agefreq; - lock(&dnlock); + jehanne_lock(&dnlock); /* time out all old entries (and set refs to 0) */ for(i = 0; i < HTLEN; i++) @@ -571,7 +571,7 @@ dnageall(int doit) } } - unlock(&dnlock); + jehanne_unlock(&dnlock); } /* @@ -584,7 +584,7 @@ dnagedb(void) int i; RR *rp; - lock(&dnlock); + jehanne_lock(&dnlock); /* time out all database entries */ for(i = 0; i < HTLEN; i++) @@ -595,7 +595,7 @@ dnagedb(void) rp->expire = 0; } - unlock(&dnlock); + jehanne_unlock(&dnlock); } /* @@ -611,7 +611,7 @@ dnauthdb(void) DN *dp; RR *rp, **l; - lock(&dnlock); + jehanne_lock(&dnlock); /* time out all database entries */ for(i = 0; i < HTLEN; i++) @@ -635,7 +635,7 @@ dnauthdb(void) } } - unlock(&dnlock); + jehanne_unlock(&dnlock); } /* @@ -650,22 +650,22 @@ getactivity(Request *req, int recursive) if(traceactivity) dnslog("get: %d active by pid %d from %p", dnvars.active, getpid(), getcallerpc()); - lock(&dnvars); + jehanne_lock(&dnvars); /* * can't block here if we're already holding one * of the dnvars.active (recursive). will deadlock. */ while(!recursive && dnvars.mutex){ - unlock(&dnvars); + jehanne_unlock(&dnvars); sleep(100); /* tune; was 200 */ - lock(&dnvars); + jehanne_lock(&dnvars); } rv = ++dnvars.active; now = time(nil); nowns = nsec(); req->id = ++dnvars.id; req->aux = nil; - unlock(&dnvars); + jehanne_unlock(&dnvars); return rv; } @@ -675,7 +675,7 @@ putactivity(int recursive) if(traceactivity) dnslog("put: %d active by pid %d", dnvars.active, getpid()); - lock(&dnvars); + jehanne_lock(&dnvars); dnvars.active--; assert(dnvars.active >= 0); /* "dnvars.active %d", dnvars.active */ @@ -686,18 +686,18 @@ putactivity(int recursive) */ if (recursive || dnvars.mutex || (needrefresh == 0 && dnvars.active > 0)){ - unlock(&dnvars); + jehanne_unlock(&dnvars); return; } /* wait till we're alone */ dnvars.mutex = 1; while(dnvars.active > 0){ - unlock(&dnvars); + jehanne_unlock(&dnvars); sleep(100); /* tune; was 100 */ - lock(&dnvars); + jehanne_lock(&dnvars); } - unlock(&dnvars); + jehanne_unlock(&dnvars); db2cache(needrefresh); @@ -838,7 +838,7 @@ rrattach(RR *rp, int auth) RR *next; DN *dp; - lock(&dnlock); + jehanne_lock(&dnlock); for(; rp; rp = next){ next = rp->next; rp->next = nil; @@ -849,7 +849,7 @@ rrattach(RR *rp, int auth) else rrattach1(rp, auth); } - unlock(&dnlock); + jehanne_unlock(&dnlock); } RR** @@ -958,7 +958,7 @@ rrlookup(DN *dp, int type, int flag) first = nil; last = &first; - lock(&dnlock); + jehanne_lock(&dnlock); /* try for an authoritative db entry */ for(rp = dp->rr; rp; rp = rp->next){ @@ -1016,7 +1016,7 @@ rrlookup(DN *dp, int type, int flag) } out: - unlock(&dnlock); + jehanne_unlock(&dnlock); unique(first); return first; } diff --git a/sys/src/cmd/ndb/dnarea.c b/sys/src/cmd/ndb/dnarea.c index 4351bf7..aa7a318 100644 --- a/sys/src/cmd/ndb/dnarea.c +++ b/sys/src/cmd/ndb/dnarea.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ addarea(DN *dp, RR *rp, Ndbtuple *t) Area *s; Area **l; - lock(&dnlock); + jehanne_lock(&dnlock); if(t->val[0]) l = &delegated; else @@ -57,7 +57,7 @@ addarea(DN *dp, RR *rp, Ndbtuple *t) for (s = *l; s != nil; s = s->next) if(s->soarr->owner == dp) { - unlock(&dnlock); + jehanne_unlock(&dnlock); return; /* we've already got one */ } @@ -81,7 +81,7 @@ addarea(DN *dp, RR *rp, Ndbtuple *t) s->next = *l; *l = s; - unlock(&dnlock); + jehanne_unlock(&dnlock); } void @@ -89,14 +89,14 @@ freearea(Area **l) { Area *s; - lock(&dnlock); + jehanne_lock(&dnlock); while(s = *l){ *l = s->next; rrfree(s->soarr); memset(s, 0, sizeof *s); /* cause trouble */ free(s); } - unlock(&dnlock); + jehanne_unlock(&dnlock); } /* diff --git a/sys/src/cmd/ndb/dnnotify.c b/sys/src/cmd/ndb/dnnotify.c index dddd278..21276f0 100644 --- a/sys/src/cmd/ndb/dnnotify.c +++ b/sys/src/cmd/ndb/dnnotify.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/dnresolve.c b/sys/src/cmd/ndb/dnresolve.c index 772be3f..e07f7b4 100644 --- a/sys/src/cmd/ndb/dnresolve.c +++ b/sys/src/cmd/ndb/dnresolve.c @@ -2,7 +2,7 @@ * domain name resolvers, see rfcs 1035 and 1123 */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/dns.c b/sys/src/cmd/ndb/dns.c index 0041668..008c4b2 100644 --- a/sys/src/cmd/ndb/dns.c +++ b/sys/src/cmd/ndb/dns.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include @@ -299,10 +299,10 @@ newfid(int fid, int needunused) { Mfile *mf; - lock(&mfalloc); + jehanne_lock(&mfalloc); for(mf = mfalloc.inuse; mf != nil; mf = mf->next) if(mf->fid == fid){ - unlock(&mfalloc); + jehanne_unlock(&mfalloc); if(needunused) return nil; return mf; @@ -315,7 +315,7 @@ newfid(int fid, int needunused) mf->user = estrdup("none"); mf->next = mfalloc.inuse; mfalloc.inuse = mf; - unlock(&mfalloc); + jehanne_unlock(&mfalloc); return mf; } @@ -324,17 +324,17 @@ freefid(Mfile *mf) { Mfile **l; - lock(&mfalloc); + jehanne_lock(&mfalloc); for(l = &mfalloc.inuse; *l != nil; l = &(*l)->next) if(*l == mf){ *l = mf->next; free(mf->user); memset(mf, 0, sizeof *mf); /* cause trouble */ free(mf); - unlock(&mfalloc); + jehanne_unlock(&mfalloc); return; } - unlock(&mfalloc); + jehanne_unlock(&mfalloc); sysfatal("freeing unused fid"); } @@ -361,11 +361,11 @@ newjob(void) Job *job; job = emalloc(sizeof *job); - lock(&joblock); + jehanne_lock(&joblock); job->next = joblist; joblist = job; job->request.tag = -1; - unlock(&joblock); + jehanne_unlock(&joblock); return job; } @@ -374,7 +374,7 @@ freejob(Job *job) { Job **l; - lock(&joblock); + jehanne_lock(&joblock); for(l = &joblist; *l; l = &(*l)->next) if(*l == job){ *l = job->next; @@ -382,7 +382,7 @@ freejob(Job *job) free(job); break; } - unlock(&joblock); + jehanne_unlock(&joblock); } void @@ -390,13 +390,13 @@ flushjob(int tag) { Job *job; - lock(&joblock); + jehanne_lock(&joblock); for(job = joblist; job; job = job->next) if(job->request.tag == tag && job->request.type != Tflush){ job->flushed = 1; break; } - unlock(&joblock); + jehanne_unlock(&joblock); } void @@ -847,7 +847,7 @@ respond(Job *job, Mfile *mf, RR *rp, char *errbuf, int status, int wantsav) return errbuf; } - lock(&joblock); + jehanne_lock(&joblock); if(!job->flushed){ /* format data to be read later */ n = 0; @@ -862,7 +862,7 @@ respond(Job *job, Mfile *mf, RR *rp, char *errbuf, int status, int wantsav) } mf->rr[mf->nrr] = n; } - unlock(&joblock); + jehanne_unlock(&joblock); rrfreelist(rp); @@ -932,11 +932,11 @@ sendmsg(Job *job, char *err) warning("sendmsg convS2M of %F returns 0", &job->reply); abort(); } - lock(&joblock); + jehanne_lock(&joblock); if(job->flushed == 0) if(write(mfd[1], mdata, n)!=n) sysfatal("mount write"); - unlock(&joblock); + jehanne_unlock(&joblock); if(debug) dnslog("%F %d", &job->reply, n); } diff --git a/sys/src/cmd/ndb/dnsdebug.c b/sys/src/cmd/ndb/dnsdebug.c index cc2f8c6..165779b 100644 --- a/sys/src/cmd/ndb/dnsdebug.c +++ b/sys/src/cmd/ndb/dnsdebug.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/dnserver.c b/sys/src/cmd/ndb/dnserver.c index 31fddbe..fdbfa41 100644 --- a/sys/src/cmd/ndb/dnserver.c +++ b/sys/src/cmd/ndb/dnserver.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/dnsgetip.c b/sys/src/cmd/ndb/dnsgetip.c index 76ced8a..0512816 100644 --- a/sys/src/cmd/ndb/dnsgetip.c +++ b/sys/src/cmd/ndb/dnsgetip.c @@ -1,6 +1,6 @@ /* one-shot resolver */ #include -#include +#include #include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/dnsquery.c b/sys/src/cmd/ndb/dnsquery.c index 1e8fa21..36f3972 100644 --- a/sys/src/cmd/ndb/dnsquery.c +++ b/sys/src/cmd/ndb/dnsquery.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/dnstcp.c b/sys/src/cmd/ndb/dnstcp.c index 21d2e77..51ce52d 100644 --- a/sys/src/cmd/ndb/dnstcp.c +++ b/sys/src/cmd/ndb/dnstcp.c @@ -2,7 +2,7 @@ * dnstcp - serve dns via tcp */ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/dnudpserver.c b/sys/src/cmd/ndb/dnudpserver.c index 6bf2554..11a5799 100644 --- a/sys/src/cmd/ndb/dnudpserver.c +++ b/sys/src/cmd/ndb/dnudpserver.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/idn.c b/sys/src/cmd/ndb/idn.c index 46d421a..3b4d0d0 100644 --- a/sys/src/cmd/ndb/idn.c +++ b/sys/src/cmd/ndb/idn.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dns.h" diff --git a/sys/src/cmd/ndb/inform.c b/sys/src/cmd/ndb/inform.c index 733dc8d..56340af 100644 --- a/sys/src/cmd/ndb/inform.c +++ b/sys/src/cmd/ndb/inform.c @@ -1,6 +1,6 @@ /* RFC2136 DNS inform - necessary for Win2k3 DNS servers */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/ipquery.c b/sys/src/cmd/ndb/ipquery.c index aace804..1b2ca07 100644 --- a/sys/src/cmd/ndb/ipquery.c +++ b/sys/src/cmd/ndb/ipquery.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/mkdb.c b/sys/src/cmd/ndb/mkdb.c index e19685a..be016d6 100644 --- a/sys/src/cmd/ndb/mkdb.c +++ b/sys/src/cmd/ndb/mkdb.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/ndb/mkhash.c b/sys/src/cmd/ndb/mkhash.c index 5be66d9..778dfbc 100644 --- a/sys/src/cmd/ndb/mkhash.c +++ b/sys/src/cmd/ndb/mkhash.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/ndb/mkhosts.c b/sys/src/cmd/ndb/mkhosts.c index f03ffd7..a8716ad 100644 --- a/sys/src/cmd/ndb/mkhosts.c +++ b/sys/src/cmd/ndb/mkhosts.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ndb/query.c b/sys/src/cmd/ndb/query.c index 4efdb52..e3305cc 100644 --- a/sys/src/cmd/ndb/query.c +++ b/sys/src/cmd/ndb/query.c @@ -2,7 +2,7 @@ * search the network database for matches */ #include -#include +#include #include #include diff --git a/sys/src/cmd/netstat.c b/sys/src/cmd/netstat.c index 9308d24..d4d43c2 100644 --- a/sys/src/cmd/netstat.c +++ b/sys/src/cmd/netstat.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/ns.c b/sys/src/cmd/ns.c index 337fa5e..538bd17 100644 --- a/sys/src/cmd/ns.c +++ b/sys/src/cmd/ns.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/p.c b/sys/src/cmd/p.c index aa1169f..ba274ab 100644 --- a/sys/src/cmd/p.c +++ b/sys/src/cmd/p.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #define DEF 22 /* lines in chunk: 3*DEF == 66, #lines per nroff page */ diff --git a/sys/src/cmd/pict/bmp.c b/sys/src/cmd/pict/bmp.c index 2d75790..bbbfbd8 100644 --- a/sys/src/cmd/pict/bmp.c +++ b/sys/src/cmd/pict/bmp.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/close.c b/sys/src/cmd/pict/close.c index 7a260c1..e1f8a9f 100644 --- a/sys/src/cmd/pict/close.c +++ b/sys/src/cmd/pict/close.c @@ -1,5 +1,5 @@ #include -#include +#include #include float c1 = 1.402; diff --git a/sys/src/cmd/pict/gif.c b/sys/src/cmd/pict/gif.c index 1b6fdbf..ade27ab 100644 --- a/sys/src/cmd/pict/gif.c +++ b/sys/src/cmd/pict/gif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/ico.c b/sys/src/cmd/pict/ico.c index 6125ca7..8f5c7c0 100644 --- a/sys/src/cmd/pict/ico.c +++ b/sys/src/cmd/pict/ico.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/jpg.c b/sys/src/cmd/pict/jpg.c index 7179dc5..e66978b 100644 --- a/sys/src/cmd/pict/jpg.c +++ b/sys/src/cmd/pict/jpg.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/multichan.c b/sys/src/cmd/pict/multichan.c index 6245687..b4cbc77 100644 --- a/sys/src/cmd/pict/multichan.c +++ b/sys/src/cmd/pict/multichan.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/onechan.c b/sys/src/cmd/pict/onechan.c index aee1dc7..1a21f07 100644 --- a/sys/src/cmd/pict/onechan.c +++ b/sys/src/cmd/pict/onechan.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/png.c b/sys/src/cmd/pict/png.c index 5340b6f..5710a7e 100644 --- a/sys/src/cmd/pict/png.c +++ b/sys/src/cmd/pict/png.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/ppm.c b/sys/src/cmd/pict/ppm.c index 5d845a9..0226bcd 100644 --- a/sys/src/cmd/pict/ppm.c +++ b/sys/src/cmd/pict/ppm.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/readbmp.c b/sys/src/cmd/pict/readbmp.c index 5892d3f..4dbcbe5 100644 --- a/sys/src/cmd/pict/readbmp.c +++ b/sys/src/cmd/pict/readbmp.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/readgif.c b/sys/src/cmd/pict/readgif.c index b00495c..908a8c7 100644 --- a/sys/src/cmd/pict/readgif.c +++ b/sys/src/cmd/pict/readgif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/readjpg.c b/sys/src/cmd/pict/readjpg.c index 5bceee6..b4f5370 100644 --- a/sys/src/cmd/pict/readjpg.c +++ b/sys/src/cmd/pict/readjpg.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/readpng.c b/sys/src/cmd/pict/readpng.c index bbf3b70..8ea738e 100644 --- a/sys/src/cmd/pict/readpng.c +++ b/sys/src/cmd/pict/readpng.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/readppm.c b/sys/src/cmd/pict/readppm.c index f1a15e9..d9af764 100644 --- a/sys/src/cmd/pict/readppm.c +++ b/sys/src/cmd/pict/readppm.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/readtga.c b/sys/src/cmd/pict/readtga.c index faf170c..482aa7e 100644 --- a/sys/src/cmd/pict/readtga.c +++ b/sys/src/cmd/pict/readtga.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/readtif.c b/sys/src/cmd/pict/readtif.c index 186626e..db3f8c1 100644 --- a/sys/src/cmd/pict/readtif.c +++ b/sys/src/cmd/pict/readtif.c @@ -13,7 +13,7 @@ * http://www.remotesensing.org/libtiff/ */ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/readv210.c b/sys/src/cmd/pict/readv210.c index 6df21ce..48a4e97 100644 --- a/sys/src/cmd/pict/readv210.c +++ b/sys/src/cmd/pict/readv210.c @@ -4,7 +4,7 @@ * Steve Simon, 2009 */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/readyuv.c b/sys/src/cmd/pict/readyuv.c index 7d08515..c61b825 100644 --- a/sys/src/cmd/pict/readyuv.c +++ b/sys/src/cmd/pict/readyuv.c @@ -1,6 +1,6 @@ /* readyuv.c - read an Abekas A66 style image file. Steve Simon, 2003 */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/rgbrgbv.c b/sys/src/cmd/pict/rgbrgbv.c index ed4de79..6c46fa6 100644 --- a/sys/src/cmd/pict/rgbrgbv.c +++ b/sys/src/cmd/pict/rgbrgbv.c @@ -1,5 +1,5 @@ #include -#include +#include #include /* diff --git a/sys/src/cmd/pict/rgbycc.c b/sys/src/cmd/pict/rgbycc.c index f0c8756..e535fbc 100644 --- a/sys/src/cmd/pict/rgbycc.c +++ b/sys/src/cmd/pict/rgbycc.c @@ -1,5 +1,5 @@ #include -#include +#include #include float c1 = 1.402; diff --git a/sys/src/cmd/pict/tga.c b/sys/src/cmd/pict/tga.c index ef0d18c..e7817ab 100644 --- a/sys/src/cmd/pict/tga.c +++ b/sys/src/cmd/pict/tga.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/tif.c b/sys/src/cmd/pict/tif.c index 28adc0f..97fe1ea 100644 --- a/sys/src/cmd/pict/tif.c +++ b/sys/src/cmd/pict/tif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/togif.c b/sys/src/cmd/pict/togif.c index 2a5e186..491e96c 100644 --- a/sys/src/cmd/pict/togif.c +++ b/sys/src/cmd/pict/togif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/toico.c b/sys/src/cmd/pict/toico.c index f32825c..9141c1d 100644 --- a/sys/src/cmd/pict/toico.c +++ b/sys/src/cmd/pict/toico.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/pict/tojpg.c b/sys/src/cmd/pict/tojpg.c index 79a3e9f..d792f5e 100644 --- a/sys/src/cmd/pict/tojpg.c +++ b/sys/src/cmd/pict/tojpg.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/topng.c b/sys/src/cmd/pict/topng.c index 09c0061..b760d9c 100644 --- a/sys/src/cmd/pict/topng.c +++ b/sys/src/cmd/pict/topng.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/toppm.c b/sys/src/cmd/pict/toppm.c index 724854e..ce66381 100644 --- a/sys/src/cmd/pict/toppm.c +++ b/sys/src/cmd/pict/toppm.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/torgbv.c b/sys/src/cmd/pict/torgbv.c index 6a58d03..6363b75 100644 --- a/sys/src/cmd/pict/torgbv.c +++ b/sys/src/cmd/pict/torgbv.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/totif.c b/sys/src/cmd/pict/totif.c index 2e440b9..4f7efb7 100644 --- a/sys/src/cmd/pict/totif.c +++ b/sys/src/cmd/pict/totif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/totruecolor.c b/sys/src/cmd/pict/totruecolor.c index 5dead68..0613865 100644 --- a/sys/src/cmd/pict/totruecolor.c +++ b/sys/src/cmd/pict/totruecolor.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/v210.c b/sys/src/cmd/pict/v210.c index 0614c2a..2d77646 100644 --- a/sys/src/cmd/pict/v210.c +++ b/sys/src/cmd/pict/v210.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/writegif.c b/sys/src/cmd/pict/writegif.c index 346bc18..3d6dfee 100644 --- a/sys/src/cmd/pict/writegif.c +++ b/sys/src/cmd/pict/writegif.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/writejpg.c b/sys/src/cmd/pict/writejpg.c index e764d9f..ec81771 100644 --- a/sys/src/cmd/pict/writejpg.c +++ b/sys/src/cmd/pict/writejpg.c @@ -12,7 +12,7 @@ * http://code.google.com/p/go/source/browse/src/pkg/image/jpeg/fdct.go */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/writepng.c b/sys/src/cmd/pict/writepng.c index ad03601..cb4d018 100644 --- a/sys/src/cmd/pict/writepng.c +++ b/sys/src/cmd/pict/writepng.c @@ -2,7 +2,7 @@ * See PNG 1.2 spec, also RFC 2083. */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/writeppm.c b/sys/src/cmd/pict/writeppm.c index 34b74fe..e8115d3 100644 --- a/sys/src/cmd/pict/writeppm.c +++ b/sys/src/cmd/pict/writeppm.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/writerawimage.c b/sys/src/cmd/pict/writerawimage.c index 0ed4028..a893695 100644 --- a/sys/src/cmd/pict/writerawimage.c +++ b/sys/src/cmd/pict/writerawimage.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "imagefile.h" diff --git a/sys/src/cmd/pict/writetif.c b/sys/src/cmd/pict/writetif.c index c413cbb..e7b6a00 100644 --- a/sys/src/cmd/pict/writetif.c +++ b/sys/src/cmd/pict/writetif.c @@ -14,7 +14,7 @@ * http://www.remotesensing.org/libtiff/ */ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pict/yuv.c b/sys/src/cmd/pict/yuv.c index 25d7820..795daf3 100644 --- a/sys/src/cmd/pict/yuv.c +++ b/sys/src/cmd/pict/yuv.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/pipefile.c b/sys/src/cmd/pipefile.c index c2851e1..4a51e75 100644 --- a/sys/src/cmd/pipefile.c +++ b/sys/src/cmd/pipefile.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define TEMP "/n/temp" diff --git a/sys/src/cmd/ps.c b/sys/src/cmd/ps.c index 92470a2..67fb479 100644 --- a/sys/src/cmd/ps.c +++ b/sys/src/cmd/ps.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void ps(char*); diff --git a/sys/src/cmd/pwd.c b/sys/src/cmd/pwd.c index 15f33b8..0a99882 100644 --- a/sys/src/cmd/pwd.c +++ b/sys/src/cmd/pwd.c @@ -17,7 +17,7 @@ */ #include -#include +#include /* * Print working (current) directory */ diff --git a/sys/src/cmd/ramfs.c b/sys/src/cmd/ramfs.c index 3b5b7da..85a1796 100644 --- a/sys/src/cmd/ramfs.c +++ b/sys/src/cmd/ramfs.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include <9P2000.h> diff --git a/sys/src/cmd/rc/build.json b/sys/src/cmd/rc/build.json index c90e23f..10cc167 100644 --- a/sys/src/cmd/rc/build.json +++ b/sys/src/cmd/rc/build.json @@ -13,6 +13,7 @@ "Install": "/arch/$ARCH/cmd/", "Program": "rc", "SourceFiles": [ + "/sys/src/lib/c/lib9.c", "code.c", "exec.c", "getflags.c", diff --git a/sys/src/cmd/rc/rc.h b/sys/src/cmd/rc/rc.h index c31cab7..abb2969 100644 --- a/sys/src/cmd/rc/rc.h +++ b/sys/src/cmd/rc/rc.h @@ -15,7 +15,7 @@ #ifndef Unix /* plan 9 */ #include -#include +#include #define NSIG 32 #define SIGINT 2 diff --git a/sys/src/cmd/rio/data.c b/sys/src/cmd/rio/data.c index 8821229..c3adbb8 100644 --- a/sys/src/cmd/rio/data.c +++ b/sys/src/cmd/rio/data.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c index 5fda892..32eba12 100644 --- a/sys/src/cmd/rio/fsys.c +++ b/sys/src/cmd/rio/fsys.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index b7313ed..5324a90 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -328,7 +328,7 @@ shutdown(void * _, char *msg) killprocs(); for(i=0; oknotes[i]; i++) if(strncmp(oknotes[i], msg, strlen(oknotes[i])) == 0){ - lock(&shutdownlk); /* only one can threadexitsall */ + jehanne_lock(&shutdownlk); /* only one can threadexitsall */ threadexitsall(msg); } fprint(2, "rio %d: abort: %s\n", getpid(), msg); diff --git a/sys/src/cmd/rio/scrl.c b/sys/src/cmd/rio/scrl.c index 1d48409..22fd3db 100644 --- a/sys/src/cmd/rio/scrl.c +++ b/sys/src/cmd/rio/scrl.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/time.c b/sys/src/cmd/rio/time.c index 4dda61d..fd7ff10 100644 --- a/sys/src/cmd/rio/time.c +++ b/sys/src/cmd/rio/time.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/util.c b/sys/src/cmd/rio/util.c index e161f2e..2f1f167 100644 --- a/sys/src/cmd/rio/util.c +++ b/sys/src/cmd/rio/util.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/wctl.c b/sys/src/cmd/rio/wctl.c index 74c9d66..6b55bb6 100644 --- a/sys/src/cmd/rio/wctl.c +++ b/sys/src/cmd/rio/wctl.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c index 9ba7dd8..cca8eaa 100644 --- a/sys/src/cmd/rio/wind.c +++ b/sys/src/cmd/rio/wind.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c index 911abce..477cbe1 100644 --- a/sys/src/cmd/rio/xfid.c +++ b/sys/src/cmd/rio/xfid.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/rm.c b/sys/src/cmd/rm.c index 9a9d9dd..27b32e2 100644 --- a/sys/src/cmd/rm.c +++ b/sys/src/cmd/rm.c @@ -8,7 +8,7 @@ */ #include -#include +#include char errbuf[ERRMAX]; int ignerr = 0; diff --git a/sys/src/cmd/sam/sam.h b/sys/src/cmd/sam/sam.h index bc06f31..f5bb293 100644 --- a/sys/src/cmd/sam/sam.h +++ b/sys/src/cmd/sam/sam.h @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "errors.h" diff --git a/sys/src/cmd/samterm/flayer.c b/sys/src/cmd/samterm/flayer.c index cb779c7..a54ae7b 100644 --- a/sys/src/cmd/samterm/flayer.c +++ b/sys/src/cmd/samterm/flayer.c @@ -57,7 +57,7 @@ flnew(Flayer *l, Rune *(*fn)(Flayer*, long, uint32_t*), int u0, void *u1) { if(nllist == nlalloc){ nlalloc += DELTA; - llist = realloc(llist, nlalloc*sizeof(Flayer**)); + llist = jehanne_realloc(llist, nlalloc*sizeof(Flayer**)); if(llist == 0) panic("flnew"); } @@ -82,7 +82,7 @@ flrect(Flayer *l, Rectangle r) static void fontbuggered(char *name) { - fprint(2, "samterm: font %s has zero-width \"0\" character\n", name); + jehanne_fprint(2, "samterm: font %s has zero-width \"0\" character\n", name); threadexits("font zero-width"); } diff --git a/sys/src/cmd/samterm/io.c b/sys/src/cmd/samterm/io.c index 4b56f1b..ee6ecad 100644 --- a/sys/src/cmd/samterm/io.c +++ b/sys/src/cmd/samterm/io.c @@ -49,16 +49,16 @@ initio(void) threadsetname("main"); mousectl = initmouse(nil, display->image); if(mousectl == nil){ - fprint(2, "samterm: mouse init failed: %r\n"); + jehanne_fprint(2, "samterm: mouse init failed: %r\n"); threadexitsall("mouse"); } mousep = (Mouse *)mousectl; keyboardctl = initkeyboard(nil); if(keyboardctl == nil){ - fprint(2, "samterm: keyboard init failed: %r\n"); + jehanne_fprint(2, "samterm: keyboard init failed: %r\n"); threadexitsall("kbd"); } - atexit(closeio); + jehanne_atexit(closeio); hoststart(); if(plumbstart() < 0) extstart(); @@ -93,10 +93,10 @@ button(int but) void externload(int i) { - plumbbase = malloc(plumbbuf[i].n); + plumbbase = jehanne_malloc(plumbbuf[i].n); if(plumbbase == 0) return; - memmove(plumbbase, plumbbuf[i].data, plumbbuf[i].n); + jehanne_memmove(plumbbase, plumbbuf[i].data, plumbbuf[i].n); plumbp = plumbbase; plumbstop = plumbbase + plumbbuf[i].n; got |= 1<= plumbstop){ got &= ~(1<c, &r) < 0){ - fprint(2, "samterm: keybard recv error: %r\n"); + jehanne_fprint(2, "samterm: keybard recv error: %r\n"); panic("kbd"); } return r; diff --git a/sys/src/cmd/samterm/main.c b/sys/src/cmd/samterm/main.c index 6e34e95..9e5badc 100644 --- a/sys/src/cmd/samterm/main.c +++ b/sys/src/cmd/samterm/main.c @@ -188,7 +188,7 @@ closeup(Flayer *l) work = 0; if(--t->nwin == 0){ rclear(&t->rasp); - free((uint8_t *)t); + jehanne_free((uint8_t *)t); text[m] = 0; }else if(l == &t->l[t->front]){ for(m=0; m?@[\\]^`{|}~", c)) + if(jehanne_utfrune("!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", c)) return 0; return 1; } @@ -695,8 +695,8 @@ panic(char *s) void panic1(Display* d, char *s) { - fprint(2, "samterm:panic: "); - perror(s); + jehanne_fprint(2, "samterm:panic: "); + jehanne_perror(s); abort(); } @@ -721,9 +721,9 @@ alloc(uint32_t n) { void *p; - p = malloc(n); + p = jehanne_malloc(n); if(p == 0) panic("alloc"); - memset(p, 0, n); + jehanne_memset(p, 0, n); return p; } diff --git a/sys/src/cmd/samterm/menu.c b/sys/src/cmd/samterm/menu.c index 5e26969..9b5bc26 100644 --- a/sys/src/cmd/samterm/menu.c +++ b/sys/src/cmd/samterm/menu.c @@ -214,8 +214,8 @@ sweeptext(int new, int tag) Rectangle r; Text *t; - if(getr(&r) && (t = malloc(sizeof(Text)))){ - memset((void*)t, 0, sizeof(Text)); + if(getr(&r) && (t = jehanne_malloc(sizeof(Text)))){ + jehanne_memset((void*)t, 0, sizeof(Text)); current((Flayer *)0); flnew(&t->l[0], gettext, 0, (char *)t); flinit(&t->l[0], r, font, maincols); /*bnl*/ @@ -254,9 +254,9 @@ menuins(int n, uint8_t *s, Text *t, int m, int tg) mname = 32; else mname *= 2; - name = realloc(name, sizeof(name[0])*mname); - text = realloc(text, sizeof(text[0])*mname); - tag = realloc(tag, sizeof(tag[0])*mname); + name = jehanne_realloc(name, sizeof(name[0])*mname); + text = jehanne_realloc(text, sizeof(text[0])*mname); + tag = jehanne_realloc(tag, sizeof(tag[0])*mname); if(name==nil || text==nil || tag==nil) panic("realloc"); } @@ -264,9 +264,9 @@ menuins(int n, uint8_t *s, Text *t, int m, int tg) name[i]=name[i-1], text[i]=text[i-1], tag[i]=tag[i-1]; text[n] = t; tag[n] = tg; - name[n] = alloc(strlen((char*)s)+2); + name[n] = alloc(jehanne_strlen((char*)s)+2); name[n][0] = m; - strcpy((char*)name[n]+1, (char*)s); + jehanne_strcpy((char*)name[n]+1, (char*)s); nname++; menu3.lasthit = n+NMENU3; } @@ -278,7 +278,7 @@ menudel(int n) if(nname==0 || n>=nname || text[n]) panic("menudel"); - free(name[n]); + jehanne_free(name[n]); --nname; for(i = n; i mw) mw = w; } @@ -380,28 +380,28 @@ genmenu3(int n) buf[0] = '\''; } } - l = utflen((char*)name[n]+1); + l = jehanne_utflen((char*)name[n]+1); if(l > NBUF-4-2){ i = 4; k = 1; while(i < NBUF/2){ - k += chartorune(&r, (char*)name[n]+k); + k += jehanne_chartorune(&r, (char*)name[n]+k); i++; } c = name[n][k]; name[n][k] = 0; - strcpy((char*)buf+4, (char*)name[n]+1); + jehanne_strcpy((char*)buf+4, (char*)name[n]+1); name[n][k] = c; - strcat((char*)buf, "..."); + jehanne_strcat((char*)buf, "..."); while((l-i) >= NBUF/2-4){ - k += chartorune(&r, (char*)name[n]+k); + k += jehanne_chartorune(&r, (char*)name[n]+k); i++; } - strcat((char*)buf, (char*)name[n]+k); + jehanne_strcat((char*)buf, (char*)name[n]+k); }else - strcpy((char*)buf+4, (char*)name[n]+1); - i = utflen((char*)buf); - k = strlen((char*)buf); + jehanne_strcpy((char*)buf+4, (char*)name[n]+1); + i = jehanne_utflen((char*)buf); + k = jehanne_strlen((char*)buf); while(iDATASIZE"); } if(count == 0) @@ -116,7 +116,7 @@ inmesg(Hmesg type, int count) default: if(type == ((Hmesg)-1)) panic("rcv error"); - fprint(2, "type %d\n", type); + jehanne_fprint(2, "type %d\n", type); panic("rcv unknown"); case Hversion: @@ -170,7 +170,7 @@ inmesg(Hmesg type, int count) m = 1; else m = 0; for(; m= 0){ if(!s1) n = 0; - s1 = realloc(s1, n+1); + s1 = jehanne_realloc(s1, n+1); if (!s1) panic("realloc"); s1[n] = 0; @@ -662,10 +662,10 @@ hsetsnarf(int nc) outTs(Tsetsnarf, n); if(n>0 && write(1, s1, n)!=n) panic("snarf write error"); - free(s1); + jehanne_free(s1); }else outTs(Tsetsnarf, 0); - free(s2); + jehanne_free(s2); setcursor(mousectl, cursor); } @@ -685,7 +685,7 @@ hplumb(int nc) plumbsend(plumbfd, m); plumbfree(m); } - free(s); + jehanne_free(s); } void @@ -757,7 +757,7 @@ hdata(int m, long a, uint8_t *s, int len) return 0; r = buf; for(i=0; iclipr, display->white, nil, ZP); } @@ -73,12 +73,12 @@ screensize(int *w, int *h) return 0; buf[n] = 0; if (h) { - *h = atoi(buf+4*12)-atoi(buf+2*12); + *h = jehanne_atoi(buf+4*12)-jehanne_atoi(buf+2*12); if (*h < 0) return 0; } if (w) { - *w = atoi(buf+3*12)-atoi(buf+1*12); + *w = jehanne_atoi(buf+3*12)-jehanne_atoi(buf+1*12); if (*w < 0) return 0; } @@ -104,10 +104,10 @@ snarfswap(char *fromsam, int nc, char **tosam) n = 0; if (n == 0) { *tosam = 0; - free(s1); + jehanne_free(s1); } else s1[n] = 0; - f = ocreate("/dev/snarf", OWRITE, 0666); + f = jehanne_ocreate("/dev/snarf", OWRITE, 0666); if(f >= 0){ write(f, fromsam, nc); close(f); @@ -118,7 +118,7 @@ snarfswap(char *fromsam, int nc, char **tosam) void dumperrmsg(int count, int type, int count0, int c) { - fprint(2, "samterm: host mesg: count %d %ux %ux %ux %s...ignored\n", + jehanne_fprint(2, "samterm: host mesg: count %d %ux %ux %ux %s...ignored\n", count, type, count0, c, rcvstring()); } @@ -147,7 +147,7 @@ extproc(void *argv) i = 1-i; /* toggle */ n = read(*fdp, plumbbuf[i].data, sizeof plumbbuf[i].data); if(n <= 0){ - fprint(2, "samterm: extern read error: %r\n"); + jehanne_fprint(2, "samterm: extern read error: %r\n"); threadexits("extern"); /* not a fatal error */ } plumbbuf[i].n = n; @@ -164,18 +164,18 @@ extstart(void) static int p[2]; static void *arg[2]; - if(pipe(p) < 0) + if(jehanne_pipe(p) < 0) return; - sprint(exname, "/srv/sam.%s", getuser()); - fd = ocreate(exname, OWRITE, 0600); + jehanne_sprint(exname, "/srv/sam.%s", jehanne_getuser()); + fd = jehanne_ocreate(exname, OWRITE, 0600); if(fd < 0){ /* assume existing guy is more important */ Err: close(p[0]); close(p[1]); return; } - sprint(buf, "%d", p[0]); - if(write(fd, buf, strlen(buf)) <= 0) + jehanne_sprint(buf, "%d", p[0]); + if(write(fd, buf, jehanne_strlen(buf)) <= 0) goto Err; close(fd); /* @@ -186,7 +186,7 @@ extstart(void) arg[0] = plumbc; arg[1] = &p[1]; proccreate(extproc, arg, STACK); - atexit(removeextern); + jehanne_atexit(removeextern); } int @@ -206,7 +206,7 @@ plumbformat(int i) return 0; } act = plumblookup(m->attr, "action"); - if(act!=nil && strcmp(act, "showfile")!=0){ + if(act!=nil && jehanne_strcmp(act, "showfile")!=0){ /* can't handle other cases yet */ plumbfree(m); return 0; @@ -216,17 +216,17 @@ plumbformat(int i) if(addr[0] == '\0') addr = nil; else - addr = strdup(addr); /* copy to safe storage; we'll overwrite data */ + addr = jehanne_strdup(addr); /* copy to safe storage; we'll overwrite data */ } - memmove(data, "B ", 2); /* we know there's enough room for this */ - memmove(data+2, m->data, n); + jehanne_memmove(data, "B ", 2); /* we know there's enough room for this */ + jehanne_memmove(data+2, m->data, n); n += 2; if(data[n-1] != '\n') data[n++] = '\n'; if(addr != nil){ - if(n+strlen(addr)+1+1 <= READBUFSIZE) - n += sprint(data+n, "%s\n", addr); - free(addr); + if(n+jehanne_strlen(addr)+1+1 <= READBUFSIZE) + n += jehanne_sprint(data+n, "%s\n", addr); + jehanne_free(addr); } plumbbuf[i].n = n; plumbfree(m); @@ -249,7 +249,7 @@ plumbproc(void *argv) i = 1-i; /* toggle */ n = read(*fdp, plumbbuf[i].data, READBUFSIZE); if(n <= 0){ - fprint(2, "samterm: plumb read error: %r\n"); + jehanne_fprint(2, "samterm: plumb read error: %r\n"); threadexits("plumb"); /* not a fatal error */ } plumbbuf[i].n = n; @@ -297,9 +297,9 @@ hostproc(void *arg) if(n==0){ if(exiting) threadexits(nil); - werrstr("unexpected eof"); + jehanne_werrstr("unexpected eof"); } - fprint(2, "samterm: host read error: %r\n"); + jehanne_fprint(2, "samterm: host read error: %r\n"); threadexitsall("host"); } hostbuf[i].n = n; diff --git a/sys/src/cmd/samterm/rasp.c b/sys/src/cmd/samterm/rasp.c index 645fe14..2f0da95 100644 --- a/sys/src/cmd/samterm/rasp.c +++ b/sys/src/cmd/samterm/rasp.c @@ -31,8 +31,8 @@ rclear(Rasp *r) for(s=r->sect; s; s=ns){ ns = s->next; - free(s->text); - free(s); + jehanne_free(s->text); + jehanne_free(s); } r->sect = 0; } @@ -81,8 +81,8 @@ rsdelete(Rasp *r, Section *s) t->next = s->next; Free: if(s->text) - free(s->text); - free(s); + jehanne_free(s->text); + jehanne_free(s); return; } panic("rsdelete 2"); @@ -155,7 +155,7 @@ rdata(Rasp *r, long p0, long p1, Rune *cp) p1 -= p0; s = rsinsert(r, t); s->text = alloc(RUNESIZE*(TBLOCKSIZE+1)); - memmove(s->text, cp, RUNESIZE*p1); + jehanne_memmove(s->text, cp, RUNESIZE*p1); s->text[p1] = 0; s->nrunes = p1; } @@ -206,7 +206,7 @@ rload(Rasp *r, uint32_t p0, uint32_t p1, uint32_t *nrp) n = s->nrunes-(p0-p); if(n>p1-p0) /* all in this section */ n = p1-p0; - memmove(scratch+nb, s->text+(p0-p), n*RUNESIZE); + jehanne_memmove(scratch+nb, s->text+(p0-p), n*RUNESIZE); nb += n; scratch[nb] = 0; } @@ -268,7 +268,7 @@ Strgrow(Rune **s, long *n, int want) /* can always toss the old data when called { if(*n >= want) return; - free(*s); + jehanne_free(*s); *s = alloc(RUNESIZE*want); *n = want; } diff --git a/sys/src/cmd/samterm/scroll.c b/sys/src/cmd/samterm/scroll.c index 50cd96e..3aacd35 100644 --- a/sys/src/cmd/samterm/scroll.c +++ b/sys/src/cmd/samterm/scroll.c @@ -129,7 +129,7 @@ scroll(Flayer *l, int but) draw(scrback, Rect(0,0,Dx(l->scroll), Dy(l->scroll)), l->f.b, nil, l->scroll.min); do{ oin = in; - in = (but > 3) || (but == 2) || abs(x-mousep->xy.x)<=FLSCROLLWID/2; + in = (but > 3) || (but == 2) || jehanne_abs(x-mousep->xy.x)<=FLSCROLLWID/2; if(oin && !in) scrunmark(l, r); if(in){ diff --git a/sys/src/cmd/sed.c b/sys/src/cmd/sed.c index 9ea3c60..0aa519b 100644 --- a/sys/src/cmd/sed.c +++ b/sys/src/cmd/sed.c @@ -11,7 +11,7 @@ * sed -- stream editor */ #include -#include +#include #include #include diff --git a/sys/src/cmd/seq.c b/sys/src/cmd/seq.c index ab4fa8a..8e2faac 100644 --- a/sys/src/cmd/seq.c +++ b/sys/src/cmd/seq.c @@ -8,7 +8,7 @@ */ #include -#include +#include double min = 1.0; double max = 0.0; diff --git a/sys/src/cmd/sleep.c b/sys/src/cmd/sleep.c index 7c9e68c..569e507 100644 --- a/sys/src/cmd/sleep.c +++ b/sys/src/cmd/sleep.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/sys/src/cmd/sort.c b/sys/src/cmd/sort.c index 86ec66c..52fa1d1 100644 --- a/sys/src/cmd/sort.c +++ b/sys/src/cmd/sort.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/cmd/split.c b/sys/src/cmd/split.c index a0db924..07dd7ef 100644 --- a/sys/src/cmd/split.c +++ b/sys/src/cmd/split.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/srv.c b/sys/src/cmd/srv.c index 54493c4..0b525d1 100644 --- a/sys/src/cmd/srv.c +++ b/sys/src/cmd/srv.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/srvfs.c b/sys/src/cmd/srvfs.c index 3f643fb..5c965c9 100644 --- a/sys/src/cmd/srvfs.c +++ b/sys/src/cmd/srvfs.c @@ -8,7 +8,7 @@ */ #include -#include +#include static void usage(void) diff --git a/sys/src/cmd/stats.c b/sys/src/cmd/stats.c index 1fc58d5..56681ab 100644 --- a/sys/src/cmd/stats.c +++ b/sys/src/cmd/stats.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/cmd/sys/call/syscall.c b/sys/src/cmd/sys/call/syscall.c index 5a1be0c..36e80ee 100644 --- a/sys/src/cmd/sys/call/syscall.c +++ b/sys/src/cmd/sys/call/syscall.c @@ -8,7 +8,7 @@ */ #define PORTABLE_SYSCALLS #include -#include +#include //#include #include <9P2000.h> diff --git a/sys/src/cmd/sys/ctrace.c b/sys/src/cmd/sys/ctrace.c index 7ee65ea..7e9cf9b 100644 --- a/sys/src/cmd/sys/ctrace.c +++ b/sys/src/cmd/sys/ctrace.c @@ -1,5 +1,5 @@ #include -#include +#include #include enum { diff --git a/sys/src/cmd/tail.c b/sys/src/cmd/tail.c index aaf702d..ee10e7b 100644 --- a/sys/src/cmd/tail.c +++ b/sys/src/cmd/tail.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/cmd/tar.c b/sys/src/cmd/tar.c index 7d910a0..1befe61 100644 --- a/sys/src/cmd/tar.c +++ b/sys/src/cmd/tar.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include <9P2000.h> /* for %M */ #include diff --git a/sys/src/cmd/tee.c b/sys/src/cmd/tee.c index ff07a7a..8058e4d 100644 --- a/sys/src/cmd/tee.c +++ b/sys/src/cmd/tee.c @@ -12,7 +12,7 @@ */ #include -#include +#include int uflag; int aflag; diff --git a/sys/src/cmd/test.c b/sys/src/cmd/test.c index 8af1a34..2f04a19 100644 --- a/sys/src/cmd/test.c +++ b/sys/src/cmd/test.c @@ -19,7 +19,7 @@ */ #include -#include +#include #define EQ(a,b) ((tmp=a)==0?0:(strcmp(tmp,b)==0)) diff --git a/sys/src/cmd/time.c b/sys/src/cmd/time.c index bed7964..dea0f4d 100644 --- a/sys/src/cmd/time.c +++ b/sys/src/cmd/time.c @@ -25,18 +25,18 @@ main(int argc, char *argv[]) char err[ERRMAX]; if(argc <= 1){ - fprint(2, "usage: time command\n"); - exits("usage"); + jehanne_fprint(2, "usage: time command\n"); + jehanne_exits("usage"); } - switch(fork()){ + switch(jehanne_fork()){ case -1: error("fork"); case 0: exec(argv[1], &argv[1]); - if(argv[1][0] != '/' && strncmp(argv[1], "./", 2) && - strncmp(argv[1], "../", 3)){ - sprint(output, "/cmd/%s", argv[1]); + if(argv[1][0] != '/' && jehanne_strncmp(argv[1], "./", 2) && + jehanne_strncmp(argv[1], "../", 3)){ + jehanne_sprint(output, "/cmd/%s", argv[1]); exec(output, &argv[1]); } error(argv[1]); @@ -45,10 +45,10 @@ main(int argc, char *argv[]) notify(notifyf); loop: - w = wait(); + w = jehanne_wait(); if(w == nil){ errstr(err, sizeof err); - if(strcmp(err, "interrupted") == 0) + if(jehanne_strcmp(err, "interrupted") == 0) goto loop; error("wait"); } @@ -67,15 +67,15 @@ main(int argc, char *argv[]) } } if(w->msg[0]){ - p = utfrune(w->msg, ':'); + p = jehanne_utfrune(w->msg, ':'); if(p && p[1]) p++; else p = w->msg; add(" # status=%s", p); } - fprint(2, "%s\n", output); - exits(w->msg); + jehanne_fprint(2, "%s\n", output); + jehanne_exits(w->msg); } void @@ -85,9 +85,9 @@ add(char *a, ...) va_list arg; if(beenhere) - strcat(output, " "); + jehanne_strcat(output, " "); va_start(arg, a); - vseprint(output+strlen(output), output+sizeof(output), a, arg); + jehanne_vseprint(output+jehanne_strlen(output), output+sizeof(output), a, arg); va_end(arg); beenhere++; } @@ -96,15 +96,15 @@ void error(char *s) { - fprint(2, "time: %s: %r\n", s); - exits(s); + jehanne_fprint(2, "time: %s: %r\n", s); + jehanne_exits(s); } void notifyf(void *a, char *s) { USED(a); - if(strcmp(s, "interrupt") == 0) + if(jehanne_strcmp(s, "interrupt") == 0) noted(NCONT); noted(NDFLT); } diff --git a/sys/src/cmd/touch.c b/sys/src/cmd/touch.c index 8ae24b8..111c28c 100644 --- a/sys/src/cmd/touch.c +++ b/sys/src/cmd/touch.c @@ -8,7 +8,7 @@ */ #include -#include +#include int touch(int, char *); uint32_t now; diff --git a/sys/src/cmd/tr.c b/sys/src/cmd/tr.c index ee349da..ae36303 100644 --- a/sys/src/cmd/tr.c +++ b/sys/src/cmd/tr.c @@ -8,7 +8,7 @@ */ #include -#include +#include typedef struct PCB /* Control block controlling specification parse */ { diff --git a/sys/src/cmd/unicode.c b/sys/src/cmd/unicode.c index ddb9794..d97ec07 100644 --- a/sys/src/cmd/unicode.c +++ b/sys/src/cmd/unicode.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include char usage[] = "unicode { [-t] hex hex ... | hexmin-hexmax ... | [-n] char ... }"; diff --git a/sys/src/cmd/uniq.c b/sys/src/cmd/uniq.c index 5d0d535..52239e0 100644 --- a/sys/src/cmd/uniq.c +++ b/sys/src/cmd/uniq.c @@ -11,7 +11,7 @@ * Deal with duplicated lines in a file */ #include -#include +#include #include #include diff --git a/sys/src/cmd/unmount.c b/sys/src/cmd/unmount.c index 51520b1..2c42038 100644 --- a/sys/src/cmd/unmount.c +++ b/sys/src/cmd/unmount.c @@ -8,7 +8,7 @@ */ #include -#include +#include void main(int argc, char *argv[]) diff --git a/sys/src/cmd/usb/audio/audio.c b/sys/src/cmd/usb/audio/audio.c index cccd6ef..d869cba 100644 --- a/sys/src/cmd/usb/audio/audio.c +++ b/sys/src/cmd/usb/audio/audio.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/cmd/usb/disk/disk.c b/sys/src/cmd/usb/disk/disk.c index 14e0eff..e733a2d 100644 --- a/sys/src/cmd/usb/disk/disk.c +++ b/sys/src/cmd/usb/disk/disk.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/cmd/usb/disk/mkscsierrs b/sys/src/cmd/usb/disk/mkscsierrs index a7cc32e..9ceb338 100755 --- a/sys/src/cmd/usb/disk/mkscsierrs +++ b/sys/src/cmd/usb/disk/mkscsierrs @@ -2,7 +2,7 @@ cat < -#include +#include typedef struct Err Err; struct Err diff --git a/sys/src/cmd/usb/disk/scsierrs.c b/sys/src/cmd/usb/disk/scsierrs.c index 8bc31cc..1bf68fe 100644 --- a/sys/src/cmd/usb/disk/scsierrs.c +++ b/sys/src/cmd/usb/disk/scsierrs.c @@ -2,7 +2,7 @@ * But the errors almost never change, so there's no hurry. */ #include -#include +#include typedef struct Err Err; struct Err diff --git a/sys/src/cmd/usb/disk/scsireq.c b/sys/src/cmd/usb/disk/scsireq.c index 958d349..00ea2f7 100644 --- a/sys/src/cmd/usb/disk/scsireq.c +++ b/sys/src/cmd/usb/disk/scsireq.c @@ -14,7 +14,7 @@ */ #include -#include +#include #include <9P2000.h> #include "scsireq.h" diff --git a/sys/src/cmd/usb/ether/asix.c b/sys/src/cmd/usb/ether/asix.c index 717e104..9e1d739 100644 --- a/sys/src/cmd/usb/ether/asix.c +++ b/sys/src/cmd/usb/ether/asix.c @@ -6,7 +6,7 @@ * less than required in others. */ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/aue.c b/sys/src/cmd/usb/ether/aue.c index 2d019c2..a7d5c9a 100644 --- a/sys/src/cmd/usb/ether/aue.c +++ b/sys/src/cmd/usb/ether/aue.c @@ -5,7 +5,7 @@ * drivers/net/usb/pegasus.c driver */ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/cdc.c b/sys/src/cmd/usb/ether/cdc.c index fd1460a..54fabe3 100644 --- a/sys/src/cmd/usb/ether/cdc.c +++ b/sys/src/cmd/usb/ether/cdc.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/ether.c b/sys/src/cmd/usb/ether/ether.c index 37a24af..e777a66 100644 --- a/sys/src/cmd/usb/ether/ether.c +++ b/sys/src/cmd/usb/ether/ether.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/rndis.c b/sys/src/cmd/usb/ether/rndis.c index f411e54..759735e 100644 --- a/sys/src/cmd/usb/ether/rndis.c +++ b/sys/src/cmd/usb/ether/rndis.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/smsc.c b/sys/src/cmd/usb/ether/smsc.c index 9cf4bbe..622e8e1 100644 --- a/sys/src/cmd/usb/ether/smsc.c +++ b/sys/src/cmd/usb/ether/smsc.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ether/url.c b/sys/src/cmd/usb/ether/url.c index 6a1a2d1..eba7c76 100644 --- a/sys/src/cmd/usb/ether/url.c +++ b/sys/src/cmd/usb/ether/url.c @@ -5,7 +5,7 @@ * and bill paul's and shunsuke akiyama's freebsd rue(4) driver */ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/joy/joy.c b/sys/src/cmd/usb/joy/joy.c index 58c19a2..7c1d43c 100644 --- a/sys/src/cmd/usb/joy/joy.c +++ b/sys/src/cmd/usb/joy/joy.c @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include "usb.h" #include "hid.h" diff --git a/sys/src/cmd/usb/kb/kb.c b/sys/src/cmd/usb/kb/kb.c index 9189efc..c032903 100644 --- a/sys/src/cmd/usb/kb/kb.c +++ b/sys/src/cmd/usb/kb/kb.c @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include "usb.h" #include "hid.h" diff --git a/sys/src/cmd/usb/lib/dev.c b/sys/src/cmd/usb/lib/dev.c index 17399d6..9e3c8f3 100644 --- a/sys/src/cmd/usb/lib/dev.c +++ b/sys/src/cmd/usb/lib/dev.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/lib/dump.c b/sys/src/cmd/usb/lib/dump.c index a031ffd..35cd369 100644 --- a/sys/src/cmd/usb/lib/dump.c +++ b/sys/src/cmd/usb/lib/dump.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/lib/parse.c b/sys/src/cmd/usb/lib/parse.c index f29a10c..ad89102 100644 --- a/sys/src/cmd/usb/lib/parse.c +++ b/sys/src/cmd/usb/lib/parse.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" diff --git a/sys/src/cmd/usb/ptp/ptp.c b/sys/src/cmd/usb/ptp/ptp.c index 876d528..b47ee78 100644 --- a/sys/src/cmd/usb/ptp/ptp.c +++ b/sys/src/cmd/usb/ptp/ptp.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/usb/serial/ftdi.c b/sys/src/cmd/usb/serial/ftdi.c index a5db406..de5fb26 100644 --- a/sys/src/cmd/usb/serial/ftdi.c +++ b/sys/src/cmd/usb/serial/ftdi.c @@ -1,6 +1,6 @@ /* Future Technology Devices International serial ports */ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/usb/serial/prolific.c b/sys/src/cmd/usb/serial/prolific.c index a46cec6..f6a648b 100644 --- a/sys/src/cmd/usb/serial/prolific.c +++ b/sys/src/cmd/usb/serial/prolific.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/usb/serial/serial.c b/sys/src/cmd/usb/serial/serial.c index 4f64693..38c5645 100644 --- a/sys/src/cmd/usb/serial/serial.c +++ b/sys/src/cmd/usb/serial/serial.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/cmd/usb/serial/silabs.c b/sys/src/cmd/usb/serial/silabs.c index 9cf75f9..dea36da 100644 --- a/sys/src/cmd/usb/serial/silabs.c +++ b/sys/src/cmd/usb/serial/silabs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/usb/serial/ucons.c b/sys/src/cmd/usb/serial/ucons.c index 3349b4e..9658d8c 100644 --- a/sys/src/cmd/usb/serial/ucons.c +++ b/sys/src/cmd/usb/serial/ucons.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/usb/usbd/hname.c b/sys/src/cmd/usb/usbd/hname.c index 7ae3fee..4e4680e 100644 --- a/sys/src/cmd/usb/usbd/hname.c +++ b/sys/src/cmd/usb/usbd/hname.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/cmd/usb/usbd/hub.c b/sys/src/cmd/usb/usbd/hub.c index 89cf80f..8cd9b56 100644 --- a/sys/src/cmd/usb/usbd/hub.c +++ b/sys/src/cmd/usb/usbd/hub.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "usb.h" #include "dat.h" @@ -17,24 +17,24 @@ getdevnb(uint64_t *maskp) { int i; - lock(&masklck); + jehanne_lock(&masklck); for(i = 0; i < 8 * sizeof *maskp; i++) if((*maskp & (1ULL<= 0) *maskp &= ~(1ULL< -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/cmd/wc.c b/sys/src/cmd/wc.c index 99b93d4..5b520bd 100644 --- a/sys/src/cmd/wc.c +++ b/sys/src/cmd/wc.c @@ -11,7 +11,7 @@ * Count bytes within runes, if it fits in a uint64_t, and other things. */ #include -#include +#include #include /* flags, per-file counts, and total counts */ diff --git a/sys/src/cmd/xargs.c b/sys/src/cmd/xargs.c index 486f803..c0b9812 100644 --- a/sys/src/cmd/xargs.c +++ b/sys/src/cmd/xargs.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/cmd/xd.c b/sys/src/cmd/xd.c index 9ca3218..7d9f524 100644 --- a/sys/src/cmd/xd.c +++ b/sys/src/cmd/xd.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include uint8_t odata[16]; diff --git a/sys/src/kern/386/bios32.c b/sys/src/kern/386/bios32.c index 643516d..227cb61 100644 --- a/sys/src/kern/386/bios32.c +++ b/sys/src/kern/386/bios32.c @@ -5,7 +5,7 @@ #include "fns.h" #include "io.h" -#define VFLAG(...) if(vflag) print(__VA_ARGS__) +#define VFLAG(...) if(vflag) jehanne_print(__VA_ARGS__) #define UPTR2INT(p) ((uintptr_t)(p)) @@ -76,7 +76,7 @@ void BIOS32close(BIOS32si* si) { vunmap(si->base, si->length); - free(si); + jehanne_free(si); } BIOS32si* @@ -93,7 +93,7 @@ bios32open(char* id) } VFLAG("bios32si: %s\n", id); - memset(&ci, 0, sizeof(BIOS32ci)); + jehanne_memset(&ci, 0, sizeof(BIOS32ci)); ci.eax = (id[3]<<24|(id[2]<<16)|(id[1]<<8)|id[0]); bios32call(&ci, bios32ptr); @@ -105,10 +105,10 @@ bios32open(char* id) VFLAG("bios32si: base %#ux length %#ux offset %#ux\n", ci.ebx, ci.ecx, ci.edx); - if((si = malloc(sizeof(BIOS32si))) == nil) + if((si = jehanne_malloc(sizeof(BIOS32si))) == nil) return nil; if((si->base = vmap(ci.ebx, ci.ecx)) == nil){ - free(si); + jehanne_free(si); return nil; } si->length = ci.ecx; diff --git a/sys/src/kern/386/devether.c b/sys/src/kern/386/devether.c index 6fd819c..3b5b6ac 100644 --- a/sys/src/kern/386/devether.c +++ b/sys/src/kern/386/devether.c @@ -22,7 +22,7 @@ etherattach(Chan *c, Chan *ac, char *spec, int flags) ctlrno = 0; if(spec && *spec){ - ctlrno = strtoul(spec, &p, 0); + ctlrno = jehanne_strtoul(spec, &p, 0); if((ctlrno == 0 && p == spec) || *p != 0) error(Ebadarg); if(ctlrno < 0 || ctlrno >= MaxEther) @@ -122,7 +122,7 @@ etherrtrace(Netfile* f, Etherpkt* pkt, int len) bp = iallocb(64); if(bp == nil) return; - memmove(bp->wp, pkt->d, n); + jehanne_memmove(bp->wp, pkt->d, n); i = TK2MS(sys->ticks); bp->wp[58] = len>>8; bp->wp[59] = len; @@ -153,7 +153,7 @@ etheriq(Ether* ether, Block* bp, int fromwire) multi = pkt->d[0] & 1; /* check for valid multcast addresses */ - if(multi && memcmp(pkt->d, ether->netif.bcast, sizeof(pkt->d)) != 0 && ether->netif.prom == 0){ + if(multi && jehanne_memcmp(pkt->d, ether->netif.bcast, sizeof(pkt->d)) != 0 && ether->netif.prom == 0){ if(!activemulti(ðer->netif, pkt->d, sizeof(pkt->d))){ if(fromwire){ freeb(bp); @@ -164,8 +164,8 @@ etheriq(Ether* ether, Block* bp, int fromwire) } /* is it for me? */ - tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; - fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; + tome = jehanne_memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; + fromme = jehanne_memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; /* * Multiplex the packet to all the connections which want it. @@ -184,7 +184,7 @@ etheriq(Ether* ether, Block* bp, int fromwire) if(fromwire && fx == 0) fx = f; else if(xbp = iallocb(len)){ - memmove(xbp->wp, pkt, len); + jehanne_memmove(xbp->wp, pkt, len); xbp->wp += len; xbp->flag = bp->flag; if(qpass(f->iq, xbp) < 0) @@ -230,8 +230,8 @@ etheroq(Ether* ether, Block* bp) */ pkt = (Etherpkt*)bp->rp; len = BLEN(bp); - loopback = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; - if(loopback || memcmp(pkt->d, ether->netif.bcast, sizeof(pkt->d)) == 0 || ether->netif.prom) + loopback = jehanne_memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; + if(loopback || jehanne_memcmp(pkt->d, ether->netif.bcast, sizeof(pkt->d)) == 0 || ether->netif.prom) if(etheriq(ether, bp, loopback) == 0) return len; @@ -255,16 +255,16 @@ etherwrite(Chan* chan, void* buf, long n, int64_t _1) if(nn >= 0) return nn; cb = parsecmd(buf, n); - if(cb->f[0] && strcmp(cb->f[0], "nonblocking") == 0){ + if(cb->f[0] && jehanne_strcmp(cb->f[0], "nonblocking") == 0){ if(cb->nf <= 1) onoff = 1; else - onoff = atoi(cb->f[1]); + onoff = jehanne_atoi(cb->f[1]); qnoblock(ether->netif.oq, onoff); - free(cb); + jehanne_free(cb); return n; } - free(cb); + jehanne_free(cb); if(ether->ctl!=nil) return ether->ctl(ether,buf,n); @@ -281,8 +281,8 @@ etherwrite(Chan* chan, void* buf, long n, int64_t _1) freeb(bp); nexterror(); } - memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + jehanne_memmove(bp->rp, buf, n); + jehanne_memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; @@ -353,7 +353,7 @@ parseether(uint8_t *to, char *from) return -1; nip[1] = *p++; nip[2] = 0; - to[i] = strtoul(nip, 0, 16); + to[i] = jehanne_strtoul(nip, 0, 16); if(*p == ':') p++; } @@ -368,12 +368,12 @@ etherprobe(int cardno, int ctlrno) Ether *ether; char buf[128], name[32]; - ether = malloc(sizeof(Ether)); + ether = jehanne_malloc(sizeof(Ether)); if(ether == nil){ - print("etherprobe: no memory for Ether\n"); + jehanne_print("etherprobe: no memory for Ether\n"); return nil; } - memset(ether, 0, sizeof(Ether)); + jehanne_memset(ether, 0, sizeof(Ether)); ether->ctlrno = ctlrno; ether->tbdf = BUSUNKNOWN; ether->netif.mbps = 10; @@ -382,28 +382,28 @@ etherprobe(int cardno, int ctlrno) if(cardno < 0){ if(isaconfig("ether", ctlrno, ether) == 0){ - free(ether); + jehanne_free(ether); return nil; } for(cardno = 0; cards[cardno].type; cardno++){ - if(cistrcmp(cards[cardno].type, ether->type)) + if(jehanne_cistrcmp(cards[cardno].type, ether->type)) continue; for(i = 0; i < ether->nopt; i++){ - if(strncmp(ether->opt[i], "ea=", 3)) + if(jehanne_strncmp(ether->opt[i], "ea=", 3)) continue; if(parseether(ether->ea, ðer->opt[i][3])) - memset(ether->ea, 0, Eaddrlen); + jehanne_memset(ether->ea, 0, Eaddrlen); } break; } } if(cardno >= MaxEther || cards[cardno].type == nil){ - free(ether); + jehanne_free(ether); return nil; } if(cards[cardno].reset(ether) < 0){ - free(ether); + jehanne_free(ether); return nil; } @@ -414,7 +414,7 @@ etherprobe(int cardno, int ctlrno) */ if(ether->irq == 2) ether->irq = 9; - snprint(name, sizeof(name), "ether%d", ctlrno); + jehanne_snprint(name, sizeof(name), "ether%d", ctlrno); /* * If ether->irq is <0, it is a hack to indicate no interrupt @@ -425,19 +425,19 @@ etherprobe(int cardno, int ctlrno) if(ether->irq >= 0) ether->vector = intrenable(ether->irq, ether->interrupt, ether, ether->tbdf, name); - i = sprint(buf, "#l%d: %s: %dMbps port %#p irq %d", + i = jehanne_sprint(buf, "#l%d: %s: %dMbps port %#p irq %d", ctlrno, cards[cardno].type, ether->netif.mbps, ether->port, ether->irq); if(ether->mem) - i += sprint(buf+i, " addr %#p", ether->mem); + i += jehanne_sprint(buf+i, " addr %#p", ether->mem); if(ether->size) - i += sprint(buf+i, " size %ld", ether->size); - i += sprint(buf+i, ": %2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux", + i += jehanne_sprint(buf+i, " size %ld", ether->size); + i += jehanne_sprint(buf+i, ": %2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux", ether->ea[0], ether->ea[1], ether->ea[2], ether->ea[3], ether->ea[4], ether->ea[5]); - sprint(buf+i, "\n"); - print(buf); + jehanne_sprint(buf+i, "\n"); + jehanne_print(buf); - /* compute log10(ether->mbps) into lg */ + /* compute jehanne_log10(ether->mbps) into lg */ for(lg = 0, mb = ether->netif.mbps; mb >= 10; lg++) mb /= 10; if (lg > 0) @@ -457,8 +457,8 @@ etherprobe(int cardno, int ctlrno) if(ether->netif.oq == 0) panic("etherreset %s", name); ether->netif.alen = Eaddrlen; - memmove(ether->netif.addr, ether->ea, Eaddrlen); - memset(ether->netif.bcast, 0xFF, Eaddrlen); + jehanne_memmove(ether->netif.addr, ether->ea, Eaddrlen); + jehanne_memset(ether->netif.bcast, 0xFF, Eaddrlen); return ether; } @@ -506,7 +506,7 @@ ethershutdown(void) if(ether->irq >= 0) intrdisable(ether->vector); if(ether->shutdown == nil) { - print("#l%d: no shutdown function\n", i); + jehanne_print("#l%d: no shutdown function\n", i); continue; } (*ether->shutdown)(ether); diff --git a/sys/src/kern/386/devpmc.c b/sys/src/kern/386/devpmc.c index 68b9339..663210b 100644 --- a/sys/src/kern/386/devpmc.c +++ b/sys/src/kern/386/devpmc.c @@ -35,11 +35,11 @@ topdirinit(void) int nent; nent = 1 + MACHMAX; - toptab = mallocz(nent * sizeof(Dirtab), 1); + toptab = jehanne_mallocz(nent * sizeof(Dirtab), 1); if (toptab == nil) return; d = toptab; - strncpy(d->name, "ctrdesc", KNAMELEN); + jehanne_strncpy(d->name, "ctrdesc", KNAMELEN); mkqid(&d->qid, Qdesc, 0, 0); d->perm = 0440; @@ -64,11 +64,11 @@ corefilesinit(void) continue; }else{ /* a new one appeared, make space, should almost never happen */ - memmove(d + 1, d, (MACHMAX - i)*sizeof(*d)); - memset(d, 0, sizeof(*d)); + jehanne_memmove(d + 1, d, (MACHMAX - i)*sizeof(*d)); + jehanne_memset(d, 0, sizeof(*d)); } } - snprint(d->name, KNAMELEN, "core%4.4ud", i); + jehanne_snprint(d->name, KNAMELEN, "core%4.4ud", i); mkqid(&d->qid, PMCQID(i, Qcore), 0, 0); d->perm = 0660; nc++; @@ -156,28 +156,28 @@ pmcctlstr(char *str, int nstr, PmcCtl *p, int64_t v) int ns; ns = 0; - ns += snprint(str + ns, nstr - ns, "%#ullx ", v); + ns += jehanne_snprint(str + ns, nstr - ns, "%#ullx ", v); if (p->enab && p->enab != PmcCtlNullval) - ns += snprint(str + ns, nstr - ns, "on "); + ns += jehanne_snprint(str + ns, nstr - ns, "on "); else - ns += snprint(str + ns, nstr - ns, "off "); + ns += jehanne_snprint(str + ns, nstr - ns, "off "); if (p->user && p->user != PmcCtlNullval) - ns += snprint(str + ns, nstr - ns, "user "); + ns += jehanne_snprint(str + ns, nstr - ns, "user "); else - ns += snprint(str + ns, nstr - ns, "nouser "); + ns += jehanne_snprint(str + ns, nstr - ns, "nouser "); if (p->os && p->user != PmcCtlNullval) - ns += snprint(str + ns, nstr - ns, "os "); + ns += jehanne_snprint(str + ns, nstr - ns, "os "); else - ns += snprint(str + ns, nstr - ns, "noos "); + ns += jehanne_snprint(str + ns, nstr - ns, "noos "); /* TODO, inverse pmctrans? */ if(!p->nodesc) - ns += snprint(str + ns, nstr - ns, "%s", p->descstr); + ns += jehanne_snprint(str + ns, nstr - ns, "%s", p->descstr); else - ns += snprint(str + ns, nstr - ns, "no desc"); - ns += snprint(str + ns, nstr - ns, "\n"); + ns += jehanne_snprint(str + ns, nstr - ns, "no desc"); + ns += jehanne_snprint(str + ns, nstr - ns, "\n"); return ns; } @@ -198,9 +198,9 @@ pmcread(Chan *c, void *a, long n, int64_t offset) if(type == Qdir) return devdirread(c, a, n, nil, 0, pmcgen); - s = malloc(PmcCtlRdStr); + s = jehanne_malloc(PmcCtlRdStr); if(waserror()){ - free(s); + jehanne_free(s); nexterror(); } @@ -215,7 +215,7 @@ pmcread(Chan *c, void *a, long n, int64_t offset) if(! p.enab) continue; v = pmcgetctr(coreno, i); - ns += snprint(s + ns, PmcCtlRdStr - ns, "%2.2ud ", i); + ns += jehanne_snprint(s + ns, PmcCtlRdStr - ns, "%2.2ud ", i); nn = pmcctlstr(s + ns, PmcCtlRdStr - ns, &p, v); if (n < 0) error("bad pmc"); @@ -230,7 +230,7 @@ pmcread(Chan *c, void *a, long n, int64_t offset) error(Eperm); } n = readstr(offset, a, n, s); - free(s); + jehanne_free(s); poperror(); return n; } @@ -238,7 +238,7 @@ pmcread(Chan *c, void *a, long n, int64_t offset) static int isset(char *str) { - return strncmp(str, "-", 2) != 0; + return jehanne_strncmp(str, "-", 2) != 0; } static int @@ -266,20 +266,20 @@ fillctl(PmcCtl *p, Cmdbuf *cb, int start, int end) end = cb->nf -1; for(i = start; i <= end; i++){ if(pmcdebug != 0) - print("setting field %d to %s\n", i, cb->f[i]); + jehanne_print("setting field %d to %s\n", i, cb->f[i]); if(!isset(cb->f[i])) continue; - else if(strcmp("on", cb->f[i]) == 0) + else if(jehanne_strcmp("on", cb->f[i]) == 0) p->enab = 1; - else if(strcmp("off", cb->f[i]) == 0) + else if(jehanne_strcmp("off", cb->f[i]) == 0) p->enab = 0; - else if(strcmp("user", cb->f[i]) == 0) + else if(jehanne_strcmp("user", cb->f[i]) == 0) p->user = 1; - else if(strcmp("os", cb->f[i]) == 0) + else if(jehanne_strcmp("os", cb->f[i]) == 0) p->os = 1; - else if(strcmp("nouser", cb->f[i]) == 0) + else if(jehanne_strcmp("nouser", cb->f[i]) == 0) p->user = 0; - else if(strcmp("noos", cb->f[i]) == 0) + else if(jehanne_strcmp("noos", cb->f[i]) == 0) p->os = 0; else error("bad ctl"); @@ -308,12 +308,12 @@ pmcwrite(Chan *c, void *a, long n, int64_t) /* TODO, multiple lines? */ cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } if(cb->nf < 1) error("short ctl"); - if(strcmp("debug", cb->f[0]) == 0) + if(jehanne_strcmp("debug", cb->f[0]) == 0) pmcdebug = ~pmcdebug; else{ if(cb->nf < 2) @@ -324,16 +324,16 @@ pmcwrite(Chan *c, void *a, long n, int64_t) if(regno < 0) error("no free regno"); if(pmcdebug != 0) - print("picked regno %d\n", regno); + jehanne_print("picked regno %d\n", regno); }else{ - regno = strtoull(cb->f[0], 0, 0); + regno = jehanne_strtoull(cb->f[0], 0, 0); if(regno > pmcnregs()) error("ctr number too big"); if(pmcdebug != 0) - print("setting regno %d\n", regno); + jehanne_print("setting regno %d\n", regno); } if(isset(cb->f[1])) - pmcsetctr(coreno, strtoull(cb->f[1], 0, 0), regno); + pmcsetctr(coreno, jehanne_strtoull(cb->f[1], 0, 0), regno); pmcinitctl(&p); fillctl(&p, cb, 2, 4); @@ -343,14 +343,14 @@ pmcwrite(Chan *c, void *a, long n, int64_t) for(i = 5; i < cb->nf; i++){ if(!isset(cb->f[i])) continue; - ns += snprint(s + ns, KNAMELEN - ns, "%s ", cb->f[i]); + ns += jehanne_snprint(s + ns, KNAMELEN - ns, "%s ", cb->f[i]); p.nodesc = 0; } if(pmcdebug != 0) - print("setting desc to %s\n", p.descstr); + jehanne_print("setting desc to %s\n", p.descstr); pmcsetctl(coreno, &p, regno); } - free(cb); + jehanne_free(cb); poperror(); diff --git a/sys/src/kern/386/devrtc.c b/sys/src/kern/386/devrtc.c index a41964c..a530794 100644 --- a/sys/src/kern/386/devrtc.c +++ b/sys/src/kern/386/devrtc.c @@ -161,7 +161,7 @@ rtctime(void) } iunlock(&nvrtlock); - if(i == 100) print("we are boofheads\n"); + if(i == 100) jehanne_print("we are boofheads\n"); return t; } @@ -198,13 +198,13 @@ rtcread(Chan* c, void* buf, long n, int64_t off) iunlock(&nvrtlock); if(waserror()){ - free(start); + jehanne_free(start); nexterror(); } - memmove(buf, start, t - offset); + jehanne_memmove(buf, start, t - offset); poperror(); - free(start); + jehanne_free(start); return t - offset; } error(Ebadarg); @@ -240,7 +240,7 @@ rtcwrite(Chan* c, void* buf, long n, int64_t off) break; cp++; } - secs = strtoul(cp, 0, 0); + secs = jehanne_strtoul(cp, 0, 0); /* * convert to bcd @@ -273,10 +273,10 @@ rtcwrite(Chan* c, void* buf, long n, int64_t off) start = a = smalloc(n); if(waserror()){ - free(start); + jehanne_free(start); nexterror(); } - memmove(a, buf, n); + jehanne_memmove(a, buf, n); poperror(); ilock(&nvrtlock); @@ -288,7 +288,7 @@ rtcwrite(Chan* c, void* buf, long n, int64_t off) } iunlock(&nvrtlock); - free(start); + jehanne_free(start); return t - offset; } error(Ebadarg); diff --git a/sys/src/kern/386/ether8139.c b/sys/src/kern/386/ether8139.c index 7918608..cf02a99 100644 --- a/sys/src/kern/386/ether8139.c +++ b/sys/src/kern/386/ether8139.c @@ -311,38 +311,38 @@ rtl8139ifstat(Ether* edev, void* a, long n, uint32_t offset) Ctlr *ctlr; ctlr = edev->ctlr; - p = malloc(READSTR); + p = jehanne_malloc(READSTR); if(p == nil) error(Enomem); - l = snprint(p, READSTR, "rcr %#8.8ux\n", ctlr->rcr); - l += snprint(p+l, READSTR-l, "multicast %ud\n", ctlr->mcast); - l += snprint(p+l, READSTR-l, "ierrs %d\n", ctlr->ierrs); - l += snprint(p+l, READSTR-l, "etxth %d\n", ctlr->etxth); - l += snprint(p+l, READSTR-l, "taligned %d\n", ctlr->taligned); - l += snprint(p+l, READSTR-l, "tunaligned %d\n", ctlr->tunaligned); + l = jehanne_snprint(p, READSTR, "rcr %#8.8ux\n", ctlr->rcr); + l += jehanne_snprint(p+l, READSTR-l, "multicast %ud\n", ctlr->mcast); + l += jehanne_snprint(p+l, READSTR-l, "ierrs %d\n", ctlr->ierrs); + l += jehanne_snprint(p+l, READSTR-l, "etxth %d\n", ctlr->etxth); + l += jehanne_snprint(p+l, READSTR-l, "taligned %d\n", ctlr->taligned); + l += jehanne_snprint(p+l, READSTR-l, "tunaligned %d\n", ctlr->tunaligned); ctlr->dis += csr16r(ctlr, Dis); - l += snprint(p+l, READSTR-l, "dis %d\n", ctlr->dis); + l += jehanne_snprint(p+l, READSTR-l, "dis %d\n", ctlr->dis); ctlr->fcsc += csr16r(ctlr, Fcsc); - l += snprint(p+l, READSTR-l, "fcscnt %d\n", ctlr->fcsc); + l += jehanne_snprint(p+l, READSTR-l, "fcscnt %d\n", ctlr->fcsc); ctlr->rec += csr16r(ctlr, Rec); - l += snprint(p+l, READSTR-l, "rec %d\n", ctlr->rec); + l += jehanne_snprint(p+l, READSTR-l, "rec %d\n", ctlr->rec); - l += snprint(p+l, READSTR-l, "Tcr %#8.8lux\n", csr32r(ctlr, Tcr)); - l += snprint(p+l, READSTR-l, "Config0 %#2.2ux\n", csr8r(ctlr, Config0)); - l += snprint(p+l, READSTR-l, "Config1 %#2.2ux\n", csr8r(ctlr, Config1)); - l += snprint(p+l, READSTR-l, "Msr %#2.2ux\n", csr8r(ctlr, Msr)); - l += snprint(p+l, READSTR-l, "Config3 %#2.2ux\n", csr8r(ctlr, Config3)); - l += snprint(p+l, READSTR-l, "Config4 %#2.2ux\n", csr8r(ctlr, Config4)); + l += jehanne_snprint(p+l, READSTR-l, "Tcr %#8.8lux\n", csr32r(ctlr, Tcr)); + l += jehanne_snprint(p+l, READSTR-l, "Config0 %#2.2ux\n", csr8r(ctlr, Config0)); + l += jehanne_snprint(p+l, READSTR-l, "Config1 %#2.2ux\n", csr8r(ctlr, Config1)); + l += jehanne_snprint(p+l, READSTR-l, "Msr %#2.2ux\n", csr8r(ctlr, Msr)); + l += jehanne_snprint(p+l, READSTR-l, "Config3 %#2.2ux\n", csr8r(ctlr, Config3)); + l += jehanne_snprint(p+l, READSTR-l, "Config4 %#2.2ux\n", csr8r(ctlr, Config4)); - l += snprint(p+l, READSTR-l, "Bmcr %#4.4ux\n", csr16r(ctlr, Bmcr)); - l += snprint(p+l, READSTR-l, "Bmsr %#4.4ux\n", csr16r(ctlr, Bmsr)); - l += snprint(p+l, READSTR-l, "Anar %#4.4ux\n", csr16r(ctlr, Anar)); - l += snprint(p+l, READSTR-l, "Anlpar %#4.4ux\n", csr16r(ctlr, Anlpar)); - l += snprint(p+l, READSTR-l, "Aner %#4.4ux\n", csr16r(ctlr, Aner)); - l += snprint(p+l, READSTR-l, "Nwaytr %#4.4ux\n", csr16r(ctlr, Nwaytr)); - snprint(p+l, READSTR-l, "Cscr %#4.4ux\n", csr16r(ctlr, Cscr)); + l += jehanne_snprint(p+l, READSTR-l, "Bmcr %#4.4ux\n", csr16r(ctlr, Bmcr)); + l += jehanne_snprint(p+l, READSTR-l, "Bmsr %#4.4ux\n", csr16r(ctlr, Bmsr)); + l += jehanne_snprint(p+l, READSTR-l, "Anar %#4.4ux\n", csr16r(ctlr, Anar)); + l += jehanne_snprint(p+l, READSTR-l, "Anlpar %#4.4ux\n", csr16r(ctlr, Anlpar)); + l += jehanne_snprint(p+l, READSTR-l, "Aner %#4.4ux\n", csr16r(ctlr, Aner)); + l += jehanne_snprint(p+l, READSTR-l, "Nwaytr %#4.4ux\n", csr16r(ctlr, Nwaytr)); + jehanne_snprint(p+l, READSTR-l, "Cscr %#4.4ux\n", csr16r(ctlr, Cscr)); n = readstr(offset, a, n, p); - free(p); + jehanne_free(p); return n; } @@ -427,7 +427,7 @@ rtl8139init(Ether* edev) alloc = (uint8_t*)ROUNDUP((uintptr_t)ctlr->alloc, 32); ctlr->rbstart = alloc; alloc += ctlr->rblen+16; - memset(ctlr->rbstart, 0, ctlr->rblen+16); + jehanne_memset(ctlr->rbstart, 0, ctlr->rblen+16); csr32w(ctlr, Rbstart, PCIWADDR32(ctlr->rbstart)); ctlr->rcr = Rxfth256|Rblen|Mrxdmaunlimited|Ab|Am|Apm; @@ -471,18 +471,18 @@ rtl8139attach(Ether* edev) Ctlr *ctlr; if(edev == nil) { - print("rtl8139attach: nil edev\n"); + jehanne_print("rtl8139attach: nil edev\n"); return; } ctlr = edev->ctlr; if(ctlr == nil) { - print("rtl8139attach: nil ctlr for Ether %#p\n", edev); + jehanne_print("rtl8139attach: nil ctlr for Ether %#p\n", edev); return; } qlock(&ctlr->alock); if(ctlr->alloc == nil){ ctlr->rblen = 1<<((Rblen>>RblenSHIFT)+13); - ctlr->alloc = malloc(ctlr->rblen+16 + Ntd*Tdbsz + 32); + ctlr->alloc = jehanne_malloc(ctlr->rblen+16 + Ntd*Tdbsz + 32); if(ctlr->alloc == nil) { qunlock(&ctlr->alock); error(Enomem); @@ -509,7 +509,7 @@ rtl8139txstart(Ether* edev) td = &ctlr->td[ctlr->tdh]; if(((uintptr_t)bp->rp) & 0x03){ - memmove(td->data, bp->rp, size); + jehanne_memmove(td->data, bp->rp, size); freeb(bp); csr32w(ctlr, td->tsad, PCIWADDR32(td->data)); ctlr->tunaligned++; @@ -605,13 +605,13 @@ rtl8139receive(Ether* edev) if((bp = iallocb(length)) != nil){ if(p+length >= ctlr->rbstart+ctlr->rblen){ l = ctlr->rbstart+ctlr->rblen - p; - memmove(bp->wp, p, l); + jehanne_memmove(bp->wp, p, l); bp->wp += l; length -= l; p = ctlr->rbstart; } if(length > 0){ - memmove(bp->wp, p, length); + jehanne_memmove(bp->wp, p, length); bp->wp += length; } bp->wp -= 4; @@ -634,7 +634,7 @@ rtl8139interrupt(Ureg* _1, void* arg) edev = arg; ctlr = edev->ctlr; if(ctlr == nil) { /* not attached yet? (shouldn't happen) */ - print("rtl8139interrupt: interrupt for unattached Ether %#p\n", + jehanne_print("rtl8139interrupt: interrupt for unattached Ether %#p\n", edev); return; } @@ -642,7 +642,7 @@ rtl8139interrupt(Ureg* _1, void* arg) while((isr = csr16r(ctlr, Isr)) != 0){ csr16w(ctlr, Isr, isr); if(ctlr->alloc == nil) { - print("rtl8139interrupt: interrupt for unattached Ctlr " + jehanne_print("rtl8139interrupt: interrupt for unattached Ctlr " "%#p port %#p\n", ctlr, (void *)(int64_t)ctlr->port); return; /* not attached yet (shouldn't happen) */ } @@ -740,7 +740,7 @@ rtl8139match(Ether* edev, int id) continue; if(ioalloc(port, p->mem[0].size, 0, "rtl8139") < 0){ - print("rtl8139: port %#ux in use\n", port); + jehanne_print("rtl8139: port %#ux in use\n", port); continue; } @@ -796,7 +796,7 @@ rtl8139pnp(Ether* edev) while(p = pcimatch(p, 0, 0)){ if(p->ccrb != 0x02 || p->ccru != 0) continue; - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil) error(Enomem); ctlr->pcidev = p; @@ -819,8 +819,8 @@ rtl8139pnp(Ether* edev) */ id = 0; for(i = 0; i < edev->nopt; i++){ - if(cistrncmp(edev->opt[i], "id=", 3) == 0) - id = strtol(&edev->opt[i][3], nil, 0); + if(jehanne_cistrncmp(edev->opt[i], "id=", 3) == 0) + id = jehanne_strtol(&edev->opt[i][3], nil, 0); } ctlr = nil; @@ -842,8 +842,8 @@ rtl8139pnp(Ether* edev) * Check if the adapter's station address is to be overridden. * If not, read it from the device and set in edev->ea. */ - memset(ea, 0, Eaddrlen); - if(memcmp(ea, edev->ea, Eaddrlen) == 0){ + jehanne_memset(ea, 0, Eaddrlen); + if(jehanne_memcmp(ea, edev->ea, Eaddrlen) == 0){ i = csr32r(ctlr, Idr0); edev->ea[0] = i; edev->ea[1] = i>>8; diff --git a/sys/src/kern/386/ether8169.c b/sys/src/kern/386/ether8169.c index 1806b86..10e1e5e 100644 --- a/sys/src/kern/386/ether8169.c +++ b/sys/src/kern/386/ether8169.c @@ -389,7 +389,7 @@ rtl8169mii(Ctlr* ctlr) /* * Link management. */ - if((ctlr->mii = malloc(sizeof(Mii))) == nil) + if((ctlr->mii = jehanne_malloc(sizeof(Mii))) == nil) return -1; ctlr->mii->mir = rtl8169miimir; ctlr->mii->miw = rtl8169miimiw; @@ -420,11 +420,11 @@ rtl8169mii(Ctlr* ctlr) } if(mii(ctlr->mii, (1<<1)) == 0 || (phy = ctlr->mii->curphy) == nil){ - free(ctlr->mii); + jehanne_free(ctlr->mii); ctlr->mii = nil; return -1; } - print("rtl8169: oui %#ux phyno %d, macv = %#8.8ux phyv = %#4.4ux\n", + jehanne_print("rtl8169: oui %#ux phyno %d, macv = %#8.8ux phyv = %#4.4ux\n", phy->oui, phy->phyno, ctlr->macv, ctlr->phyv); miireset(ctlr->mii); @@ -531,7 +531,7 @@ rtl8169ifstat(Ether* edev, void* a, long n, uint32_t offset) if(waserror()){ qunlock(&ctlr->slock); - free(p); + jehanne_free(p); nexterror(); } @@ -555,56 +555,56 @@ rtl8169ifstat(Ether* edev, void* a, long n, uint32_t offset) if(n == 0){ qunlock(&ctlr->slock); poperror(); - free(p); + jehanne_free(p); return 0; } - l = snprint(p, READSTR, "TxOk: %llud\n", dtcc->txok); - l += snprint(p+l, READSTR-l, "RxOk: %llud\n", dtcc->rxok); - l += snprint(p+l, READSTR-l, "TxEr: %llud\n", dtcc->txer); - l += snprint(p+l, READSTR-l, "RxEr: %ud\n", dtcc->rxer); - l += snprint(p+l, READSTR-l, "MissPkt: %ud\n", dtcc->misspkt); - l += snprint(p+l, READSTR-l, "FAE: %ud\n", dtcc->fae); - l += snprint(p+l, READSTR-l, "Tx1Col: %ud\n", dtcc->tx1col); - l += snprint(p+l, READSTR-l, "TxMCol: %ud\n", dtcc->txmcol); - l += snprint(p+l, READSTR-l, "RxOkPh: %llud\n", dtcc->rxokph); - l += snprint(p+l, READSTR-l, "RxOkBrd: %llud\n", dtcc->rxokbrd); - l += snprint(p+l, READSTR-l, "RxOkMu: %ud\n", dtcc->rxokmu); - l += snprint(p+l, READSTR-l, "TxAbt: %ud\n", dtcc->txabt); - l += snprint(p+l, READSTR-l, "TxUndrn: %ud\n", dtcc->txundrn); + l = jehanne_snprint(p, READSTR, "TxOk: %llud\n", dtcc->txok); + l += jehanne_snprint(p+l, READSTR-l, "RxOk: %llud\n", dtcc->rxok); + l += jehanne_snprint(p+l, READSTR-l, "TxEr: %llud\n", dtcc->txer); + l += jehanne_snprint(p+l, READSTR-l, "RxEr: %ud\n", dtcc->rxer); + l += jehanne_snprint(p+l, READSTR-l, "MissPkt: %ud\n", dtcc->misspkt); + l += jehanne_snprint(p+l, READSTR-l, "FAE: %ud\n", dtcc->fae); + l += jehanne_snprint(p+l, READSTR-l, "Tx1Col: %ud\n", dtcc->tx1col); + l += jehanne_snprint(p+l, READSTR-l, "TxMCol: %ud\n", dtcc->txmcol); + l += jehanne_snprint(p+l, READSTR-l, "RxOkPh: %llud\n", dtcc->rxokph); + l += jehanne_snprint(p+l, READSTR-l, "RxOkBrd: %llud\n", dtcc->rxokbrd); + l += jehanne_snprint(p+l, READSTR-l, "RxOkMu: %ud\n", dtcc->rxokmu); + l += jehanne_snprint(p+l, READSTR-l, "TxAbt: %ud\n", dtcc->txabt); + l += jehanne_snprint(p+l, READSTR-l, "TxUndrn: %ud\n", dtcc->txundrn); - l += snprint(p+l, READSTR-l, "serr: %ud\n", ctlr->serr); - l += snprint(p+l, READSTR-l, "fovw: %ud\n", ctlr->fovw); + l += jehanne_snprint(p+l, READSTR-l, "serr: %ud\n", ctlr->serr); + l += jehanne_snprint(p+l, READSTR-l, "fovw: %ud\n", ctlr->fovw); - l += snprint(p+l, READSTR-l, "txdu: %ud\n", ctlr->txdu); - l += snprint(p+l, READSTR-l, "tcpf: %ud\n", ctlr->tcpf); - l += snprint(p+l, READSTR-l, "udpf: %ud\n", ctlr->udpf); - l += snprint(p+l, READSTR-l, "ipf: %ud\n", ctlr->ipf); - l += snprint(p+l, READSTR-l, "fovf: %ud\n", ctlr->fovf); - l += snprint(p+l, READSTR-l, "rer: %ud\n", ctlr->rer); - l += snprint(p+l, READSTR-l, "rdu: %ud\n", ctlr->rdu); - l += snprint(p+l, READSTR-l, "punlc: %ud\n", ctlr->punlc); + l += jehanne_snprint(p+l, READSTR-l, "txdu: %ud\n", ctlr->txdu); + l += jehanne_snprint(p+l, READSTR-l, "tcpf: %ud\n", ctlr->tcpf); + l += jehanne_snprint(p+l, READSTR-l, "udpf: %ud\n", ctlr->udpf); + l += jehanne_snprint(p+l, READSTR-l, "ipf: %ud\n", ctlr->ipf); + l += jehanne_snprint(p+l, READSTR-l, "fovf: %ud\n", ctlr->fovf); + l += jehanne_snprint(p+l, READSTR-l, "rer: %ud\n", ctlr->rer); + l += jehanne_snprint(p+l, READSTR-l, "rdu: %ud\n", ctlr->rdu); + l += jehanne_snprint(p+l, READSTR-l, "punlc: %ud\n", ctlr->punlc); - l += snprint(p+l, READSTR-l, "tcr: %#8.8ux\n", ctlr->tcr); - l += snprint(p+l, READSTR-l, "rcr: %#8.8ux\n", ctlr->rcr); - l += snprint(p+l, READSTR-l, "multicast: %ud\n", ctlr->mcast); + l += jehanne_snprint(p+l, READSTR-l, "tcr: %#8.8ux\n", ctlr->tcr); + l += jehanne_snprint(p+l, READSTR-l, "rcr: %#8.8ux\n", ctlr->rcr); + l += jehanne_snprint(p+l, READSTR-l, "multicast: %ud\n", ctlr->mcast); if(ctlr->mii != nil && ctlr->mii->curphy != nil){ - l += snprint(p+l, READSTR-l, "phy: "); + l += jehanne_snprint(p+l, READSTR-l, "phy: "); for(i = 0; i < NMiiPhyr; i++){ if(i && ((i & 0x07) == 0)) - l += snprint(p+l, READSTR-l, "\n "); + l += jehanne_snprint(p+l, READSTR-l, "\n "); r = miimir(ctlr->mii, i); - l += snprint(p+l, READSTR-l, " %4.4ux", r); + l += jehanne_snprint(p+l, READSTR-l, " %4.4ux", r); } - snprint(p+l, READSTR-l, "\n"); + jehanne_snprint(p+l, READSTR-l, "\n"); } n = readstr(offset, a, n, p); qunlock(&ctlr->slock); poperror(); - free(p); + jehanne_free(p); return n; } @@ -680,7 +680,7 @@ rtl8169init(Ether* edev) rtl8169reset(ctlr); - memset(ctlr->td, 0, sizeof(D)*ctlr->ntd); + jehanne_memset(ctlr->td, 0, sizeof(D)*ctlr->ntd); ctlr->tdh = ctlr->tdt = ctlr->ntq = 0; ctlr->td[ctlr->ntd-1].control = Eor; for(i = 0; i < ctlr->ntd; i++) @@ -689,7 +689,7 @@ rtl8169init(Ether* edev) freeb(bp); } - memset(ctlr->rd, 0, sizeof(D)*ctlr->nrd); + jehanne_memset(ctlr->rd, 0, sizeof(D)*ctlr->nrd); ctlr->rdh = ctlr->rdt = ctlr->nrq = 0; ctlr->rd[ctlr->nrd-1].control = Eor; for(i = 0; i < ctlr->nrd; i++) @@ -783,22 +783,22 @@ rtl8169attach(Ether* edev) if(!ctlr->init){ ctlr->ntd = Ntd; ctlr->nrd = Nrd; - ctlr->tb = malloc(ctlr->ntd*sizeof(Block*)); - ctlr->rb = malloc(ctlr->nrd*sizeof(Block*)); - ctlr->td = mallocalign(sizeof(D)*ctlr->ntd, 256, 0, 0); - ctlr->rd = mallocalign(sizeof(D)*ctlr->nrd, 256, 0, 0); - ctlr->dtcc = mallocalign(sizeof(Dtcc), 64, 0, 0); + ctlr->tb = jehanne_malloc(ctlr->ntd*sizeof(Block*)); + ctlr->rb = jehanne_malloc(ctlr->nrd*sizeof(Block*)); + ctlr->td = jehanne_mallocalign(sizeof(D)*ctlr->ntd, 256, 0, 0); + ctlr->rd = jehanne_mallocalign(sizeof(D)*ctlr->nrd, 256, 0, 0); + ctlr->dtcc = jehanne_mallocalign(sizeof(Dtcc), 64, 0, 0); if(ctlr->rb == nil || ctlr->rb == nil || ctlr->rd == nil || ctlr->rd == nil || ctlr->dtcc == nil){ - free(ctlr->tb); + jehanne_free(ctlr->tb); ctlr->tb = nil; - free(ctlr->rb); + jehanne_free(ctlr->rb); ctlr->rb = nil; - free(ctlr->td); + jehanne_free(ctlr->td); ctlr->td = nil; - free(ctlr->rd); + jehanne_free(ctlr->rd); ctlr->rd = nil; - free(ctlr->dtcc); + jehanne_free(ctlr->dtcc); ctlr->dtcc = nil; qunlock(&ctlr->alock); error(Enomem); @@ -1091,12 +1091,12 @@ rtl8169pci(void) port = p->mem[0].bar & ~0x01; if(ioalloc(port, p->mem[0].size, 0, "rtl8169") < 0){ - print("rtl8169: port %#ux in use\n", port); + jehanne_print("rtl8169: port %#ux in use\n", port); continue; } - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil){ - print("rtl8169: can't allocate memory\n"); + jehanne_print("rtl8169: can't allocate memory\n"); iofree(port); continue; } @@ -1107,8 +1107,8 @@ rtl8169pci(void) if(vetmacv(ctlr, &macv) == -1){ iofree(port); - free(ctlr); - print("rtl8169: unknown mac %.4ux %.8ux\n", p->did, macv); + jehanne_free(ctlr); + jehanne_print("rtl8169: unknown mac %.4ux %.8ux\n", p->did, macv); continue; } @@ -1125,8 +1125,8 @@ rtl8169pci(void) if(rtl8169reset(ctlr)){ iofree(port); - free(ctlr); - print("rtl8169: reset failed\n"); + jehanne_free(ctlr); + jehanne_print("rtl8169: reset failed\n"); continue; } @@ -1187,8 +1187,8 @@ rtl8169pnp(Ether* edev) * Check if the adapter's station address is to be overridden. * If not, read it from the device and set in edev->ea. */ - memset(ea, 0, Eaddrlen); - if(memcmp(ea, edev->ea, Eaddrlen) == 0){ + jehanne_memset(ea, 0, Eaddrlen); + if(jehanne_memcmp(ea, edev->ea, Eaddrlen) == 0){ r = csr32r(ctlr, Idr0); edev->ea[0] = r; edev->ea[1] = r>>8; diff --git a/sys/src/kern/386/ether82557.c b/sys/src/kern/386/ether82557.c index 1cae7f9..80968ca 100644 --- a/sys/src/kern/386/ether82557.c +++ b/sys/src/kern/386/ether82557.c @@ -361,7 +361,7 @@ ethwatchdog(void* arg) */ ctlr = ether->ctlr; if(ctlr == nil || ctlr->state == 0){ - print("%s: exiting\n", up->text); + jehanne_print("%s: exiting\n", up->text); pexit("disabled", 0); } @@ -395,7 +395,7 @@ attach(Ether* ether) * omitted. */ if((ctlr->eeprom[0x03] & 0x0003) != 0x0003){ - snprint(name, KNAMELEN, "#l%dwatchdog", ether->ctlrno); + jehanne_snprint(name, KNAMELEN, "#l%dwatchdog", ether->ctlrno); kproc(name, ethwatchdog, ether); } } @@ -434,55 +434,55 @@ ifstat(Ether* ether, void* a, long n, uint32_t offset) return 0; } - memmove(dump, ctlr->dump, sizeof(dump)); + jehanne_memmove(dump, ctlr->dump, sizeof(dump)); unlock(&ctlr->dlock); - if((alloc = malloc(READSTR)) == nil) + if((alloc = jehanne_malloc(READSTR)) == nil) error(Enomem); p = alloc; e = p + READSTR; - p = seprint(p, e, "transmit good frames: %lud\n", dump[0]); - p = seprint(p, e, "transmit maximum collisions errors: %lud\n", dump[1]); - p = seprint(p, e, "transmit late collisions errors: %lud\n", dump[2]); - p = seprint(p, e, "transmit underrun errors: %lud\n", dump[3]); - p = seprint(p, e, "transmit lost carrier sense: %lud\n", dump[4]); - p = seprint(p, e, "transmit deferred: %lud\n", dump[5]); - p = seprint(p, e, "transmit single collisions: %lud\n", dump[6]); - p = seprint(p, e, "transmit multiple collisions: %lud\n", dump[7]); - p = seprint(p, e, "transmit total collisions: %lud\n", dump[8]); - p = seprint(p, e, "receive good frames: %lud\n", dump[9]); - p = seprint(p, e, "receive CRC errors: %lud\n", dump[10]); - p = seprint(p, e, "receive alignment errors: %lud\n", dump[11]); - p = seprint(p, e, "receive resource errors: %lud\n", dump[12]); - p = seprint(p, e, "receive overrun errors: %lud\n", dump[13]); - p = seprint(p, e, "receive collision detect errors: %lud\n", dump[14]); - p = seprint(p, e, "receive short frame errors: %lud\n", dump[15]); - p = seprint(p, e, "nop: %d\n", ctlr->nop); + p = jehanne_seprint(p, e, "transmit good frames: %lud\n", dump[0]); + p = jehanne_seprint(p, e, "transmit maximum collisions errors: %lud\n", dump[1]); + p = jehanne_seprint(p, e, "transmit late collisions errors: %lud\n", dump[2]); + p = jehanne_seprint(p, e, "transmit underrun errors: %lud\n", dump[3]); + p = jehanne_seprint(p, e, "transmit lost carrier sense: %lud\n", dump[4]); + p = jehanne_seprint(p, e, "transmit deferred: %lud\n", dump[5]); + p = jehanne_seprint(p, e, "transmit single collisions: %lud\n", dump[6]); + p = jehanne_seprint(p, e, "transmit multiple collisions: %lud\n", dump[7]); + p = jehanne_seprint(p, e, "transmit total collisions: %lud\n", dump[8]); + p = jehanne_seprint(p, e, "receive good frames: %lud\n", dump[9]); + p = jehanne_seprint(p, e, "receive CRC errors: %lud\n", dump[10]); + p = jehanne_seprint(p, e, "receive alignment errors: %lud\n", dump[11]); + p = jehanne_seprint(p, e, "receive resource errors: %lud\n", dump[12]); + p = jehanne_seprint(p, e, "receive overrun errors: %lud\n", dump[13]); + p = jehanne_seprint(p, e, "receive collision detect errors: %lud\n", dump[14]); + p = jehanne_seprint(p, e, "receive short frame errors: %lud\n", dump[15]); + p = jehanne_seprint(p, e, "nop: %d\n", ctlr->nop); if(ctlr->cbqmax > ctlr->cbqmaxhw) ctlr->cbqmaxhw = ctlr->cbqmax; - p = seprint(p, e, "cbqmax: %d\n", ctlr->cbqmax); + p = jehanne_seprint(p, e, "cbqmax: %d\n", ctlr->cbqmax); ctlr->cbqmax = 0; - p = seprint(p, e, "threshold: %d\n", ctlr->threshold); + p = jehanne_seprint(p, e, "threshold: %d\n", ctlr->threshold); - p = seprint(p, e, "eeprom:"); + p = jehanne_seprint(p, e, "eeprom:"); for(i = 0; i < (1<eepromsz); i++){ if(i && ((i & 0x07) == 0)) - p = seprint(p, e, "\n "); - p = seprint(p, e, " %4.4ux", ctlr->eeprom[i]); + p = jehanne_seprint(p, e, "\n "); + p = jehanne_seprint(p, e, " %4.4ux", ctlr->eeprom[i]); } if((ctlr->eeprom[6] & 0x1F00) && !(ctlr->eeprom[6] & 0x8000)){ phyaddr = ctlr->eeprom[6] & 0x00FF; - p = seprint(p, e, "\nphy %2d:", phyaddr); + p = jehanne_seprint(p, e, "\nphy %2d:", phyaddr); for(i = 0; i < 6; i++){ - p = seprint(p, e, " %4.4ux", miir(ctlr, phyaddr, i)); + p = jehanne_seprint(p, e, " %4.4ux", miir(ctlr, phyaddr, i)); } } - seprint(p, e, "\n"); + jehanne_seprint(p, e, "\n"); n = readstr(offset, a, n, alloc); - free(alloc); + jehanne_free(alloc); return n; } @@ -513,21 +513,21 @@ txstart(Ether* ether) } else if(ctlr->action == CbConfigure){ cb->command = CbS|CbConfigure; - memmove(cb->data, ctlr->configdata, sizeof(ctlr->configdata)); + jehanne_memmove(cb->data, ctlr->configdata, sizeof(ctlr->configdata)); ctlr->action = 0; } else if(ctlr->action == CbIAS){ cb->command = CbS|CbIAS; - memmove(cb->data, ether->ea, Eaddrlen); + jehanne_memmove(cb->data, ether->ea, Eaddrlen); ctlr->action = 0; } else if(ctlr->action == CbMAS){ cb->command = CbS|CbMAS; - memset(cb->data, 0, sizeof(cb->data)); + jehanne_memset(cb->data, 0, sizeof(cb->data)); ctlr->action = 0; } else{ - print("#l%d: action %#ux\n", ether->ctlrno, ctlr->action); + jehanne_print("#l%d: action %#ux\n", ether->ctlrno, ctlr->action); ctlr->action = 0; break; } @@ -640,7 +640,7 @@ receive(Ether* ether) pbp = nil; count = rfd->count & 0x3FFF; if((count < ETHERMAXTU/4) && (pbp = iallocb(count))){ - memmove(pbp->rp, bp->rp+offsetof(Rfd, data[0]), count); + jehanne_memmove(pbp->rp, bp->rp+offsetof(Rfd, data[0]), count); pbp->wp = pbp->rp + count; rfd->count = 0; @@ -800,7 +800,7 @@ ctlrinit(Ctlr* ctlr) * transmit side. */ ilock(&ctlr->cblock); - ctlr->cbr = malloc(ctlr->ncb*sizeof(Cb)); + ctlr->cbr = jehanne_malloc(ctlr->ncb*sizeof(Cb)); if(ctlr->cbr == nil) { iunlock(&ctlr->cblock); error(Enomem); @@ -815,7 +815,7 @@ ctlrinit(Ctlr* ctlr) ctlr->cbtail = ctlr->cbr; ctlr->cbq = 0; - memmove(ctlr->configdata, configdata, sizeof(configdata)); + jehanne_memmove(ctlr->configdata, configdata, sizeof(configdata)); ctlr->threshold = 80; ctlr->tick = 0; @@ -920,7 +920,7 @@ reread: if(ctlr->eepromsz == 0){ ctlr->eepromsz = 8-size; - ctlr->eeprom = malloc((1<eepromsz)*sizeof(uint16_t)); + ctlr->eeprom = jehanne_malloc((1<eepromsz)*sizeof(uint16_t)); if(ctlr->eeprom == nil) error(Enomem); goto reread; @@ -978,11 +978,11 @@ i82557pci(void) */ port = p->mem[1].bar & ~0x01; if(ioalloc(port, p->mem[1].size, 0, "i82557") < 0){ - print("i82557: port %#ux in use\n", port); + jehanne_print("i82557: port %#ux in use\n", port); continue; } - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil) error(Enomem); ctlr->port = port; @@ -1022,7 +1022,7 @@ scanphy(Ctlr* ctlr) oui <<= 6; x = miir(ctlr, i, 3); oui |= x>>10; - //print("phy%d: oui %#ux reg1 %#ux\n", i, oui, miir(ctlr, i, 1)); + //jehanne_print("phy%d: oui %#ux reg1 %#ux\n", i, oui, miir(ctlr, i, 1)); ctlr->eeprom[6] = i; if(oui == 0xAA00) @@ -1117,7 +1117,7 @@ reset(Ether* ether) sum += x; } if(sum != 0xBABA) - print("#l%d: EEPROM checksum - %#4.4ux\n", ether->ctlrno, sum); + jehanne_print("#l%d: EEPROM checksum - %#4.4ux\n", ether->ctlrno, sum); /* * Eeprom[6] indicates whether there is a PHY and whether @@ -1181,7 +1181,7 @@ reset(Ether* ether) x = miir(ctlr, phyaddr, 0x17) & ~0x0520; x |= 0x0420; for(i = 0; i < ether->nopt; i++){ - if(cistrcmp(ether->opt[i], "congestioncontrol")) + if(jehanne_cistrcmp(ether->opt[i], "congestioncontrol")) continue; x |= 0x0100; break; @@ -1238,7 +1238,7 @@ reset(Ether* ether) medium = -1; for(i = 0; i < ether->nopt; i++){ for(k = 0; k < nelem(mediatable); k++){ - if(cistrcmp(mediatable[k], ether->opt[i])) + if(jehanne_cistrcmp(mediatable[k], ether->opt[i])) continue; medium = k; break; @@ -1312,8 +1312,8 @@ reset(Ether* ether) * If not, read it from the EEPROM and set in ether->ea prior to loading * the station address with the Individual Address Setup command. */ - memset(ea, 0, Eaddrlen); - if(memcmp(ea, ether->ea, Eaddrlen) == 0){ + jehanne_memset(ea, 0, Eaddrlen); + if(jehanne_memcmp(ea, ether->ea, Eaddrlen) == 0){ for(i = 0; i < Eaddrlen/2; i++){ x = ctlr->eeprom[i]; ether->ea[2*i] = x; diff --git a/sys/src/kern/386/ether82563.c b/sys/src/kern/386/ether82563.c index b16f2f5..9f1f4a6 100644 --- a/sys/src/kern/386/ether82563.c +++ b/sys/src/kern/386/ether82563.c @@ -672,7 +672,7 @@ i82563ifstat(Ether *edev, void *a, long n, usize offset) ctlr = edev->ctlr; qlock(&ctlr->slock); - p = s = malloc(READSTR); + p = s = jehanne_malloc(READSTR); e = p + READSTR; for(i = 0; i < Nstatistics; i++){ @@ -693,7 +693,7 @@ i82563ifstat(Ether *edev, void *a, long n, usize offset) continue; ctlr->statistics[i] = tuvl; ctlr->statistics[i+1] = tuvl >> 32; - p = seprint(p, e, "%s: %llud %llud\n", stat, tuvl, ruvl); + p = jehanne_seprint(p, e, "%s: %llud %llud\n", stat, tuvl, ruvl); i++; break; @@ -701,35 +701,35 @@ i82563ifstat(Ether *edev, void *a, long n, usize offset) ctlr->statistics[i] += r; if(ctlr->statistics[i] == 0) continue; - p = seprint(p, e, "%s: %ud %ud\n", stat, + p = jehanne_seprint(p, e, "%s: %ud %ud\n", stat, ctlr->statistics[i], r); break; } } - p = seprint(p, e, "lintr: %ud %ud\n", ctlr->lintr, ctlr->lsleep); - p = seprint(p, e, "rintr: %ud %ud\n", ctlr->rintr, ctlr->rsleep); - p = seprint(p, e, "tintr: %ud %ud\n", ctlr->tintr, ctlr->txdw); - p = seprint(p, e, "ixcs: %ud %ud %ud\n", ctlr->ixsm, ctlr->ipcs, ctlr->tcpcs); - p = seprint(p, e, "rdtr: %ud\n", ctlr->rdtr); - p = seprint(p, e, "radv: %ud\n", ctlr->radv); - p = seprint(p, e, "ctrl: %.8ux\n", csr32r(ctlr, Ctrl)); - p = seprint(p, e, "ctrlext: %.8ux\n", csr32r(ctlr, Ctrlext)); - p = seprint(p, e, "status: %.8ux\n", csr32r(ctlr, Status)); - p = seprint(p, e, "txcw: %.8ux\n", csr32r(ctlr, Txcw)); - p = seprint(p, e, "txdctl: %.8ux\n", csr32r(ctlr, Txdctl)); - p = seprint(p, e, "pba: %.8ux\n", ctlr->pba); + p = jehanne_seprint(p, e, "lintr: %ud %ud\n", ctlr->lintr, ctlr->lsleep); + p = jehanne_seprint(p, e, "rintr: %ud %ud\n", ctlr->rintr, ctlr->rsleep); + p = jehanne_seprint(p, e, "tintr: %ud %ud\n", ctlr->tintr, ctlr->txdw); + p = jehanne_seprint(p, e, "ixcs: %ud %ud %ud\n", ctlr->ixsm, ctlr->ipcs, ctlr->tcpcs); + p = jehanne_seprint(p, e, "rdtr: %ud\n", ctlr->rdtr); + p = jehanne_seprint(p, e, "radv: %ud\n", ctlr->radv); + p = jehanne_seprint(p, e, "ctrl: %.8ux\n", csr32r(ctlr, Ctrl)); + p = jehanne_seprint(p, e, "ctrlext: %.8ux\n", csr32r(ctlr, Ctrlext)); + p = jehanne_seprint(p, e, "status: %.8ux\n", csr32r(ctlr, Status)); + p = jehanne_seprint(p, e, "txcw: %.8ux\n", csr32r(ctlr, Txcw)); + p = jehanne_seprint(p, e, "txdctl: %.8ux\n", csr32r(ctlr, Txdctl)); + p = jehanne_seprint(p, e, "pba: %.8ux\n", ctlr->pba); b = rbtab + ctlr->pool; - p = seprint(p, e, "pool: fast %ud slow %ud nstarve %ud nwakey %ud starve %ud\n", + p = jehanne_seprint(p, e, "pool: fast %ud slow %ud nstarve %ud nwakey %ud starve %ud\n", b->nfast, b->nslow, b->nstarve, b->nwakey, b->starve); - p = seprint(p, e, "speeds: 10:%ud 100:%ud 1000:%ud ?:%ud\n", + p = jehanne_seprint(p, e, "speeds: 10:%ud 100:%ud 1000:%ud ?:%ud\n", ctlr->speeds[0], ctlr->speeds[1], ctlr->speeds[2], ctlr->speeds[3]); - p = seprint(p, e, "type: %s\n", cname(ctlr)); + p = jehanne_seprint(p, e, "type: %s\n", cname(ctlr)); USED(p); n = readstr(offset, a, n, s); - free(s); + jehanne_free(s); qunlock(&ctlr->slock); return n; @@ -930,7 +930,7 @@ newpool(void) if(seq == nelem(freetab)) return -1; if(freetab[seq] == nil){ - print("82563: bad freetab\n"); + jehanne_print("82563: bad freetab\n"); return -1; } return seq++; @@ -969,7 +969,7 @@ i82563txinit(Ctlr *ctlr) ctlr->tb[i] = nil; freeb(b); } - memset(&ctlr->tdba[i], 0, sizeof(Td)); + jehanne_memset(&ctlr->tdba[i], 0, sizeof(Td)); } csr32w(ctlr, Tidv, 128); csr32w(ctlr, Tadv, 64); @@ -1075,7 +1075,7 @@ i82563replenish(Ctlr *ctlr, int maysleep) if(bp == nil){ if(rdt - ctlr->rdh >= 16) break; - print("%s: pool %d: no rx buffers\n", cname(ctlr), ctlr->pool); + jehanne_print("%s: pool %d: no rx buffers\n", cname(ctlr), ctlr->pool); if(maysleep == 0) return -1; ilock(p); @@ -1296,7 +1296,7 @@ phyread0(Ctlr *c, int phyno, int reg) microdelay(1); } if((phy & (MDIe|MDIready)) != MDIready){ - print("%s: phy %d wedged %.8ux\n", cttab[c->type].name, phyno, phy); + jehanne_print("%s: phy %d wedged %.8ux\n", cttab[c->type].name, phyno, phy); return ~0; } return phy & 0xffff; @@ -1306,7 +1306,7 @@ static uint32_t phyread(Ctlr *c, uint32_t phyno, uint32_t reg) { if(setpage(c, phyno, reg>>8, reg & 0xff) == ~0){ - print("%s: phyread: bad phy page %d\n", cname(c), reg>>8); + jehanne_print("%s: phyread: bad phy page %d\n", cname(c), reg>>8); return ~0; } return phyread0(c, phyno, reg & 0xff); @@ -1345,7 +1345,7 @@ phyerrata(Ether *e, Ctlr *c, uint32_t phyno) if(c->phyerrata == 0){ c->phyerrata++; phywrite(c, phyno, Phyprst, Prst); /* try a port reset */ - print("ether%d: %s: phy port reset\n", e->ctlrno, cname(c)); + jehanne_print("ether%d: %s: phy port reset\n", e->ctlrno, cname(c)); } else c->phyerrata = 0; @@ -1519,7 +1519,7 @@ i82563attach(Ether *edev) ctlr->nrd = Nrd; ctlr->ntd = Ntd; - ctlr->alloc = malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 255); + ctlr->alloc = jehanne_malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 255); if(ctlr->alloc == nil){ qunlock(&ctlr->alock); error(Enomem); @@ -1527,19 +1527,19 @@ i82563attach(Ether *edev) ctlr->rdba = (Rd*)ROUNDUP((uintptr_t)ctlr->alloc, 256); ctlr->tdba = (Td*)(ctlr->rdba + ctlr->nrd); - ctlr->rb = malloc(ctlr->nrd * sizeof(Block*)); - ctlr->tb = malloc(ctlr->ntd * sizeof(Block*)); + ctlr->rb = jehanne_malloc(ctlr->nrd * sizeof(Block*)); + ctlr->tb = jehanne_malloc(ctlr->ntd * sizeof(Block*)); if(waserror()){ while(bp = i82563rballoc(rbtab + ctlr->pool)){ bp->free = nil; freeb(bp); } - free(ctlr->tb); + jehanne_free(ctlr->tb); ctlr->tb = nil; - free(ctlr->rb); + jehanne_free(ctlr->rb); ctlr->rb = nil; - free(ctlr->alloc); + jehanne_free(ctlr->alloc); ctlr->alloc = nil; qunlock(&ctlr->alock); nexterror(); @@ -1551,7 +1551,7 @@ i82563attach(Ether *edev) freeb(bp); } - snprint(name, sizeof name, "#l%dl", edev->ctlrno); + jehanne_snprint(name, sizeof name, "#l%dl", edev->ctlrno); if(csr32r(ctlr, Status) & Tbimode) kproc(name, serdeslproc, edev); /* mac based serdes */ else if((csr32r(ctlr, Ctrlext) & Linkmode) == Serdes) @@ -1561,10 +1561,10 @@ i82563attach(Ether *edev) else kproc(name, phylproc, edev); - snprint(name, sizeof name, "#l%dr", edev->ctlrno); + jehanne_snprint(name, sizeof name, "#l%dr", edev->ctlrno); kproc(name, i82563rproc, edev); - snprint(name, sizeof name, "#l%dt", edev->ctlrno); + jehanne_snprint(name, sizeof name, "#l%dt", edev->ctlrno); kproc(name, i82563tproc, edev); qunlock(&ctlr->alock); @@ -1784,7 +1784,7 @@ defaultea(Ctlr *ctlr, uint8_t *ra) uint64_t u; static uint8_t nilea[Eaddrlen]; - if(memcmp(ra, nilea, Eaddrlen) != 0) + if(jehanne_memcmp(ra, nilea, Eaddrlen) != 0) return; if(cttab[ctlr->type].flag & Fflashea){ /* intel mb bug */ @@ -1792,7 +1792,7 @@ defaultea(Ctlr *ctlr, uint8_t *ra) for(i = 0; i < Eaddrlen; i++) ra[i] = u >> 8*i; } - if(memcmp(ra, nilea, Eaddrlen) != 0) + if(jehanne_memcmp(ra, nilea, Eaddrlen) != 0) return; for(i = 0; i < Eaddrlen/2; i++){ ra[2*i] = ctlr->eeprom[Ea+i]; @@ -1815,7 +1815,7 @@ i82563reset(Ctlr *ctlr) else r = eeload(ctlr); if(r != 0 && r != 0xbaba){ - print("%s: bad eeprom checksum - %#.4ux\n", + jehanne_print("%s: bad eeprom checksum - %#.4ux\n", cname(ctlr), r); return -1; } @@ -1828,7 +1828,7 @@ i82563reset(Ctlr *ctlr) csr32w(ctlr, Ral+i*8, 0); csr32w(ctlr, Rah+i*8, 0); } - memset(ctlr->mta, 0, sizeof(ctlr->mta)); + jehanne_memset(ctlr->mta, 0, sizeof(ctlr->mta)); for(i = 0; i < 128; i++) csr32w(ctlr, Mta + i*4, 0); csr32w(ctlr, Fcal, 0x00C28001); @@ -1871,21 +1871,21 @@ i82563ctl(Ether *edev, void *buf, long n) cb = parsecmd(buf, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, i82563ctlmsg, nelem(i82563ctlmsg)); switch(ct->index){ case CMrdtr: - v = strtoul(cb->f[1], &p, 0); + v = jehanne_strtoul(cb->f[1], &p, 0); if(*p || v > 0xffff) error(Ebadarg); ctlr->rdtr = v; csr32w(ctlr, Rdtr, v); break; case CMradv: - v = strtoul(cb->f[1], &p, 0); + v = jehanne_strtoul(cb->f[1], &p, 0); if(*p || v > 0xffff) error(Ebadarg); ctlr->radv = v; @@ -1898,7 +1898,7 @@ i82563ctl(Ether *edev, void *buf, long n) csr32w(ctlr, Ctrl, csr32r(ctlr, Ctrl) | Lrst | Phyrst); break; } - free(cb); + jehanne_free(cb); poperror(); return n; @@ -2024,7 +2024,7 @@ i82563pci(void) hbafixup(p); if((type = didtype(p->did)) == -1) continue; - c = malloc(sizeof *c); + c = jehanne_malloc(sizeof *c); c->type = type; c->pcidev = p; c->rbsz = cttab[type].mtu; @@ -2040,13 +2040,13 @@ setup(Ctlr *ctlr) Pcidev *p; if((ctlr->pool = newpool()) == -1){ - print("%s: no pool\n", cname(ctlr)); + jehanne_print("%s: no pool\n", cname(ctlr)); return -1; } p = ctlr->pcidev; ctlr->nic = vmap(ctlr->port, p->mem[0].size); if(ctlr->nic == nil){ - print("%s: can't map %#P\n", cname(ctlr), ctlr->port); + jehanne_print("%s: can't map %#P\n", cname(ctlr), ctlr->port); return -1; } if(i82563reset(ctlr)){ @@ -2081,7 +2081,7 @@ pnp(Ether *edev, int type) continue; if(ethercfgmatch(edev, ctlr->pcidev, ctlr->port) == 0){ ctlr->active = 1; - memmove(ctlr->ra, edev->ea, Eaddrlen); + jehanne_memmove(ctlr->ra, edev->ea, Eaddrlen); if(setup(ctlr) == 0) break; } @@ -2093,7 +2093,7 @@ pnp(Ether *edev, int type) edev->tbdf = ctlr->pcidev->tbdf; edev->netif.mbps = 1000; edev->maxmtu = ctlr->rbsz; - memmove(edev->ea, ctlr->ra, Eaddrlen); + jehanne_memmove(edev->ea, ctlr->ra, Eaddrlen); /* * Linkage to the generic ethernet driver. diff --git a/sys/src/kern/386/ether82598.c b/sys/src/kern/386/ether82598.c index 764a7de..6a5cd3c 100644 --- a/sys/src/kern/386/ether82598.c +++ b/sys/src/kern/386/ether82598.c @@ -407,20 +407,20 @@ ifstat(Ether *e, void *a, long n, usize offset) uint32_t i, *t; c = e->ctlr; - p = s = malloc(READSTR); + p = s = jehanne_malloc(READSTR); q = p+READSTR; readstats(c); for(i = 0; istats[i]>0) - p = seprint(p, q, "%.10s %llud\n", stattab[i].name, c->stats[i]); + p = jehanne_seprint(p, q, "%.10s %llud\n", stattab[i].name, c->stats[i]); t = c->speeds; - p = seprint(p, q, "type: %s\n", cttab[c->type].name); - p = seprint(p, q, "speeds: 0:%d 100:%d 1000:%d 10000:%d\n", t[0], t[1], t[2], t[3]); - p = seprint(p, q, "rdfree: %d rdh %d rdt %d\n", c->rdfree, c->reg[Rdt], c->reg[Rdh]); - seprint(p, q, "nobufs: %ud\n", c->nobufs); + p = jehanne_seprint(p, q, "type: %s\n", cttab[c->type].name); + p = jehanne_seprint(p, q, "speeds: 0:%d 100:%d 1000:%d 10000:%d\n", t[0], t[1], t[2], t[3]); + p = jehanne_seprint(p, q, "rdfree: %d rdh %d rdt %d\n", c->rdfree, c->reg[Rdt], c->reg[Rdh]); + jehanne_seprint(p, q, "nobufs: %ud\n", c->nobufs); n = readstr(offset, a, n, s); - free(s); + jehanne_free(s); return n; } @@ -734,7 +734,7 @@ replenish(Ether *e, Ctlr *c, uint32_t rdh, int maysleep) for(int j = 0; j < Ntypes; j++){ if(e->f[j] == nil) continue; - print(" %.4ux %d\n", e->f[j]->type, qlen(e->f[j]->iq)); + jehanne_print(" %.4ux %d\n", e->f[j]->type, qlen(e->f[j]->iq)); } } sleep(p, icansleep, p); @@ -926,11 +926,11 @@ reset(Ctlr *c) int i; if(detach(c)){ - print("%s: reset timeout\n", cname(c)); + jehanne_print("%s: reset timeout\n", cname(c)); return -1; } if(eeload(c)){ - print("%s: eeprom failure\n", cname(c)); + jehanne_print("%s: eeprom failure\n", cname(c)); return -1; } p = c->ra; @@ -975,7 +975,7 @@ txinit(Ctlr *c) if(b) freeb(b); } - memset(c->tdba, 0, c->ntd*sizeof(Td)); + jehanne_memset(c->tdba, 0, c->ntd*sizeof(Td)); c->reg[Tdbal] = PCIWADDRL(c->tdba); c->reg[Tdbah] = PCIWADDRH(c->tdba); c->reg[Tdlen] = c->ntd*sizeof(Td); @@ -1008,7 +1008,7 @@ attach(Ether *e) t = c->nrd*sizeof *c->rdba+255; t += c->ntd*sizeof *c->tdba+255; t += (c->ntd+c->nrd)*sizeof(Block*); - c->alloc = malloc(t); + c->alloc = jehanne_malloc(t); qunlock(&c->alock); if(c->alloc == 0) error(Enomem); @@ -1023,7 +1023,7 @@ attach(Ether *e) b->free = nil; freeb(b); } - free(c->alloc); + jehanne_free(c->alloc); c->alloc = 0; nexterror(); } @@ -1038,11 +1038,11 @@ attach(Ether *e) rxinit(c); txinit(c); - sprint(buf, "#l%dl", e->ctlrno); + jehanne_sprint(buf, "#l%dl", e->ctlrno); kproc(buf, lproc, e); - sprint(buf, "#l%dr", e->ctlrno); + jehanne_sprint(buf, "#l%dr", e->ctlrno); kproc(buf, rproc, e); - sprint(buf, "#l%dt", e->ctlrno); + jehanne_sprint(buf, "#l%dt", e->ctlrno); kproc(buf, tproc, e); } @@ -1126,24 +1126,24 @@ scan(void) } name = cttab[type].name; if(nctlr == nelem(ctlrtab)){ - print("%s: %T: too many controllers\n", name, p->tbdf); + jehanne_print("%s: %T: too many controllers\n", name, p->tbdf); return; } io = p->mem[0].bar&~(uintmem)0xf; mem = vmap(io, p->mem[0].size); if(mem == 0){ - print("%s: %T: cant map bar\n", name, p->tbdf); + jehanne_print("%s: %T: cant map bar\n", name, p->tbdf); continue; } - c = malloc(sizeof *c); + c = jehanne_malloc(sizeof *c); c->p = p; c->port = io; c->reg = (uint32_t*)mem; c->rbsz = cttab[type].mtu; c->type = type; if(reset(c)){ - print("%s: %T: cant reset\n", name, p->tbdf); - free(c); + jehanne_print("%s: %T: cant reset\n", name, p->tbdf); + jehanne_free(c); vunmap(mem, p->mem[0].size); continue; } @@ -1178,7 +1178,7 @@ found: e->tbdf = c->p->tbdf; e->netif.mbps = 10000; e->maxmtu = c->rbsz; - memmove(e->ea, c->ra, Eaddrlen); + jehanne_memmove(e->ea, c->ra, Eaddrlen); e->netif.arg = e; e->attach = attach; e->ctl = ctl; diff --git a/sys/src/kern/386/etherbcm.c b/sys/src/kern/386/etherbcm.c index 91a46f4..2b555b1 100644 --- a/sys/src/kern/386/etherbcm.c +++ b/sys/src/kern/386/etherbcm.c @@ -18,7 +18,7 @@ #include "etherif.h" #include "../port/ethermii.h" -#define dprint(...) do{ if(debug)print(__VA_ARGS__); }while(0) +#define dprint(...) do{ if(debug)jehanne_print(__VA_ARGS__); }while(0) #define Rbsz ROUNDUP(1514+4, 4) typedef struct Ctlr Ctlr; @@ -243,19 +243,19 @@ bcmifstat(Ether *edev, void *a, long n, usize offset) Ctlr *c; c = edev->ctlr; - p = s = malloc(READSTR); + p = s = jehanne_malloc(READSTR); e = p + READSTR; - p = seprint(p, e, "nobuf %ud\n", c->nobuf); - p = seprint(p, e, "partial %ud\n", c->partial); - p = seprint(p, e, "rxerr %ud\n", c->rxerr); - p = seprint(p, e, "qfull %ud\n", c->qfull); - p = seprint(p, e, "dmaerr %ud\n", c->dmaerr); - p = seprint(p, e, "type: %s\n", cname(c)); + p = jehanne_seprint(p, e, "nobuf %ud\n", c->nobuf); + p = jehanne_seprint(p, e, "partial %ud\n", c->partial); + p = jehanne_seprint(p, e, "rxerr %ud\n", c->rxerr); + p = jehanne_seprint(p, e, "qfull %ud\n", c->qfull); + p = jehanne_seprint(p, e, "dmaerr %ud\n", c->dmaerr); + p = jehanne_seprint(p, e, "type: %s\n", cname(c)); USED(p); n = readstr(offset, a, n, s); - free(s); + jehanne_free(s); return n; } @@ -282,7 +282,7 @@ miiwait(Ctlr *ctlr) } microdelay(5); } - print("#l%d: bcm: miiwait: timeout\n", ctlr->ether->ctlrno); + jehanne_print("#l%d: bcm: miiwait: timeout\n", ctlr->ether->ctlrno); return ~0; } @@ -299,7 +299,7 @@ miir(Ctlr *ctlr, int r) if(v == ~0) return -1; if(v & Phyrdfail){ - print("#l%d: bcm: miir: fail\n", ctlr->ether->ctlrno); + jehanne_print("#l%d: bcm: miir: fail\n", ctlr->ether->ctlrno); return -1; } return v & 0xffff; @@ -401,7 +401,7 @@ replenish(Ctlr *ctlr) return -1; } next = ctlr->recvprod + ctlr->recvprodi * 8; - memset(next, 0, 32); + jehanne_memset(next, 0, 32); next[0] = PCIWADDRH(bp->rp); next[1] = PCIWADDRL(bp->rp); next[2] = Rbsz; @@ -495,7 +495,7 @@ bcmerror(Ether *edev) ctlr = edev->ctlr; if(csr32(ctlr, FlowAttention)) { if(csr32(ctlr, FlowAttention) & 0xf8ff8080) - print("bcm: fatal error %#.8ux", csr32(ctlr, FlowAttention)); + jehanne_print("bcm: fatal error %#.8ux", csr32(ctlr, FlowAttention)); csr32(ctlr, FlowAttention) = 0; } csr32(ctlr, MACEventStatus) = 0; /* worth ignoring */ @@ -507,7 +507,7 @@ bcmerror(Ether *edev) } if(csr32(ctlr, RISCState)) { if(csr32(ctlr, RISCState) & 0x78000403) - print("bcm: RISC halted %#.8ux", csr32(ctlr, RISCState)); + jehanne_print("bcm: RISC halted %#.8ux", csr32(ctlr, RISCState)); csr32(ctlr, RISCState) = 0; } } @@ -586,7 +586,7 @@ bcminit(Ether *edev) csr32(ctlr, MiscHostCtl) |= MaskPCIInt | ClearIntA | WordSwap | IndirAccessEn; csr32(ctlr, SwArbitration) |= SwArbitSet1; if(bcmµwait(ctlr, 2000, SwArbitration, SwArbitWon1, SwArbitWon1) == -1){ - print("bcm: arbiter failed to respond\n"); + jehanne_print("bcm: arbiter failed to respond\n"); return -1; } csr32(ctlr, MemArbiterMode) |= Enable; @@ -607,7 +607,7 @@ bcminit(Ether *edev) if(mem32r(ctlr, Fwmbox) == ~Fwmagic) break; if(i == 20*10000 /* microseconds */){ - print("bcm: fw failed to respond %#.8ux\n", mem32r(ctlr, Fwmbox)); + jehanne_print("bcm: fw failed to respond %#.8ux\n", mem32r(ctlr, Fwmbox)); break; //return -1; } microdelay(100); @@ -617,7 +617,7 @@ bcminit(Ether *edev) * i can find. nor to i have a datasheet that recommends this. - quanstro * csr32(ctlr, Pcitlplpl) |= 1<<25 | 1<<29; */ - memset(ctlr->status, 0, 20); + jehanne_memset(ctlr->status, 0, 20); csr32(ctlr, Dmarwctl) = (csr32(ctlr, Dmarwctl) & DMAWaterMask) | DMAWaterValue; csr32(ctlr, ModeControl) |= HostSendBDs | HostStackUp | InterruptOnMAC; csr32(ctlr, MiscConf) = (csr32(ctlr, MiscConf) & TimerMask) | TimerValue; @@ -626,13 +626,13 @@ bcminit(Ether *edev) csr32(ctlr, LowWaterMax) = (csr32(ctlr, LowWaterMax) & LowWaterMaxMask) | LowWaterMaxValue; csr32(ctlr, BufferManMode) |= Enable | Attn; if(bcmµwait(ctlr, 2000, BufferManMode, Enable, Enable) == -1){ - print("bcm: failed to enable buffers\n"); + jehanne_print("bcm: failed to enable buffers\n"); return -1; } csr32(ctlr, FTQReset) = ~0; csr32(ctlr, FTQReset) = 0; if(bcmµwait(ctlr, 2000, FTQReset, ~0, 0) == -1){ - print("bcm: failed to bring ftq out of reset\n"); + jehanne_print("bcm: failed to bring ftq out of reset\n"); return -1; } csr32(ctlr, RxBDHostAddr) = PCIWADDRH(ctlr->recvprod); @@ -673,7 +673,7 @@ bcminit(Ether *edev) csr32(ctlr, SendInitiatorConf) |= SendStats; csr32(ctlr, HostCoalMode) = 0; if(bcmµwait(ctlr, 2000, HostCoalMode, ~0, 0) == -1){ - print("bcm: failed to unset coalescing\n"); + jehanne_print("bcm: failed to unset coalescing\n"); return -1; } csr32(ctlr, HostCoalRxTicks) = 150; @@ -719,7 +719,7 @@ bcminit(Ether *edev) if((miir(ctlr, Bmcr) & BmcrR) == 0) break; if(i == 10000 /* microseconds */){ - print("bcm: phy reset failure\n"); + jehanne_print("bcm: phy reset failure\n"); return -1; } microdelay(100); @@ -797,25 +797,25 @@ bcmpci(void) continue; pcisetbme(p); pcisetpms(p, 0); - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil) continue; ctlr->type = type; ctlr->port = p->mem[0].bar & ~(uintmem)0xf; mem = vmap(ctlr->port, p->mem[0].size); if(mem == nil) { - print("bcm: can't map %#p\n", (uint64_t)ctlr->port); - free(ctlr); + jehanne_print("bcm: can't map %#p\n", (uint64_t)ctlr->port); + jehanne_free(ctlr); continue; } ctlr->pdev = p; ctlr->nic = mem; - ctlr->status = mallocalign(20, 16, 0, 0); - ctlr->recvprod = mallocalign(32 * RxProdRingLen, 16, 0, 0); - ctlr->recvret = mallocalign(32 * RxRetRingLen, 16, 0, 0); - ctlr->sendr = mallocalign(16 * SendRingLen, 16, 0, 0); - ctlr->sends = malloc(sizeof *ctlr->sends * SendRingLen); - ctlr->rxs = malloc(sizeof *ctlr->sends * SendRingLen); + ctlr->status = jehanne_mallocalign(20, 16, 0, 0); + ctlr->recvprod = jehanne_mallocalign(32 * RxProdRingLen, 16, 0, 0); + ctlr->recvret = jehanne_mallocalign(32 * RxRetRingLen, 16, 0, 0); + ctlr->sendr = jehanne_mallocalign(16 * SendRingLen, 16, 0, 0); + ctlr->sends = jehanne_malloc(sizeof *ctlr->sends * SendRingLen); + ctlr->rxs = jehanne_malloc(sizeof *ctlr->sends * SendRingLen); *xx = ctlr; xx = &ctlr->next; } diff --git a/sys/src/kern/386/etherigbe.c b/sys/src/kern/386/etherigbe.c index 87da557..5b158e9 100644 --- a/sys/src/kern/386/etherigbe.c +++ b/sys/src/kern/386/etherigbe.c @@ -617,7 +617,7 @@ igbeifstat(Ether* edev, void* a, long n, uint32_t offset) continue; ctlr->statistics[i] = tuvl; ctlr->statistics[i+1] = tuvl>>32; - l += snprint(p+l, READSTR-l, "%s: %llud %llud\n", + l += jehanne_snprint(p+l, READSTR-l, "%s: %llud %llud\n", s, tuvl, ruvl); i++; break; @@ -626,43 +626,43 @@ igbeifstat(Ether* edev, void* a, long n, uint32_t offset) ctlr->statistics[i] += r; if(ctlr->statistics[i] == 0) continue; - l += snprint(p+l, READSTR-l, "%s: %ud %ud\n", + l += jehanne_snprint(p+l, READSTR-l, "%s: %ud %ud\n", s, ctlr->statistics[i], r); break; } } - l += snprint(p+l, READSTR-l, "lintr: %ud %ud\n", + l += jehanne_snprint(p+l, READSTR-l, "lintr: %ud %ud\n", ctlr->lintr, ctlr->lsleep); - l += snprint(p+l, READSTR-l, "rintr: %ud %ud\n", + l += jehanne_snprint(p+l, READSTR-l, "rintr: %ud %ud\n", ctlr->rintr, ctlr->rsleep); - l += snprint(p+l, READSTR-l, "tintr: %ud %ud\n", + l += jehanne_snprint(p+l, READSTR-l, "tintr: %ud %ud\n", ctlr->tintr, ctlr->txdw); - l += snprint(p+l, READSTR-l, "ixcs: %ud %ud %ud\n", + l += jehanne_snprint(p+l, READSTR-l, "ixcs: %ud %ud %ud\n", ctlr->ixsm, ctlr->ipcs, ctlr->tcpcs); - l += snprint(p+l, READSTR-l, "rdtr: %ud\n", ctlr->rdtr); - l += snprint(p+l, READSTR-l, "Ctrlext: %08x\n", csr32r(ctlr, Ctrlext)); + l += jehanne_snprint(p+l, READSTR-l, "rdtr: %ud\n", ctlr->rdtr); + l += jehanne_snprint(p+l, READSTR-l, "Ctrlext: %08x\n", csr32r(ctlr, Ctrlext)); - l += snprint(p+l, READSTR-l, "eeprom:"); + l += jehanne_snprint(p+l, READSTR-l, "eeprom:"); for(i = 0; i < 0x40; i++){ if(i && ((i & 0x07) == 0)) - l += snprint(p+l, READSTR-l, "\n "); - l += snprint(p+l, READSTR-l, " %4.4uX", ctlr->eeprom[i]); + l += jehanne_snprint(p+l, READSTR-l, "\n "); + l += jehanne_snprint(p+l, READSTR-l, " %4.4uX", ctlr->eeprom[i]); } - l += snprint(p+l, READSTR-l, "\n"); + l += jehanne_snprint(p+l, READSTR-l, "\n"); if(ctlr->mii != nil && ctlr->mii->curphy != nil){ - l += snprint(p+l, READSTR-l, "phy: "); + l += jehanne_snprint(p+l, READSTR-l, "phy: "); for(i = 0; i < NMiiPhyr; i++){ if(i && ((i & 0x07) == 0)) - l += snprint(p+l, READSTR-l, "\n "); + l += jehanne_snprint(p+l, READSTR-l, "\n "); r = miimir(ctlr->mii, i); - l += snprint(p+l, READSTR-l, " %4.4uX", r); + l += jehanne_snprint(p+l, READSTR-l, " %4.4uX", r); } - snprint(p+l, READSTR-l, "\n"); + jehanne_snprint(p+l, READSTR-l, "\n"); } n = readstr(offset, a, n, p); - free(p); + jehanne_free(p); qunlock(&ctlr->slock); return n; @@ -690,21 +690,21 @@ igbectl(Ether* edev, void* buf, long n) cb = parsecmd(buf, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, igbectlmsg, nelem(igbectlmsg)); switch(ct->index){ case CMrdtr: - v = strtol(cb->f[1], &p, 0); + v = jehanne_strtol(cb->f[1], &p, 0); if(v < 0 || p == cb->f[1] || v > 0xFFFF) error(Ebadarg); ctlr->rdtr = v;; csr32w(ctlr, Rdtr, Fpd|v); break; } - free(cb); + jehanne_free(cb); poperror(); return n; @@ -905,7 +905,7 @@ igbetxinit(Ctlr* ctlr) ctlr->tb[i] = nil; freeb(bp); } - memset(&ctlr->tdba[i], 0, sizeof(Td)); + jehanne_memset(&ctlr->tdba[i], 0, sizeof(Td)); } ctlr->tdfree = ctlr->ntd; @@ -961,7 +961,7 @@ igbetransmit(Ether* edev) ctlr->tb[tdh] = nil; freeb(bp); } - memset(&ctlr->tdba[tdh], 0, sizeof(Td)); + jehanne_memset(&ctlr->tdba[tdh], 0, sizeof(Td)); tdh = NEXT(tdh, ctlr->ntd); } ctlr->tdh = tdh; @@ -1149,7 +1149,7 @@ igberproc(void* arg) ctlr->rb[rdh] = nil; } - memset(rd, 0, sizeof(Rd)); + jehanne_memset(rd, 0, sizeof(Rd)); coherence(); ctlr->rdfree--; rdh = NEXT(rdh, ctlr->nrd); @@ -1177,38 +1177,38 @@ igbeattach(Ether* edev) ctlr->nrd = ROUND(Nrd, 8); ctlr->ntd = ROUND(Ntd, 8); - ctlr->alloc = malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 127); + ctlr->alloc = jehanne_malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 127); if(ctlr->alloc == nil){ - print("igbe: can't allocate ctlr->alloc\n"); + jehanne_print("igbe: can't allocate ctlr->alloc\n"); qunlock(&ctlr->alock); return; } ctlr->rdba = (Rd*)ROUNDUP((uintptr_t)ctlr->alloc, 128); ctlr->tdba = (Td*)(ctlr->rdba+ctlr->nrd); - ctlr->rb = malloc(ctlr->nrd*sizeof(Block*)); - ctlr->tb = malloc(ctlr->ntd*sizeof(Block*)); + ctlr->rb = jehanne_malloc(ctlr->nrd*sizeof(Block*)); + ctlr->tb = jehanne_malloc(ctlr->ntd*sizeof(Block*)); if (ctlr->rb == nil || ctlr->tb == nil) { - print("igbe: can't allocate ctlr->rb or ctlr->tb\n"); + jehanne_print("igbe: can't allocate ctlr->rb or ctlr->tb\n"); qunlock(&ctlr->alock); return; } if(waserror()){ - free(ctlr->tb); + jehanne_free(ctlr->tb); ctlr->tb = nil; - free(ctlr->rb); + jehanne_free(ctlr->rb); ctlr->rb = nil; - free(ctlr->alloc); + jehanne_free(ctlr->alloc); ctlr->alloc = nil; qunlock(&ctlr->alock); nexterror(); } - snprint(name, KNAMELEN, "#l%dlproc", edev->ctlrno); + jehanne_snprint(name, KNAMELEN, "#l%dlproc", edev->ctlrno); kproc(name, igbelproc, edev); - snprint(name, KNAMELEN, "#l%drproc", edev->ctlrno); + jehanne_snprint(name, KNAMELEN, "#l%drproc", edev->ctlrno); kproc(name, igberproc, edev); igbetxinit(ctlr); @@ -1405,7 +1405,7 @@ igbemii(Ctlr* ctlr) r = csr32r(ctlr, Status); if(r & Tbimode) return -1; - if((ctlr->mii = malloc(sizeof(Mii))) == nil) + if((ctlr->mii = jehanne_malloc(sizeof(Mii))) == nil) return -1; ctlr->mii->ctlr = ctlr; @@ -1425,7 +1425,7 @@ igbemii(Ctlr* ctlr) */ r = csr32r(ctlr, Ctrlext); if(!(r & Mdro)) { - print("igbe: 82543gc Mdro not set\n"); + jehanne_print("igbe: 82543gc Mdro not set\n"); return -1; } csr32w(ctlr, Ctrlext, r); @@ -1463,18 +1463,18 @@ igbemii(Ctlr* ctlr) ctlr->mii->miw = igbemiimiw; break; default: - free(ctlr->mii); + jehanne_free(ctlr->mii); ctlr->mii = nil; return -1; } if(mii(ctlr->mii, ~0) == 0 || (phy = ctlr->mii->curphy) == nil){ - free(ctlr->mii); + jehanne_free(ctlr->mii); ctlr->mii = nil; return -1; } USED(phy); - // print("oui %X phyno %d\n", phy->oui, phy->phyno); + // jehanne_print("oui %X phyno %d\n", phy->oui, phy->phyno); /* * 8254X-specific PHY registers not in 802.3: @@ -1536,7 +1536,7 @@ at93c46io(Ctlr* ctlr, char* op, int data) case ' ': continue; case ':': /* start of loop */ - loop = strtol(p+1, &lp, 0)-1; + loop = jehanne_strtol(p+1, &lp, 0)-1; lp--; if(p == lp) loop = 7; @@ -1636,7 +1636,7 @@ at93c46r(Ctlr* ctlr) microdelay(5); } if(!(eecd & Agnt)){ - print("igbe: not granted EEPROM access\n"); + jehanne_print("igbe: not granted EEPROM access\n"); goto release; } break; @@ -1654,7 +1654,7 @@ at93c46r(Ctlr* ctlr) at93c46io(ctlr, "Ss", 0); } if(i == 1000){ - print("igbe: SPI EEPROM not ready\n"); + jehanne_print("igbe: SPI EEPROM not ready\n"); goto release; } @@ -1664,9 +1664,9 @@ at93c46r(Ctlr* ctlr) bits = 16; else bits = 8; - snprint(rop, sizeof(rop), "H :%dHDCc;", bits); + jehanne_snprint(rop, sizeof(rop), "H :%dHDCc;", bits); if(at93c46io(ctlr, rop, 0) != 0){ - print("igbe: can't set EEPROM address 0x00\n"); + jehanne_print("igbe: can't set EEPROM address 0x00\n"); goto release; } @@ -1680,7 +1680,7 @@ at93c46r(Ctlr* ctlr) bits = 8; else bits = 6; - snprint(rop, sizeof(rop), "S :%dDCc;", bits+3); + jehanne_snprint(rop, sizeof(rop), "S :%dDCc;", bits+3); for(addr = 0; addr < 0x40; addr++){ /* @@ -1690,7 +1690,7 @@ at93c46r(Ctlr* ctlr) * for protocol details. */ if(at93c46io(ctlr, rop, (0x06<mta, 0, sizeof(ctlr->mta)); + jehanne_memset(ctlr->mta, 0, sizeof(ctlr->mta)); for(i = 0; i < 128; i++) csr32w(ctlr, Mta+i*4, 0); @@ -1945,13 +1945,13 @@ igbepci(void) mem = vmap(p->mem[0].bar & ~0x0F, p->mem[0].size); if(mem == nil){ - print("igbe: can't map %8.8luX\n", p->mem[0].bar); + jehanne_print("igbe: can't map %8.8luX\n", p->mem[0].bar); continue; } cls = pcicfgr8(p, PciCLS); switch(cls){ default: - print("igbe: p->cls %#ux, setting to 0x10\n", p->cls); + jehanne_print("igbe: p->cls %#ux, setting to 0x10\n", p->cls); p->cls = 0x10; pcicfgw8(p, PciCLS, p->cls); break; @@ -1959,9 +1959,9 @@ igbepci(void) case 0x10: break; } - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil){ - print("igbe: can't allocate memory\n"); + jehanne_print("igbe: can't allocate memory\n"); continue; } ctlr->port = p->mem[0].bar & ~0x0F; @@ -1971,7 +1971,7 @@ igbepci(void) ctlr->nic = mem; if(igbereset(ctlr)){ - free(ctlr); + jehanne_free(ctlr); vunmap(mem, p->mem[0].size); continue; } @@ -2013,7 +2013,7 @@ igbepnp(Ether* edev) edev->irq = ctlr->pcidev->intl; edev->tbdf = ctlr->pcidev->tbdf; edev->netif.mbps = 1000; - memmove(edev->ea, ctlr->ra, Eaddrlen); + jehanne_memmove(edev->ea, ctlr->ra, Eaddrlen); /* * Linkage to the generic ethernet driver. diff --git a/sys/src/kern/386/etherm10g.c b/sys/src/kern/386/etherm10g.c index 39e4288..0c9b831 100644 --- a/sys/src/kern/386/etherm10g.c +++ b/sys/src/kern/386/etherm10g.c @@ -23,9 +23,9 @@ #define MiB 1048576u /* Mebi 0x0000000000100000 */ #endif /* KiB */ -#define dprint(...) if(debug) print(__VA_ARGS__) +#define dprint(...) if(debug) jehanne_print(__VA_ARGS__) #define pcicapdbg(...) -#define malign(n) mallocalign((n), 4*KiB, 0, 0) +#define malign(n) jehanne_mallocalign((n), 4*KiB, 0, 0) #include "etherm10g2k.i" #include "etherm10g4k.i" @@ -267,11 +267,11 @@ pciecap(Pcidev *p, int cap) off = 0x100; while(((i = pcicfgr32(p, off))&0xffff) != cap){ off = i >> 20; - print("pciecap offset = %ud\n", off); + jehanne_print("pciecap offset = %ud\n", off); if(off < 0x100 || off >= 4*KiB - 1) return 0; } - print("pciecap found = %ud\n", off); + jehanne_print("pciecap found = %ud\n", off); return off; } @@ -306,33 +306,33 @@ whichfw(Pcidev *p) /* check AERC register. we need it on. */ off = pciecap(p, PcieAERC); - print("%d offset\n", off); + jehanne_print("%d offset\n", off); cap = 0; if(off != 0){ off += AercCCR; cap = pcicfgr32(p, off); - print("%ud cap\n", cap); + jehanne_print("%ud cap\n", cap); } ecrc = (cap>>4) & 0xf; /* if we don't like the aerc, kick it here. */ - print("m10g %d lanes; ecrc=%d; ", lanes, ecrc); + jehanne_print("m10g %d lanes; ecrc=%d; ", lanes, ecrc); if(s = getconf("myriforce")){ - i = atoi(s); + i = jehanne_atoi(s); if(i != 4*KiB || i != 2*KiB) i = 2*KiB; - print("fw=%d [forced]\n", i); + jehanne_print("fw=%d [forced]\n", i); return i; } if(lanes <= 4){ - print("fw = 4096 [lanes]\n"); + jehanne_print("fw = 4096 [lanes]\n"); return 4*KiB; } if(ecrc & 10){ - print("fw = 4096 [ecrc set]\n"); + jehanne_print("fw = 4096 [ecrc set]\n"); return 4*KiB; } - print("fw = 4096 [default]\n"); + jehanne_print("fw = 4096 [default]\n"); return 4*KiB; } @@ -346,16 +346,16 @@ parseeprom(Ctlr *c) s = c->eprom; bits = 3; for(i = 0; s[i] && i < Epromsz; i++){ - l = strlen(s+i); + l = jehanne_strlen(s+i); dprint("\t%s\n", s+i); - if(strncmp(s+i, "MAC=", 4) == 0 && l == 4+12+5){ + if(jehanne_strncmp(s+i, "MAC=", 4) == 0 && l == 4+12+5){ bits ^= 1; j = i + 4; for(k = 0; k < 6; k++) - c->ra[k] = strtoul(s+j+3*k, 0, 16); - }else if(strncmp(s+i, "SN=", 3) == 0){ + c->ra[k] = jehanne_strtoul(s+j+3*k, 0, 16); + }else if(jehanne_strncmp(s+i, "SN=", 3) == 0){ bits ^= 2; - c->serial = atoi(s+i+3); + c->serial = jehanne_atoi(s+i+3); } i += l; } @@ -439,7 +439,7 @@ cmd(Ctlr *c, int type, uint64_t data) qlock(&c->cmdl); cmd = c->cmd; cmd->i[1] = Noconf; - memset(buf, 0, sizeof buf); + jehanne_memset(buf, 0, sizeof buf); buf[0] = type; buf[1] = data; buf[2] = data >> 32; @@ -447,7 +447,7 @@ cmd(Ctlr *c, int type, uint64_t data) buf[5] = c->cprt; prepcmd(buf, 6); coherence(); - memmove(c->ram + Cmdoff, buf, sizeof buf); + jehanne_memmove(c->ram + Cmdoff, buf, sizeof buf); if(waserror()) nexterror(); @@ -478,7 +478,7 @@ maccmd(Ctlr *c, int type, uint8_t *m) qlock(&c->cmdl); cmd = c->cmd; cmd->i[1] = Noconf; - memset(buf, 0, sizeof buf); + jehanne_memset(buf, 0, sizeof buf); buf[0] = type; buf[1] = m[0]<<24 | m[1]<<16 | m[2]<<8 | m[3]; buf[2] = m[4]<< 8 | m[5]; @@ -486,7 +486,7 @@ maccmd(Ctlr *c, int type, uint8_t *m) buf[5] = c->cprt; prepcmd(buf, 6); coherence(); - memmove(c->ram + Cmdoff, buf, sizeof buf); + jehanne_memmove(c->ram + Cmdoff, buf, sizeof buf); if(waserror()) nexterror(); @@ -519,8 +519,8 @@ dmatestcmd(Ctlr *c, int type, uint64_t addr, int len) { uint32_t buf[16], i; - memset(buf, 0, sizeof buf); - memset(c->cmd, Noconf, sizeof *c->cmd); + jehanne_memset(buf, 0, sizeof buf); + jehanne_memset(c->cmd, Noconf, sizeof *c->cmd); buf[0] = Cdmatest; buf[1] = addr; buf[2] = addr >> 32; @@ -529,7 +529,7 @@ dmatestcmd(Ctlr *c, int type, uint64_t addr, int len) buf[5] = c->cprt; prepcmd(buf, 6); coherence(); - memmove(c->ram + Cmdoff, buf, sizeof buf); + jehanne_memmove(c->ram + Cmdoff, buf, sizeof buf); if(waserror()) nexterror(); @@ -552,7 +552,7 @@ rdmacmd(Ctlr *c, int on) { uint32_t buf[16], i; - memset(buf, 0, sizeof buf); + jehanne_memset(buf, 0, sizeof buf); c->cmd->i[0] = 0; coherence(); buf[0] = c->cprt >> 32; @@ -562,7 +562,7 @@ rdmacmd(Ctlr *c, int on) buf[4] = c->cprt; buf[5] = on; prepcmd(buf, 6); - memmove(c->ram + Rdmaoff, buf, sizeof buf); + jehanne_memmove(c->ram + Rdmaoff, buf, sizeof buf); if(waserror()) nexterror(); @@ -610,7 +610,7 @@ bootfw(Ctlr *c) dprint("bootfw %d bytes ... ", sz); cmd = c->cmd; - memset(buf, 0, sizeof buf); + jehanne_memset(buf, 0, sizeof buf); c->cmd->i[0] = 0; coherence(); buf[0] = c->cprt >> 32; /* upper dma target address */ @@ -622,7 +622,7 @@ bootfw(Ctlr *c) buf[6] = 0; prepcmd(buf, 7); coherence(); - memmove(c->ram + Fwsubmt, buf, sizeof buf); + jehanne_memmove(c->ram + Fwsubmt, buf, sizeof buf); for(i = 0; i < 20; i++){ if(cmd->i[0] == Noconf) @@ -631,7 +631,7 @@ bootfw(Ctlr *c) } dprint("[%ux %ux]", gbit32(cmd->c), gbit32(cmd->c+4)); if(i == 20){ - print("m10g: cannot load fw\n"); + jehanne_print("m10g: cannot load fw\n"); return -1; } dprint("\n"); @@ -700,7 +700,7 @@ chkfw(Ctlr *c) off = gbit32(c->ram+0x3c); dprint("firmware %llux\n", (uint64_t)off); if((off&3) || off + sizeof *h > c->ramsz){ - print("!m10g: bad firmware %llux\n", (uint64_t)off); + jehanne_print("!m10g: bad firmware %llux\n", (uint64_t)off); return -1; } h = (Fwhdr*)(c->ram + off); @@ -709,7 +709,7 @@ chkfw(Ctlr *c) dprint("\t" "vers %s\n", h->version); dprint("\t" "ramsz %ux\n", gbit32(h->ramsz)); if(type != Teth){ - print("!m10g: bad card type %s\n", fwtype(type)); + jehanne_print("!m10g: bad card type %s\n", fwtype(type)); return -1; } @@ -722,7 +722,7 @@ reset(Ether *e, Ctlr *c) uint32_t i, sz; if(waserror()){ - print("m10g: reset error\n"); + jehanne_print("m10g: reset error\n"); nexterror(); return -1; } @@ -743,12 +743,12 @@ reset(Ether *e, Ctlr *c) rdmacmd(c, 1); sz = c->tx.segsz; i = dmatestcmd(c, DMAread, c->done.busaddr, sz); - print("\t" "read: %ud MB/s\n", ((i>>16)*sz*2)/(i&0xffff)); + jehanne_print("\t" "read: %ud MB/s\n", ((i>>16)*sz*2)/(i&0xffff)); i = dmatestcmd(c, DMAwrite, c->done.busaddr, sz); - print("\t" "write: %ud MB/s\n", ((i>>16)*sz*2)/(i&0xffff)); + jehanne_print("\t" "write: %ud MB/s\n", ((i>>16)*sz*2)/(i&0xffff)); i = dmatestcmd(c, DMAwrite|DMAread, c->done.busaddr, sz); - print("\t" "r/w: %ud MB/s\n", ((i>>16)*sz*2*2)/(i&0xffff)); - memset(c->done.entry, 0, c->done.n * sizeof *c->done.entry); + jehanne_print("\t" "r/w: %ud MB/s\n", ((i>>16)*sz*2*2)/(i&0xffff)); + jehanne_memset(c->done.entry, 0, c->done.n * sizeof *c->done.entry); maccmd(c, CSmac, c->ra); // cmd(c, Cnopromisc, 0); @@ -765,13 +765,13 @@ static void ctlrfree(Ctlr *c) { /* free up all the Block*s, too */ - free(c->tx.host); - free(c->sm.host); - free(c->bg.host); - free(c->cmd); - free(c->done.entry); - free(c->stats); - free(c); + jehanne_free(c->tx.host); + jehanne_free(c->sm.host); + jehanne_free(c->bg.host); + jehanne_free(c->cmd); + jehanne_free(c->done.entry); + jehanne_free(c->stats); + jehanne_free(c); } static int @@ -790,7 +790,7 @@ setmem(Pcidev *p, Ctlr *c) raddr = p->mem[0].bar & ~0x0F; mem = vmap(raddr, p->mem[0].size); if(mem == nil){ - print("m10g: can't map %8.8lux\n", p->mem[0].bar); + jehanne_print("m10g: can't map %8.8lux\n", p->mem[0].bar); return -1; } dprint("%llux <- vmap(mem[0].size = %ux)\n", raddr, p->mem[0].size); @@ -804,14 +804,14 @@ setmem(Pcidev *p, Ctlr *c) d->m = d->n - 1; i = d->n * sizeof *d->entry; d->entry = malign(i); - memset(d->entry, 0, i); + jehanne_memset(d->entry, 0, i); d->busaddr = PCIWADDR64(d->entry); c->stats = malign(sizeof *c->stats); - memset(c->stats, 0, sizeof *c->stats); + jehanne_memset(c->stats, 0, sizeof *c->stats); c->statsprt = PCIWADDR64(c->stats); - memmove(c->eprom, c->ram + c->ramsz - Epromsz, Epromsz-2); + jehanne_memmove(c->eprom, c->ram + c->ramsz - Epromsz, Epromsz-2); return setpcie(p) || parseeprom(c); } @@ -882,7 +882,7 @@ replenish(Rx *rx) p = rx->pool; if(p->n < 8) return; - memset(buf, 0, sizeof buf); + jehanne_memset(buf, 0, sizeof buf); e = (rx->i - rx->cnt) & ~7; e += rx->n; while(p->n >= 8 && e){ @@ -894,13 +894,13 @@ replenish(Rx *rx) rx->host[idx+i] = b; assert(b); } - memmove(rx->lanai + 2*idx, buf, sizeof buf); + jehanne_memmove(rx->lanai + 2*idx, buf, sizeof buf); coherence(); rx->cnt += 8; e -= 8; } if(e && p->n > 7+1) - print("should panic? pool->n = %d\n", p->n); + jehanne_print("should panic? pool->n = %d\n", p->n); } /* @@ -930,7 +930,7 @@ emalign(int sz) v = malign(sz); if(v == nil) error(Enomem); - memset(v, 0, sz); + jehanne_memset(v, 0, sz); return v; } @@ -1136,7 +1136,7 @@ submittx(Tx *tx, int n) l = tx->lanai; h = tx->host; for(i = n-1; i >= 0; i--) - memmove(l+(i + i0 & m), h+(i + i0 & m), sizeof *h); + jehanne_memmove(l+(i + i0 & m), h+(i + i0 & m), sizeof *h); tx->i += n; // coherence(); } @@ -1305,9 +1305,9 @@ m10gattach(Ether *e) open0(e, c); if(c->kprocs == 0){ c->kprocs++; - snprint(name, sizeof name, "#l%drxproc", e->ctlrno); + jehanne_snprint(name, sizeof name, "#l%drxproc", e->ctlrno); kproc(name, m10rx, e); - snprint(name, sizeof name, "#l%dtxproc", e->ctlrno); + jehanne_snprint(name, sizeof name, "#l%dtxproc", e->ctlrno); kproc(name, txproc, e); } c->state = Runed; @@ -1346,13 +1346,13 @@ m10gifstat(Ether *e, void *v, long n, uint32_t off) c = e->ctlr; lim = 2*READSTR-1; - p = malloc(lim+1); + p = jehanne_malloc(lim+1); l = 0; /* no point in locking this because this is done via dma. */ - memmove(&s, c->stats, sizeof s); + jehanne_memmove(&s, c->stats, sizeof s); // l += - snprint(p+l, lim, + jehanne_snprint(p+l, lim, "txcnt = %ud\n" "linkstat = %ud\n" "dlink = %ud\n" "derror = %ud\n" "drunt = %ud\n" "doverrun = %ud\n" "dnosm = %ud\n" "dnobg = %ud\n" "nrdma = %ud\n" @@ -1376,7 +1376,7 @@ m10gifstat(Ether *e, void *v, long n, uint32_t off) c->tx.segsz, gbit32((uint8_t*)c->coal)); n = readstr(off, v, n, p); - free(p); + jehanne_free(p); return n; } @@ -1388,21 +1388,21 @@ m10gifstat(Ether *e, void *v, long n, uint32_t off) // // if(e == 0) // return; -// buf = malloc(n=250); +// buf = jehanne_malloc(n=250); // if(buf == 0) // return; // -// snprint(buf, n, "oq\n"); +// jehanne_snprint(buf, n, "oq\n"); // qsummary(e->netif.oq, buf+3, n-3-1); // iprint("%s", buf); // // if(e->f) for(i = 0; e->f[i]; i++){ -// j = snprint(buf, n, "f%d %d\n", i, e->f[i]->type); +// j = jehanne_snprint(buf, n, "f%d %d\n", i, e->f[i]->type); // qsummary(e->f[i]->in, buf+j, n-j-1); -// print("%s", buf); +// jehanne_print("%s", buf); // } // -// free(buf); +// jehanne_free(buf); //} static void @@ -1453,16 +1453,16 @@ m10gctl(Ether *e, void *v, long n) c = parsecmd(v, n); if(waserror()){ - free(c); + jehanne_free(c); nexterror(); } t = lookupcmd(c, ctab, nelem(ctab)); switch(t->index){ case CMdebug: - debug = (strcmp(c->f[1], "on") == 0); + debug = (jehanne_strcmp(c->f[1], "on") == 0); break; case CMcoal: - i = atoi(c->f[1]); + i = jehanne_atoi(c->f[1]); if(i < 0 || i > 1000) error(Ebadarg); *((Ctlr*)e->ctlr)->coal = pbit32(i); @@ -1482,7 +1482,7 @@ m10gctl(Ether *e, void *v, long n) default: error(Ebadarg); } - free(c); + jehanne_free(c); poperror(); return n; } @@ -1521,7 +1521,7 @@ m10gmulticast(void *v, uint8_t *ea, int on) dprint("m10gmulticast\n"); e = v; if((i = maccmd(e->ctlr, mcctab[on], ea)) != 0) - print("m10g: can't %s %E: %d\n", mcntab[on], ea, i); + jehanne_print("m10g: can't %s %E: %d\n", mcntab[on], ea, i); } static void @@ -1532,10 +1532,10 @@ m10gpci(void) t = 0; for(p = 0; p = pcimatch(p, 0x14c1, 0x0008); ){ - c = malloc(sizeof *c); + c = jehanne_malloc(sizeof *c); if(c == nil) continue; - memset(c, 0, sizeof *c); + jehanne_memset(c, 0, sizeof *c); c->pcidev = p; c->id = p->did<<16 | p->vid; // c->boot = pcicap(p, PciCapVND); @@ -1544,8 +1544,8 @@ m10gpci(void) // } pcisetbme(p); if(setmem(p, c) == -1){ - print("m10g failed\n"); - free(c); + jehanne_print("m10g failed\n"); + jehanne_free(c); /* cleanup */ continue; } @@ -1579,7 +1579,7 @@ m10gpnp(Ether *e) e->irq = c->pcidev->intl; e->tbdf = c->pcidev->tbdf; e->netif.mbps = 10000; - memmove(e->ea, c->ra, Eaddrlen); + jehanne_memmove(e->ea, c->ra, Eaddrlen); e->attach = m10gattach; e->detach = m10gshutdown; diff --git a/sys/src/kern/386/ethermii.c b/sys/src/kern/386/ethermii.c index 90b219b..2426bd9 100644 --- a/sys/src/kern/386/ethermii.c +++ b/sys/src/kern/386/ethermii.c @@ -40,7 +40,7 @@ mii(Mii* mii, int mask) if(oui == 0xFFFFF || oui == 0) continue; - if((miiphy = malloc(sizeof(MiiPhy))) == nil) + if((miiphy = jehanne_malloc(sizeof(MiiPhy))) == nil) continue; miiphy->mii = mii; @@ -175,13 +175,13 @@ miistatus(Mii* mii) */ bmsr = mii->mir(mii, phyno, Bmsr); if(!(bmsr & (BmsrAnc|BmsrAna))) { - // print("miistatus: auto-neg incomplete\n"); + // jehanne_print("miistatus: auto-neg incomplete\n"); return -1; } bmsr = mii->mir(mii, phyno, Bmsr); if(!(bmsr & BmsrLs)){ - // print("miistatus: link down\n"); + // jehanne_print("miistatus: link down\n"); phy->link = 0; return -1; } @@ -214,7 +214,7 @@ miistatus(Mii* mii) phy->speed = 10; } if(phy->speed == 0) { - // print("miistatus: phy speed 0\n"); + // jehanne_print("miistatus: phy speed 0\n"); return -1; } diff --git a/sys/src/kern/386/fis.c b/sys/src/kern/386/fis.c index 5450d90..d845352 100644 --- a/sys/src/kern/386/fis.c +++ b/sys/src/kern/386/fis.c @@ -67,7 +67,7 @@ setfissig(Sfis *x, uint32_t sig) void skelfis(uint8_t *c) { - memset(c, 0, Fissize); + jehanne_memset(c, 0, Fissize); c[Ftype] = H2dev; c[Fflags] = Fiscmd; c[Fdev] = Ataobs; @@ -357,7 +357,7 @@ idmove(char *p, uint16_t *u, int n) p = op; while(*p == ' ') p++; - memmove(op, p, n - (e - p)); + jehanne_memmove(op, p, n - (e - p)); } char* @@ -368,8 +368,8 @@ pflag(char *s, char *e, Sfis *f) u = f->feat; for(i = 0; i < Dnflag; i++) if(u & (1 << i)) - s = seprint(s, e, "%s ", flagname[i]); - return seprint(s, e, "\n"); + s = jehanne_seprint(s, e, "%s ", flagname[i]); + return jehanne_seprint(s, e, "\n"); } int @@ -380,8 +380,8 @@ atapirwfis(Sfis *f, uint8_t *c, uint8_t *cdb, int cdblen, int ndata) fill = f->feat&Datapi16? 16: 12; if((len = cdblen) > fill) len = fill; - memmove(c + 0x40, cdb, len); - memset(c + 0x40 + len, 0, fill - len); + jehanne_memmove(c + 0x40, cdb, len); + jehanne_memset(c + 0x40 + len, 0, fill - len); c[Ftype] = H2dev; c[Fflags] = Fiscmd; @@ -394,7 +394,7 @@ atapirwfis(Sfis *f, uint8_t *c, uint8_t *cdb, int cdblen, int ndata) c[Flba8] = ndata; c[Flba16] = ndata >> 8; c[Fdev] = Ataobs; - memset(c + 8, 0, Fissize - 8); + jehanne_memset(c + 8, 0, Fissize - 8); return P28|Ppkt; } @@ -439,7 +439,7 @@ rwfis(Sfis *f, uint8_t *c, int rw, int nsect, uint64_t lba) c[Ficc] = 0; c[Fcontrol] = 0; - memset(c + 16, 0, Fissize - 16); + jehanne_memset(c + 16, 0, Fissize - 16); return ptab[udma][rw][llba]; } @@ -469,7 +469,7 @@ sigtofis(Sfis *f, uint8_t *c) uint32_t u; u = f->sig; - memset(c, 0, Fissize); + jehanne_memset(c, 0, Fissize); c[Ftype] = 0x34; c[Fflags] = 0x00; c[Fcmd] = 0x50; @@ -492,7 +492,7 @@ fistosig(uint8_t *u) void smpskelframe(Cfis *f, uint8_t *c, int m) { - memset(c, 0, Fissize); + jehanne_memset(c, 0, Fissize); c[Ftype] = 0x40; c[Fflags] = m; if(f->phyid) diff --git a/sys/src/kern/386/i8042.c b/sys/src/kern/386/i8042.c index bbf1bda..6d7badc 100644 --- a/sys/src/kern/386/i8042.c +++ b/sys/src/kern/386/i8042.c @@ -145,7 +145,7 @@ mousecmd(int cmd) iunlock(&i8042lock); if(c != 0xFA){ - print("mousecmd: %2.2ux returned to the %2.2ux command\n", c, cmd); + jehanne_print("mousecmd: %2.2ux returned to the %2.2ux command\n", c, cmd); badkbd = 1; /* don't keep trying; there might not be one */ return -1; } @@ -266,7 +266,7 @@ keybinit(void) } if (try <= 0) { iunlock(&i8042lock); - print("keybinit failed 0\n"); + jehanne_print("keybinit failed 0\n"); return; } @@ -274,7 +274,7 @@ keybinit(void) outb(Cmd, 0x20); if(inready() == -1){ iunlock(&i8042lock); - print("keybinit failed 1\n"); + jehanne_print("keybinit failed 1\n"); ccc = 0; } else ccc = inb(Data); @@ -284,18 +284,18 @@ keybinit(void) ccc |= Csf | Ckeybint | Cscs1; if(outready() == -1) { iunlock(&i8042lock); - print("keybinit failed 2\n"); + jehanne_print("keybinit failed 2\n"); return; } if (outbyte(Cmd, 0x60) == -1){ iunlock(&i8042lock); - print("keybinit failed 3\n"); + jehanne_print("keybinit failed 3\n"); return; } if (outbyte(Data, ccc) == -1){ iunlock(&i8042lock); - print("keybinit failed 4\n"); + jehanne_print("keybinit failed 4\n"); return; } diff --git a/sys/src/kern/386/kbd.c b/sys/src/kern/386/kbd.c index 9de0dd0..77e0e4d 100644 --- a/sys/src/kern/386/kbd.c +++ b/sys/src/kern/386/kbd.c @@ -272,7 +272,7 @@ i8042auxcmd(int cmd) iunlock(&i8042lock); if(c != 0xFA){ - print("i8042: %2.2ux returned to the %2.2ux command\n", c, cmd); + jehanne_print("i8042: %2.2ux returned to the %2.2ux command\n", c, cmd); return -1; } return 0; @@ -362,7 +362,7 @@ i8042intr(Ureg*, void*) if(c > sizeof kbtab){ c |= keyup; if(c != 0xFF) /* these come fairly often: CAPSLOCK U Y */ - print("unknown key %ux\n", c); + jehanne_print("unknown key %ux\n", c); return; } @@ -498,13 +498,13 @@ i8042auxenable(void (*putc)(int, int)) ilock(&i8042lock); if(outready() < 0) - print(err); + jehanne_print(err); outb(Cmd, 0x60); /* write control register */ if(outready() < 0) - print(err); + jehanne_print(err); outb(Data, ccc); if(outready() < 0) - print(err); + jehanne_print(err); outb(Cmd, 0xA8); /* auxilliary device enable */ if(outready() < 0){ iunlock(&i8042lock); @@ -522,7 +522,7 @@ outbyte(int port, int c) { outb(port, c); if(outready() < 0) { - print(initfailed); + jehanne_print(initfailed); return -1; } return 0; @@ -541,14 +541,14 @@ kbdinit(void) delay(1); } if (try <= 0) { - print(initfailed); + jehanne_print(initfailed); return; } /* get current controller command byte */ outb(Cmd, 0x20); if(inready() < 0){ - print("i8042: kbdinit can't read ccc\n"); + jehanne_print("i8042: kbdinit can't read ccc\n"); ccc = 0; } else ccc = inb(Data); @@ -557,7 +557,7 @@ kbdinit(void) ccc &= ~Ckbddis; ccc |= Csf | Ckbdint | Cscs1; if(outready() < 0) { - print(initfailed); + jehanne_print(initfailed); return; } @@ -565,7 +565,7 @@ kbdinit(void) /* disable mouse */ if (outbyte(Cmd, 0x60) < 0 || outbyte(Data, ccc) < 0) - print("i8042: kbdinit mouse disable failed\n"); + jehanne_print("i8042: kbdinit mouse disable failed\n"); } void diff --git a/sys/src/kern/386/pci.c b/sys/src/kern/386/pci.c index a5e3871..0c03e8a 100644 --- a/sys/src/kern/386/pci.c +++ b/sys/src/kern/386/pci.c @@ -80,31 +80,31 @@ tbdffmt(Fmt* fmt) int l, r; uint32_t type, tbdf; - if((p = malloc(READSTR)) == nil) - return fmtstrcpy(fmt, "(tbdfconv)"); + if((p = jehanne_malloc(READSTR)) == nil) + return jehanne_fmtstrcpy(fmt, "(tbdfconv)"); switch(fmt->r){ case 'T': tbdf = va_arg(fmt->args, int); if(tbdf == BUSUNKNOWN) - snprint(p, READSTR, "unknown"); + jehanne_snprint(p, READSTR, "unknown"); else{ type = BUSTYPE(tbdf); if(type < nelem(bustypes)) - l = snprint(p, READSTR, bustypes[type]); + l = jehanne_snprint(p, READSTR, bustypes[type]); else - l = snprint(p, READSTR, "%d", type); - snprint(p+l, READSTR-l, ".%d.%d.%d", + l = jehanne_snprint(p, READSTR, "%d", type); + jehanne_snprint(p+l, READSTR-l, ".%d.%d.%d", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); } break; default: - snprint(p, READSTR, "(tbdfconv)"); + jehanne_snprint(p, READSTR, "(tbdfconv)"); break; } - r = fmtstrcpy(fmt, p); - free(p); + r = jehanne_fmtstrcpy(fmt, p); + jehanne_free(p); return r; } @@ -175,7 +175,7 @@ pcibusmap(Pcidev *root, uint32_t *pmema, uint32_t *pioa, int wrreg) ntb++; ntb *= (PciCIS-PciBAR0)/4; - table = malloc(2*ntb*sizeof(Pcisiz)); + table = jehanne_malloc(2*ntb*sizeof(Pcisiz)); if(table == nil) panic("pcibusmap: can't allocate memory"); itb = table; @@ -247,9 +247,9 @@ pcibusmap(Pcidev *root, uint32_t *pmema, uint32_t *pioa, int wrreg) /* * Sort both tables IO smallest first, Memory largest */ - qsort(table, itb-table, sizeof(Pcisiz), pcisizcmp); + jehanne_qsort(table, itb-table, sizeof(Pcisiz), pcisizcmp); tptr = table+ntb; - qsort(tptr, mtb-tptr, sizeof(Pcisiz), pcisizcmp); + jehanne_qsort(tptr, mtb-tptr, sizeof(Pcisiz), pcisizcmp); /* * Allocate IO address space on this bus @@ -296,7 +296,7 @@ pcibusmap(Pcidev *root, uint32_t *pmema, uint32_t *pioa, int wrreg) *pmema = mema; *pioa = ioa; - free(table); + jehanne_free(table); if(wrreg == 0) return; @@ -368,7 +368,7 @@ pcilscan(int bno, Pcidev** list, Pcidev *parent) l = pcicfgrw32(tbdf, PciVID, 0, 1); if(l == 0xFFFFFFFF || l == 0) continue; - p = malloc(sizeof(*p)); + p = jehanne_malloc(sizeof(*p)); if(p == nil) panic("pcilscan: can't allocate memory"); p->tbdf = tbdf; @@ -432,7 +432,7 @@ pcilscan(int bno, Pcidev** list, Pcidev *parent) rno += 4; hi = pcicfgr32(p, rno); if(hi != 0){ - print("ignoring 64-bit bar %d: %llux %d from %T\n", + jehanne_print("ignoring 64-bit bar %d: %llux %d from %T\n", i, (uint64_t)hi<<32 | p->mem[i].bar, p->mem[i].size, p->tbdf); p->mem[i].bar = 0; p->mem[i].size = 0; @@ -754,13 +754,13 @@ pcirouting(void) if(size < sizeof(Router) || checksum(r, size)) return; - if(0) print("PCI interrupt routing table version %d.%d at %p\n", + if(0) jehanne_print("PCI interrupt routing table version %d.%d at %p\n", r->version[0], r->version[1], r); tbdf = MKBUS(BusPCI, r->bus, (r->devfn>>3)&0x1f, r->devfn&7); sbpci = pcimatchtbdf(tbdf); if(sbpci == nil) { - print("pcirouting: Cannot find south bridge %T\n", tbdf); + jehanne_print("pcirouting: Cannot find south bridge %T\n", tbdf); return; } @@ -769,7 +769,7 @@ pcirouting(void) break; if(i == nelem(southbridges)) { - print("pcirouting: ignoring south bridge %T %.4uX/%.4uX\n", tbdf, sbpci->vid, sbpci->did); + jehanne_print("pcirouting: ignoring south bridge %T %.4uX/%.4uX\n", tbdf, sbpci->vid, sbpci->did); return; } southbridge = &southbridges[i]; @@ -779,12 +779,12 @@ pcirouting(void) pciirqs = (r->pciirqs[1] << 8)|r->pciirqs[0]; for(e = (Slot *)&r[1]; (uint8_t *)e < p + size; e++) { if(0) { - print("%.2uX/%.2uX %.2uX: ", e->bus, e->dev, e->slot); + jehanne_print("%.2uX/%.2uX %.2uX: ", e->bus, e->dev, e->slot); for (i = 0; i < 4; i++) { map = &e->maps[i * 3]; - print("[%d] %.2uX %.4uX ", i, map[0], (map[2] << 8)|map[1]); + jehanne_print("[%d] %.2uX %.4uX ", i, map[0], (map[2] << 8)|map[1]); } - print("\n"); + jehanne_print("\n"); } for(i = 0; i < 8; i++) { tbdf = MKBUS(BusPCI, e->bus, (e->dev>>3)&0x1f, i); @@ -808,7 +808,7 @@ pcirouting(void) continue; southbridge->set(sbpci, link, irq); } - print("pcirouting: %T at pin %d link %.2uX irq %d -> %d\n", tbdf, pin, link, pci->intl, irq); + jehanne_print("pcirouting: %T at pin %d link %.2uX irq %d -> %d\n", tbdf, pin, link, pci->intl, irq); pcicfgw8(pci, PciINTL, irq); pci->intl = irq; } @@ -825,7 +825,7 @@ pcicfgrw8bios(int tbdf, int rno, int data, int read) if(pcibiossi == nil) return -1; - memset(&ci, 0, sizeof(BIOS32ci)); + jehanne_memset(&ci, 0, sizeof(BIOS32ci)); ci.ebx = (BUSBNO(tbdf)<<8)|(BUSDNO(tbdf)<<3)|BUSFNO(tbdf); ci.edi = rno; if(read){ @@ -851,7 +851,7 @@ pcicfgrw16bios(int tbdf, int rno, int data, int read) if(pcibiossi == nil) return -1; - memset(&ci, 0, sizeof(BIOS32ci)); + jehanne_memset(&ci, 0, sizeof(BIOS32ci)); ci.ebx = (BUSBNO(tbdf)<<8)|(BUSDNO(tbdf)<<3)|BUSFNO(tbdf); ci.edi = rno; if(read){ @@ -877,7 +877,7 @@ pcicfgrw32bios(int tbdf, int rno, int data, int read) if(pcibiossi == nil) return -1; - memset(&ci, 0, sizeof(BIOS32ci)); + jehanne_memset(&ci, 0, sizeof(BIOS32ci)); ci.ebx = (BUSBNO(tbdf)<<8)|(BUSDNO(tbdf)<<3)|BUSFNO(tbdf); ci.edi = rno; if(read){ @@ -904,10 +904,10 @@ pcibiosinit(void) if((si = bios32open("$PCI")) == nil) return nil; - memset(&ci, 0, sizeof(BIOS32ci)); + jehanne_memset(&ci, 0, sizeof(BIOS32ci)); ci.eax = 0xB101; if(bios32ci(si, &ci) || ci.edx != ((' '<<24)|('I'<<16)|('C'<<8)|'P')){ - free(si); + jehanne_free(si); return nil; } if(ci.eax & 0x01) @@ -996,12 +996,12 @@ pcicfginit(void) pcicfgmode = 3; } - fmtinstall('T', tbdffmt); + jehanne_fmtinstall('T', tbdffmt); if(p = getconf("*pcimaxbno")) - pcimaxbno = strtoul(p, 0, 0); + pcimaxbno = jehanne_strtoul(p, 0, 0); if(p = getconf("*pcimaxdno")){ - n = strtoul(p, 0, 0); + n = jehanne_strtoul(p, 0, 0); if(n < pcimaxdno) pcimaxdno = n; } @@ -1317,26 +1317,26 @@ pcilhinv(Pcidev* p) if(p == nil) { p = pciroot; - print("bus dev type vid did intl memory\n"); + jehanne_print("bus dev type vid did intl memory\n"); } for(t = p; t != nil; t = t->link) { - print("%d %2d/%d %.2ux %.2ux %.2ux %.4ux %.4ux %3d ", + jehanne_print("%d %2d/%d %.2ux %.2ux %.2ux %.4ux %.4ux %3d ", BUSBNO(t->tbdf), BUSDNO(t->tbdf), BUSFNO(t->tbdf), t->ccrb, t->ccru, t->ccrp, t->vid, t->did, t->intl); for(i = 0; i < nelem(p->mem); i++) { if(t->mem[i].size == 0) continue; - print("%d:%.8lux %d ", i, + jehanne_print("%d:%.8lux %d ", i, t->mem[i].bar, t->mem[i].size); } if(t->ioa.bar || t->ioa.size) - print("ioa:%.8lux %d ", t->ioa.bar, t->ioa.size); + jehanne_print("ioa:%.8lux %d ", t->ioa.bar, t->ioa.size); if(t->mema.bar || t->mema.size) - print("mema:%.8lux %d ", t->mema.bar, t->mema.size); + jehanne_print("mema:%.8lux %d ", t->mema.bar, t->mema.size); if(t->bridge) - print("->%d", BUSBNO(t->bridge->tbdf)); - print("\n"); + jehanne_print("->%d", BUSBNO(t->bridge->tbdf)); + jehanne_print("\n"); } while(p != nil) { if(p->bridge != nil) diff --git a/sys/src/kern/386/pmcio.c b/sys/src/kern/386/pmcio.c index 596d977..ea5c68e 100644 --- a/sys/src/kern/386/pmcio.c +++ b/sys/src/kern/386/pmcio.c @@ -218,7 +218,7 @@ pmcintelfamily(void) void pmcinitctl(PmcCtl *p) { - memset(p, 0xff, sizeof(PmcCtl)); + jehanne_memset(p, 0xff, sizeof(PmcCtl)); p->enab = PmcCtlNullval; p->user = PmcCtlNullval; p->os = PmcCtlNullval; @@ -233,14 +233,14 @@ pmcconfigure(void) isrecog = 0; - if(memcmp(&m->cpuinfo[0][1], "AuthcAMDenti", 12) == 0){ + if(jehanne_memcmp(&m->cpuinfo[0][1], "AuthcAMDenti", 12) == 0){ isrecog++; cfg.ctrbase = PerfCtrbaseAmd; cfg.evtbase = PerfEvtbaseAmd; cfg.vendor = PeAmd; cfg.family = PeUnk; cfg.pmcidsarch = pmcidsk10; - }else if(memcmp(&m->cpuinfo[0][1], "GenuntelineI", 12) == 0){ + }else if(jehanne_memcmp(&m->cpuinfo[0][1], "GenuntelineI", 12) == 0){ isrecog++; cfg.ctrbase = PerfCtrbaseIntel; cfg.evtbase = PerfEvtbaseIntel; @@ -306,8 +306,8 @@ pmctrans(PmcCtl *p) n = 0; if(cfg.pmcidsarch != nil) for (pi = &cfg.pmcidsarch[0]; pi->portdesc[0] != '\0'; pi++){ - if (strncmp(p->descstr, pi->portdesc, strlen(pi->portdesc)) == 0){ - strncpy(p->descstr, pi->archdesc, strlen(pi->archdesc) + 1); + if (jehanne_strncmp(p->descstr, pi->portdesc, jehanne_strlen(pi->portdesc)) == 0){ + jehanne_strncpy(p->descstr, pi->archdesc, jehanne_strlen(pi->archdesc) + 1); n = 1; break; } @@ -315,14 +315,14 @@ pmctrans(PmcCtl *p) /* this ones supersede the other ones */ if(cfg.pmcids != nil) for (pi = &cfg.pmcids[0]; pi->portdesc[0] != '\0'; pi++){ - if (strncmp(p->descstr, pi->portdesc, strlen(pi->portdesc)) == 0){ - strncpy(p->descstr, pi->archdesc, strlen(pi->archdesc) + 1); + if (jehanne_strncmp(p->descstr, pi->portdesc, jehanne_strlen(pi->portdesc)) == 0){ + jehanne_strncpy(p->descstr, pi->archdesc, jehanne_strlen(pi->archdesc) + 1); n = 1; break; } } if(pmcdebug != 0) - print("really setting %s\n", p->descstr); + jehanne_print("really setting %s\n", p->descstr); return n; } @@ -346,7 +346,7 @@ getctl(PmcCtl *p, uint32_t regno) e = GetEvMsk(r); u = GetUMsk(r); /* TODO inverse translation */ - snprint(p->descstr, KNAMELEN, "%#ullx %#ullx", e, u); + jehanne_snprint(p->descstr, KNAMELEN, "%#ullx %#ullx", e, u); p->nodesc = 0; return 0; } @@ -399,11 +399,11 @@ setctl(PmcCtl *p, int regno) return -1; if (p->nodesc == 0) { - memmove(str, p->descstr, KNAMELEN); - if (tokenize(str, toks, 2) != 2) + jehanne_memmove(str, p->descstr, KNAMELEN); + if (jehanne_tokenize(str, toks, 2) != 2) return -1; - e = atoi(toks[0]); - u = atoi(toks[1]); + e = jehanne_atoi(toks[0]); + u = jehanne_atoi(toks[1]); v &= ~(PeEvMskL|PeEvMskH|PeUnMsk); v |= SetEvMsk(v, e); v |= SetUMsk(v, u); @@ -412,7 +412,7 @@ setctl(PmcCtl *p, int regno) pmcuserenab(pmcanyenab()); if (pmcdebug) { v = rdmsr(regno+ cfg.evtbase); - print("conf pmc[%#ux]: %#llux\n", regno, v); + jehanne_print("conf pmc[%#ux]: %#llux\n", regno, v); } return 0; } @@ -426,7 +426,7 @@ pmcdescstr(char *str, int nstr) ns = 0; if(pmcdebug != 0) - print("vendor %x family %x nregs %d pmcnregs %d\n", cfg.vendor, cfg.family, cfg.nregs, pmcnregs()); + jehanne_print("vendor %x family %x nregs %d pmcnregs %d\n", cfg.vendor, cfg.family, cfg.nregs, pmcnregs()); if(cfg.pmcidsarch == nil && cfg.pmcids == nil){ *str = 0; return ns; @@ -434,10 +434,10 @@ pmcdescstr(char *str, int nstr) if(cfg.pmcidsarch != nil) for (pi = &cfg.pmcidsarch[0]; pi->portdesc[0] != '\0'; pi++) - ns += snprint(str + ns, nstr - ns, "%s\n",pi->portdesc); + ns += jehanne_snprint(str + ns, nstr - ns, "%s\n",pi->portdesc); if(cfg.pmcids != nil) for (pi = &cfg.pmcids[0]; pi->portdesc[0] != '\0'; pi++) - ns += snprint(str + ns, nstr - ns, "%s\n",pi->portdesc); + ns += jehanne_snprint(str + ns, nstr - ns, "%s\n",pi->portdesc); return ns; } @@ -508,7 +508,7 @@ ctl2ctl(PmcCtl *dctl, PmcCtl *sctl) if(sctl->os != PmcCtlNullval) dctl->os = sctl->os; if(sctl->nodesc == 0) { - memmove(dctl->descstr, sctl->descstr, KNAMELEN); + jehanne_memmove(dctl->descstr, sctl->descstr, KNAMELEN); dctl->nodesc = 0; } } @@ -551,7 +551,7 @@ pmcgetctl(uint32_t coreno, PmcCtl *pctl, uint32_t regno) if(coreno == m->machno) n = getctl(pctl, regno); else{ - memmove(pctl, &p->PmcCtl, sizeof(PmcCtl)); + jehanne_memmove(pctl, &p->PmcCtl, sizeof(PmcCtl)); n = 0; } iunlock(&pmccore[coreno]); diff --git a/sys/src/kern/386/sdiahci.c b/sys/src/kern/386/sdiahci.c index e28dae8..1c295fd 100644 --- a/sys/src/kern/386/sdiahci.c +++ b/sys/src/kern/386/sdiahci.c @@ -304,7 +304,7 @@ cfissetup(Aportc *pc) uint8_t *cfis; cfis = pc->pm->ctab->cfis; - memset(cfis, 0, 0x20); + jehanne_memset(cfis, 0, 0x20); cfis[0] = 0x27; cfis[1] = 0x80; cfis[7] = Obs; @@ -499,7 +499,7 @@ ahciidentify0(Aportc *pc, void *id, int atapi) c[2] = tab[atapi]; listsetup(pc, 1<<16); - memset(id, 0, 0x100); /* magic */ + jehanne_memset(id, 0, 0x100); /* magic */ p = &pc->pm->ctab->prdt; p->dba = PCIWADDRL(id); p->dbahi = PCIWADDRH(id); @@ -684,7 +684,7 @@ ahcirecover(Aportc *pc) static void* malign(int size, int align) { - return mallocalign(size, align, 0, 0); + return jehanne_mallocalign(size, align, 0, 0); } static void @@ -845,7 +845,7 @@ idmove(char *p, uint16_t *a, int n) e = p; for (p = op; *p == ' '; p++) ; - memmove(op, p, n - (e - p)); + jehanne_memmove(op, p, n - (e - p)); } static int @@ -858,7 +858,7 @@ identify(Drive *d) if(d->info == nil) { d->infosz = 512 * sizeof(uint16_t); - d->info = malloc(d->infosz); + d->info = jehanne_malloc(d->infosz); } if(d->info == nil) { d->info = d->tinyinfo; @@ -871,7 +871,7 @@ identify(Drive *d) return -1; } osectors = d->sectors; - memmove(oserial, d->serial, sizeof d->serial); + jehanne_memmove(oserial, d->serial, sizeof d->serial); u = d->unit; d->sectors = s; @@ -884,13 +884,13 @@ identify(Drive *d) idmove(d->firmware, id+23, 8); idmove(d->model, id+27, 40); - memset(u->inquiry, 0, sizeof u->inquiry); + jehanne_memset(u->inquiry, 0, sizeof u->inquiry); u->inquiry[2] = 2; u->inquiry[3] = 2; u->inquiry[4] = sizeof u->inquiry - 4; - memmove(u->inquiry+8, d->model, 40); + jehanne_memmove(u->inquiry+8, d->model, 40); - if(osectors != s || memcmp(oserial, d->serial, sizeof oserial) != 0){ + if(osectors != s || jehanne_memcmp(oserial, d->serial, sizeof oserial) != 0){ d->mediachange = 1; u->sectors = 0; } @@ -1171,13 +1171,13 @@ checkdrive(Drive *d, int i) char *name; if(d == nil) { - print("checkdrive: nil d\n"); + jehanne_print("checkdrive: nil d\n"); return; } ilock(d); if(d->unit == nil || d->port == nil) { if(0) - print("checkdrive: nil d->%s\n", + jehanne_print("checkdrive: nil d->%s\n", d->unit == nil? "unit": "port"); iunlock(d); return; @@ -1406,7 +1406,7 @@ awaitspinup(Drive *d) ilock(d); break; } - print("awaitspinup: %s didn't spin up after 20 seconds\n", name); + jehanne_print("awaitspinup: %s didn't spin up after 20 seconds\n", name); iunlock(d); } @@ -1447,7 +1447,7 @@ iaenable(SDev *s) if(c->ndrive == 0) panic("iaenable: zero s->ctlr->ndrive"); pcisetbme(c->pci); - snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); + jehanne_snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); c->vector = intrenable(c->pci->intl, iainterrupt, c, c->pci->tbdf, name); /* supposed to squelch leftover interrupts here. */ ahcienable(c->hba); @@ -1470,7 +1470,7 @@ iadisable(SDev *s) c = s->ctlr; ilock(c); ahcidisable(c->hba); - snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); + jehanne_snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); intrdisable(c->vector); c->enabled = 0; iunlock(c); @@ -1586,8 +1586,8 @@ ahcibuildpkt(Aportm *pm, SDreq *r, void *data, int n) fill = pm->feat&Datapi16? 16: 12; if((len = r->clen) > fill) len = fill; - memmove(t->atapi, r->cmd, len); - memset(t->atapi+len, 0, fill-len); + jehanne_memmove(t->atapi, r->cmd, len); + jehanne_memset(t->atapi+len, 0, fill-len); c[0] = 0x27; c[1] = 0x80; @@ -1646,7 +1646,7 @@ waitready(Drive *d) return 0; /* ready, present & phy. comm. */ esleep(250); } - print("%s: not responding; offline\n", d->unit->name); + jehanne_print("%s: not responding; offline\n", d->unit->name); d->state = Doffline; return -1; } @@ -1745,7 +1745,7 @@ retry: qunlock(&d->portm); if(flag == 0){ if(++try == 10){ - print("%s: bad disk\n", name); + jehanne_print("%s: bad disk\n", name); r->status = SDcheck; return SDcheck; } @@ -1768,13 +1768,13 @@ retry: break; } if (!wormwrite) { - print("%s: retry\n", name); + jehanne_print("%s: retry\n", name); goto retry; } } if(flag & Ferror){ if((task&Eidnf) == 0) - print("%s: i/o error task=%#ux\n", name, task); + jehanne_print("%s: i/o error task=%#ux\n", name, task); r->status = SDcheck; return SDcheck; } @@ -1820,7 +1820,7 @@ iario(SDreq *r) } if(*cmd != 0x28 && *cmd != 0x2a){ - print("%s: bad cmd %.2#ux\n", name, cmd[0]); + jehanne_print("%s: bad cmd %.2#ux\n", name, cmd[0]); r->status = SDcheck; return SDcheck; } @@ -1880,15 +1880,15 @@ retry: qunlock(&d->portm); if(flag == 0){ if(++try == 10){ - print("%s: bad disk\n", name); + jehanne_print("%s: bad disk\n", name); r->status = SDeio; return SDeio; } - print("%s: retry blk %lld\n", name, lba); + jehanne_print("%s: retry blk %lld\n", name, lba); goto retry; } if(flag & Ferror){ - print("%s: i/o error task=%#ux @%,lld\n", + jehanne_print("%s: i/o error task=%#ux @%,lld\n", name, task, lba); r->status = SDeio; return SDeio; @@ -1955,20 +1955,20 @@ didtype(Pcidev *p) break; case 0x1002: if(p->did == 0x4380 || p->did == 0x4390 || p->did == 0x4391){ - print("detected sb600 vid %#ux did %#ux\n", p->vid, p->did); + jehanne_print("detected sb600 vid %#ux did %#ux\n", p->vid, p->did); return Tsb600; } break; case 0x1b4b: /* can't cope with sata 3 yet; touching sd files will hang */ if (p->did == 0x9123) { - print("ahci: ignoring sata 3 controller\n"); + jehanne_print("ahci: ignoring sata 3 controller\n"); return -1; } break; } if(p->ccrb == Pcibcstore && p->ccru == Pciscsata && p->ccrp == 1){ - print("ahci: Tunk: VID %#4.4ux DID %#4.4ux\n", p->vid, p->did); + jehanne_print("ahci: Tunk: VID %#4.4ux DID %#4.4ux\n", p->vid, p->did); return Tunk; } return -1; @@ -1984,13 +1984,13 @@ newctlr(Ctlr *ctlr, SDev *sdev, int nunit) ctlr->mport = ctlr->hba->cap & ((1<<5)-1); i = (ctlr->hba->cap >> 20) & ((1<<4)-1); /* iss */ - print("#S/sd%c: %s: %#p %s, %d ports, irq %d\n", sdev->idno, + jehanne_print("#S/sd%c: %s: %#p %s, %d ports, irq %d\n", sdev->idno, Tname(ctlr), ctlr->physio, descmode[i], nunit, ctlr->pci->intl); /* map the drives -- they don't all need to be enabled. */ n = 0; - ctlr->rawdrive = malloc(NCtlrdrv * sizeof(Drive)); + ctlr->rawdrive = jehanne_malloc(NCtlrdrv * sizeof(Drive)); if(ctlr->rawdrive == nil) { - print("ahci: out of memory\n"); + jehanne_print("ahci: out of memory\n"); return -1; } for(i = 0; i < NCtlrdrv; i++) { @@ -2035,7 +2035,7 @@ iapnp(void) if(done++) return nil; - memset(olds, 0xff, sizeof olds); + jehanne_memset(olds, 0xff, sizeof olds); p = nil; head = tail = nil; while((p = pcimatch(p, 0, 0)) != nil){ @@ -2043,19 +2043,19 @@ iapnp(void) if (type == -1 || p->mem[Abar].bar == 0) continue; if(niactlr == NCtlr){ - print("ahci: iapnp: %s: too many controllers\n", + jehanne_print("ahci: iapnp: %s: too many controllers\n", tname[type]); break; } c = iactlr + niactlr; s = sdevs + niactlr; - memset(c, 0, sizeof *c); - memset(s, 0, sizeof *s); + jehanne_memset(c, 0, sizeof *c); + jehanne_memset(s, 0, sizeof *s); io = p->mem[Abar].bar & ~0xf; c->physio = (uint8_t *)io; c->mmio = vmap(io, p->mem[Abar].size); if(c->mmio == 0){ - print("ahci: %s: address %#lux in use did=%#ux\n", + jehanne_print("ahci: %s: address %#lux in use did=%#ux\n", Tname(c), io, p->did); continue; } @@ -2106,8 +2106,8 @@ pflag(char *s, char *e, uint8_t f) for(i = 0; i < 8; i++) if(f & (1 << i)) - s = seprint(s, e, "%s ", flagname[i]); - return seprint(s, e, "\n"); + s = jehanne_seprint(s, e, "%s ", flagname[i]); + return jehanne_seprint(s, e, "\n"); } static int @@ -2121,7 +2121,7 @@ iarctl(SDunit *u, char *p, int l) c = u->dev->ctlr; if(c == nil) { -print("iarctl: nil u->dev->ctlr\n"); +jehanne_print("iarctl: nil u->dev->ctlr\n"); return 0; } d = c->drive[u->subno]; @@ -2130,28 +2130,28 @@ print("iarctl: nil u->dev->ctlr\n"); e = p+l; op = p; if(d->state == Dready){ - p = seprint(p, e, "model\t%s\n", d->model); - p = seprint(p, e, "serial\t%s\n", d->serial); - p = seprint(p, e, "firm\t%s\n", d->firmware); + p = jehanne_seprint(p, e, "model\t%s\n", d->model); + p = jehanne_seprint(p, e, "serial\t%s\n", d->serial); + p = jehanne_seprint(p, e, "firm\t%s\n", d->firmware); if(d->smartrs == 0xff) - p = seprint(p, e, "smart\tenable error\n"); + p = jehanne_seprint(p, e, "smart\tenable error\n"); else if(d->smartrs == 0) - p = seprint(p, e, "smart\tdisabled\n"); + p = jehanne_seprint(p, e, "smart\tdisabled\n"); else - p = seprint(p, e, "smart\t%s\n", + p = jehanne_seprint(p, e, "smart\t%s\n", smarttab[d->portm.smart]); - p = seprint(p, e, "flag\t"); + p = jehanne_seprint(p, e, "flag\t"); p = pflag(p, e, d->portm.feat); }else - p = seprint(p, e, "no disk present [%s]\n", diskstates[d->state]); + p = jehanne_seprint(p, e, "no disk present [%s]\n", diskstates[d->state]); serrstr(o->serror, buf, buf + sizeof buf - 1); - p = seprint(p, e, "reg\ttask %#lux cmd %#lux serr %#lux %s ci %#lux " + p = jehanne_seprint(p, e, "reg\ttask %#lux cmd %#lux serr %#lux %s ci %#lux " "is %#lux; sig %#lux sstatus %06#lux\n", o->task, o->cmd, o->serror, buf, o->ci, o->isr, o->sig, o->sstatus); if(d->unit == nil) panic("iarctl: nil d->unit"); - p = seprint(p, e, "geometry %llud %lud\n", d->sectors, d->unit->secsize); + p = jehanne_seprint(p, e, "geometry %llud %lud\n", d->sectors, d->unit->secsize); return p - op; } @@ -2172,7 +2172,7 @@ forcemode(Drive *d, char *mode) int i; for(i = 0; i < nelem(modename); i++) - if(strcmp(mode, modename[i]) == 0) + if(jehanne_strcmp(mode, modename[i]) == 0) break; if(i == nelem(modename)) i = 0; @@ -2201,7 +2201,7 @@ forcestate(Drive *d, char *state) int i; for(i = 0; i < nelem(diskstates); i++) - if(strcmp(state, diskstates[i]) == 0) + if(jehanne_strcmp(state, diskstates[i]) == 0) break; if(i == nelem(diskstates)) error(Ebadctl); @@ -2238,18 +2238,18 @@ iawctl(SDunit *u, Cmdbuf *cmd) d = c->drive[u->subno]; f = cmd->f; - if(strcmp(f[0], "change") == 0) + if(jehanne_strcmp(f[0], "change") == 0) changemedia(u); - else if(strcmp(f[0], "flushcache") == 0) + else if(jehanne_strcmp(f[0], "flushcache") == 0) runflushcache(d); - else if(strcmp(f[0], "identify") == 0){ - i = strtoul(f[1]? f[1]: "0", 0, 0); + else if(jehanne_strcmp(f[0], "identify") == 0){ + i = jehanne_strtoul(f[1]? f[1]: "0", 0, 0); if(i > 0xff) i = 0; dprint("ahci: %04d %#ux\n", i, d->info[i]); - }else if(strcmp(f[0], "mode") == 0) + }else if(jehanne_strcmp(f[0], "mode") == 0) forcemode(d, f[1]? f[1]: "satai"); - else if(strcmp(f[0], "nop") == 0){ + else if(jehanne_strcmp(f[0], "nop") == 0){ if((d->portm.feat & Dnop) == 0){ cmderror(cmd, "no drive support"); return -1; @@ -2263,9 +2263,9 @@ iawctl(SDunit *u, Cmdbuf *cmd) nop(&d->portc); qunlock(&d->portm); poperror(); - }else if(strcmp(f[0], "reset") == 0) + }else if(jehanne_strcmp(f[0], "reset") == 0) forcestate(d, "reset"); - else if(strcmp(f[0], "smart") == 0){ + else if(jehanne_strcmp(f[0], "smart") == 0){ if(d->smartrs == 0){ cmderror(cmd, "smart not enabled"); return -1; @@ -2280,11 +2280,11 @@ iawctl(SDunit *u, Cmdbuf *cmd) d->portm.smart = 2 + smartrs(&d->portc); qunlock(&d->portm); poperror(); - }else if(strcmp(f[0], "smartdisable") == 0) + }else if(jehanne_strcmp(f[0], "smartdisable") == 0) runsmartable(d, 1); - else if(strcmp(f[0], "smartenable") == 0) + else if(jehanne_strcmp(f[0], "smartenable") == 0) runsmartable(d, 0); - else if(strcmp(f[0], "state") == 0) + else if(jehanne_strcmp(f[0], "state") == 0) forcestate(d, f[1]? f[1]: "null"); else{ cmderror(cmd, Ebadctl); @@ -2303,18 +2303,18 @@ portr(char *p, char *e, uint32_t x) for(i = 0; i < 32; i++){ if((x & (1< 0) - p = seprint(p, e, ", "); - p = seprint(p, e, "%d", a = i); + p = jehanne_seprint(p, e, ", "); + p = jehanne_seprint(p, e, "%d", a = i); } } if(a != -1 && i - 1 != a) - p = seprint(p, e, "-%d", i - 1); + p = jehanne_seprint(p, e, "-%d", i - 1); return p; } @@ -2327,11 +2327,11 @@ iartopctl(SDev *sdev, char *p, char *e) Ahba *hba; Ctlr *ctlr; -#define has(x, str) if(cap & (x)) p = seprint(p, e, "%s ", (str)) +#define has(x, str) if(cap & (x)) p = jehanne_seprint(p, e, "%s ", (str)) ctlr = sdev->ctlr; hba = ctlr->hba; - p = seprint(p, e, "sd%c ahci port %#p: ", sdev->idno, ctlr->physio); + p = jehanne_seprint(p, e, "sd%c ahci port %#p: ", sdev->idno, ctlr->physio); cap = hba->cap; has(Hs64a, "64a"); has(Hsalp, "alp"); @@ -2349,7 +2349,7 @@ iartopctl(SDev *sdev, char *p, char *e) has(Hsss, "ss"); has(Hsxs, "sxs"); portr(pr, pr + sizeof pr, hba->pi); - return seprint(p, e, + return jehanne_seprint(p, e, "iss %ld ncs %ld np %ld; ghc %#lux isr %#lux pi %#lux %s ver %#lux\n", (cap>>20) & 0xf, (cap>>8) & 0x1f, 1 + (cap & 0x1f), hba->ghc, hba->isr, hba->pi, pr, hba->ver); @@ -2367,11 +2367,11 @@ iawtopctl(SDev * _1, Cmdbuf *cmd) if (f[0] == nil) return 0; - if(strcmp(f[0], "debug") == 0) + if(jehanne_strcmp(f[0], "debug") == 0) v = &debug; - else if(strcmp(f[0], "idprint") == 0) + else if(jehanne_strcmp(f[0], "idprint") == 0) v = &prid; - else if(strcmp(f[0], "aprint") == 0) + else if(jehanne_strcmp(f[0], "aprint") == 0) v = &datapi; else cmderror(cmd, Ebadctl); @@ -2384,7 +2384,7 @@ iawtopctl(SDev * _1, Cmdbuf *cmd) break; case 2: if(f[1]) - *v = strcmp(f[1], "on") == 0; + *v = jehanne_strcmp(f[1], "on") == 0; else *v ^= 1; break; diff --git a/sys/src/kern/386/sdscsi.c b/sys/src/kern/386/sdscsi.c index d0ac780..8ff6093 100644 --- a/sys/src/kern/386/sdscsi.c +++ b/sys/src/kern/386/sdscsi.c @@ -13,7 +13,7 @@ static int scsitest(SDreq* r) { r->write = 0; - memset(r->cmd, 0, sizeof(r->cmd)); + jehanne_memset(r->cmd, 0, sizeof(r->cmd)); r->cmd[1] = r->lun<<5; r->clen = 6; r->data = nil; @@ -32,16 +32,16 @@ scsiverify(SDunit* unit) int i, status; uint8_t *inquiry; - if((r = malloc(sizeof(SDreq))) == nil) + if((r = jehanne_malloc(sizeof(SDreq))) == nil) return 0; if((inquiry = sdmalloc(sizeof(unit->inquiry))) == nil){ - free(r); + jehanne_free(r); return 0; } r->unit = unit; r->lun = 0; /* ??? */ - memset(unit->inquiry, 0, sizeof(unit->inquiry)); + jehanne_memset(unit->inquiry, 0, sizeof(unit->inquiry)); r->write = 0; r->cmd[0] = 0x12; r->cmd[1] = r->lun<<5; @@ -53,11 +53,11 @@ scsiverify(SDunit* unit) r->status = ~0; if(unit->dev->ifc->rio(r) != SDok){ - free(r); + jehanne_free(r); return 0; } - memmove(unit->inquiry, inquiry, r->dlen); - free(inquiry); + jehanne_memmove(unit->inquiry, inquiry, r->dlen); + jehanne_free(inquiry); SET(status); for(i = 0; i < 3; i++){ @@ -94,7 +94,7 @@ scsiverify(SDunit* unit) * Don't wait for completion, ignore the result. */ if((unit->inquiry[0] & 0x1F) == 0){ - memset(r->cmd, 0, sizeof(r->cmd)); + jehanne_memset(r->cmd, 0, sizeof(r->cmd)); r->write = 0; r->cmd[0] = 0x1B; r->cmd[1] = (r->lun<<5)|0x01; @@ -108,7 +108,7 @@ scsiverify(SDunit* unit) unit->dev->ifc->rio(r); } } - free(r); + jehanne_free(r); if(status == SDok || status == SDcheck) return 1; @@ -254,10 +254,10 @@ scsionline(SDunit* unit) int ok, retries; void (*cap)(SDreq*); - if((r = malloc(sizeof *r)) == nil) + if((r = jehanne_malloc(sizeof *r)) == nil) return 0; if((p = sdmalloc(32)) == nil){ - free(r); + jehanne_free(r); return 0; } @@ -275,7 +275,7 @@ scsionline(SDunit* unit) r->write = 0; r->data = p; r->flags = 0; - memset(r->cmd, 0, sizeof r->cmd); + jehanne_memset(r->cmd, 0, sizeof r->cmd); cap(r); r->status = ~0; @@ -298,8 +298,8 @@ scsionline(SDunit* unit) } break; } - free(p); - free(r); + jehanne_free(p); + jehanne_free(r); if(ok) return ok+retries; @@ -313,12 +313,12 @@ scsiexec(SDunit* unit, int write, uint8_t* cmd, int clen, void* data, int* dlen) SDreq *r; int status; - if((r = malloc(sizeof(SDreq))) == nil) + if((r = jehanne_malloc(sizeof(SDreq))) == nil) return SDmalloc; r->unit = unit; r->lun = cmd[1]>>5; /* ??? */ r->write = write; - memmove(r->cmd, cmd, clen); + jehanne_memmove(r->cmd, cmd, clen); r->clen = clen; r->data = data; if(dlen) @@ -415,7 +415,7 @@ scsibio(SDunit* unit, int lun, int write, void* data, long nb, uint64_t bno) SDreq *r; long rlen; - if((r = malloc(sizeof(SDreq))) == nil) + if((r = jehanne_malloc(sizeof(SDreq))) == nil) error(Enomem); r->unit = unit; r->lun = lun; @@ -445,7 +445,7 @@ again: default: break; case 0x01: /* recovered error */ - print("%s: recovered error at sector %llud\n", + jehanne_print("%s: recovered error at sector %llud\n", unit->name, bno); rlen = r->rlen; break; @@ -471,7 +471,7 @@ again: } break; } - free(r); + jehanne_free(r); return rlen; } diff --git a/sys/src/kern/386/uarti8250.c b/sys/src/kern/386/uarti8250.c index 9b29e82..07328d6 100644 --- a/sys/src/kern/386/uarti8250.c +++ b/sys/src/kern/386/uarti8250.c @@ -161,12 +161,12 @@ i8250status(Uart* uart, void* buf, long n, long offset) uint8_t ier, lcr, mcr, msr; ctlr = uart->regs; - p = malloc(READSTR); + p = jehanne_malloc(READSTR); mcr = ctlr->sticky[Mcr]; msr = csr8r(ctlr, Msr); ier = ctlr->sticky[Ier]; lcr = ctlr->sticky[Lcr]; - snprint(p, READSTR, + jehanne_snprint(p, READSTR, "b%d c%d d%d e%d l%d m%d p%c r%d s%d i%d\n" "dev(%d) type(%d) framing(%d) overruns(%d) " "berr(%d) serr(%d)%s%s%s%s\n", @@ -194,7 +194,7 @@ i8250status(Uart* uart, void* buf, long n, long offset) (msr & Ri) ? " ring": "" ); n = readstr(offset, buf, n, p); - free(p); + jehanne_free(p); return n; } @@ -624,7 +624,7 @@ i8250alloc(int io, int irq, int tbdf) { Ctlr *ctlr; - if((ctlr = malloc(sizeof(Ctlr))) != nil){ + if((ctlr = jehanne_malloc(sizeof(Ctlr))) != nil){ ctlr->io = io; ctlr->irq = irq; ctlr->tbdf = tbdf; @@ -746,7 +746,7 @@ i8250console(char* cfg) */ if((p = getconf("console")) == nil && (p = cfg) == nil) return nil; - i = strtoul(p, &cmd, 0); + i = jehanne_strtoul(p, &cmd, 0); if(p == cmd) return nil; //WTF? Something to do with the PCIe-only machine? @@ -766,7 +766,7 @@ i8250console(char* cfg) } //Madness. Something to do with the PCIe-only machine? - memset(&isa, 0, sizeof(isa)); + jehanne_memset(&isa, 0, sizeof(isa)); ctlr = uart->regs; if(isaconfig("eia", i, &isa) != 0){ if(isa.port != 0) diff --git a/sys/src/kern/386/uartpci.c b/sys/src/kern/386/uartpci.c index 6c7e46b..6b2be00 100644 --- a/sys/src/kern/386/uartpci.c +++ b/sys/src/kern/386/uartpci.c @@ -19,13 +19,13 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name) Uart *head, *uart; io = p->mem[barno].bar & ~0x01; - snprint(buf, sizeof(buf), "%s%d", pciphysuart.name, ctlrno); + jehanne_snprint(buf, sizeof(buf), "%s%d", pciphysuart.name, ctlrno); if(ioalloc(io, p->mem[barno].size, 0, buf) < 0){ - print("uartpci: I/O %#ux in use\n", io); + jehanne_print("uartpci: I/O %#ux in use\n", io); return nil; } - head = uart = mallocz(sizeof(Uart)*n, 1); + head = uart = jehanne_mallocz(sizeof(Uart)*n, 1); for(i = 0; i < n; i++){ ctlr = i8250alloc(io, p->intl, p->tbdf); @@ -34,7 +34,7 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name) continue; uart->regs = ctlr; - snprint(buf, sizeof(buf), "%s.%8.8ux", name, p->tbdf); + jehanne_snprint(buf, sizeof(buf), "%s.%8.8ux", name, p->tbdf); kstrdup(&uart->name, buf); uart->freq = freq; uart->phys = &i8250physuart; diff --git a/sys/src/kern/386/vgavesa.c b/sys/src/kern/386/vgavesa.c index eb60d8a..533d4a6 100644 --- a/sys/src/kern/386/vgavesa.c +++ b/sys/src/kern/386/vgavesa.c @@ -51,8 +51,8 @@ vbesetup(VGAreg *u, int ax) uint32_t pa; pa = PADDR(RMBUF); - memset(modebuf, 0, sizeof modebuf); - memset(u, 0, sizeof *u); + jehanne_memset(modebuf, 0, sizeof modebuf); + jehanne_memset(u, 0, sizeof *u); u->ax = ax; u->es = (pa>>4)&0xF000; u->di = pa&0xFFFF; @@ -78,7 +78,7 @@ vbecall(VGAreg *u) pa = PADDR(RMBUF); cmem->dev->write(cmem, modebuf, sizeof modebuf, pa); u->trap = 0x10; - print("vbecall: sizeof u is %d\n", sizeof *u); + jehanne_print("vbecall: sizeof u is %d\n", sizeof *u); creg->dev->write(creg, u, sizeof *u, 0); creg->dev->read(creg, u, sizeof *u, 0); @@ -99,9 +99,9 @@ vbecheck(void) uint8_t *p; p = vbesetup(&u, 0x4F00); - strcpy((char*)p, "VBE2"); + jehanne_strcpy((char*)p, "VBE2"); vbecall(&u); - if(memcmp((char*)p, "VESA", 4) != 0) + if(jehanne_memcmp((char*)p, "VESA", 4) != 0) error("bad vesa signature"); if(p[5] < 2) error("bad vesa version"); @@ -221,7 +221,7 @@ vesaflush(VGAscr *scr, Rectangle r) sp += off; esp = sp + Dy(r) * wid; while(sp < esp){ - memmove(hp, sp, w); + jehanne_memmove(hp, sp, w); hp += wid; sp += wid; } diff --git a/sys/src/kern/amd64/acpi.c b/sys/src/kern/amd64/acpi.c index 4d1802a..683a6fa 100644 --- a/sys/src/kern/amd64/acpi.c +++ b/sys/src/kern/amd64/acpi.c @@ -57,9 +57,9 @@ sigscan(uint8_t* addr, int len, char* signature) uint8_t *e, *p; e = addr+len; - sl = strlen(signature); + sl = jehanne_strlen(signature); for(p = addr; p+sl < e; p += 16) - if(memcmp(p, signature, sl) == 0) + if(jehanne_memcmp(p, signature, sl) == 0) return p; return nil; } @@ -98,7 +98,7 @@ sigsearch(char* signature) * (but will actually check 0xe0000 to 0xfffff). */ bda = KADDR(0x400); - if(memcmp(KADDR(0xfffd9), "EISA", 4) == 0){ + if(jehanne_memcmp(KADDR(0xfffd9), "EISA", 4) == 0){ if((p = (bda[0x0f]<<8)|bda[0x0e]) != 0){ if((r = sigscan(KADDR(p<<4), 1024, signature)) != nil) return r; @@ -159,7 +159,7 @@ acpigettbl(void *sig) { int i; for(i=0; isig, sig, 4) == 0) + if(jehanne_memcmp(tblmap[i]->sig, sig, 4) == 0) return tblmap[i]; return nil; } @@ -204,15 +204,15 @@ acpimaptbl(uint64_t xpa) p = (uint8_t*)t; e = p + l; - if(memcmp("RSDT", t->sig, 4) == 0){ + if(jehanne_memcmp("RSDT", t->sig, 4) == 0){ for(p = t->data; p+3 < e; p += 4) acpimaptbl(get32(p)); } - else if(memcmp("XSDT", t->sig, 4) == 0){ + else if(jehanne_memcmp("XSDT", t->sig, 4) == 0){ for(p = t->data; p+7 < e; p += 8) acpimaptbl(get64(p)); } - else if(memcmp("FACP", t->sig, 4) == 0){ + else if(jehanne_memcmp("FACP", t->sig, 4) == 0){ if(l < 44) return; acpimaptbl(get32(p + 40)); @@ -229,9 +229,9 @@ rsdscan(uint8_t* addr, int len, char* signature) uint8_t *e, *p; e = addr+len; - sl = strlen(signature); + sl = jehanne_strlen(signature); for(p = addr; p+sl < e; p += 16){ - if(memcmp(p, signature, sl)) + if(jehanne_memcmp(p, signature, sl)) continue; return p; } @@ -251,7 +251,7 @@ rsdsearch(char* signature) * 1) in the first KB of the EBDA; * 2) in the BIOS ROM between 0xE0000 and 0xFFFFF. */ - if(strncmp((char*)KADDR(0xFFFD9), "EISA", 4) == 0){ + if(jehanne_strncmp((char*)KADDR(0xFFFD9), "EISA", 4) == 0){ bda = BIOSSEG(0x40); if((p = (bda[0x0F]<<8)|bda[0x0E])){ if(rsd = rsdscan(KADDR(p), 1024, signature)) @@ -307,30 +307,30 @@ apicmkintr(uint32_t src, uint32_t inttype, int polarity, int trigger, uint32_t a */ if(apicno != 0xff){ if(Napic < 256 && apicno >= Napic){ - print("apic: id out-of-range: %d\n", apicno); + jehanne_print("apic: id out-of-range: %d\n", apicno); return 0; } switch(src){ default: - print("apic: intin botch: %d\n", intin); + jehanne_print("apic: intin botch: %d\n", intin); return 0; case Iointr: if((ioapic = ioapiclookup(apicno)) == nil){ - print("ioapic%d: ioapic unusable\n", apicno); + jehanne_print("ioapic%d: ioapic unusable\n", apicno); return 0; } if(intin >= ioapic->nrdt){ - print("ioapic%d: intin %d >= nrdt %d\n", apicno, intin, ioapic->nrdt); + jehanne_print("ioapic%d: intin %d >= nrdt %d\n", apicno, intin, ioapic->nrdt); return 0; } break; case Lintr: if((lapic = lapiclookup(apicno)) == nil){ - print("lapic%d: lapic unusable\n", apicno); + jehanne_print("lapic%d: lapic unusable\n", apicno); return 0; } if(intin >= nelem(lapic->lvt)){ - print("lapic%d: intin beyond lvt: %d\n", apicno, intin); + jehanne_print("lapic%d: intin beyond lvt: %d\n", apicno, intin); return 0; } USED(lapic); @@ -349,7 +349,7 @@ apicmkintr(uint32_t src, uint32_t inttype, int polarity, int trigger, uint32_t a v = Im; switch(inttype){ default: - print("apic: bad irq type %d\n", inttype); + jehanne_print("apic: bad irq type %d\n", inttype); return 0; case MTint: /* INT (fake type, same as fixed) */ v |= polarity | trigger; @@ -423,7 +423,7 @@ addirq(int gsi, int bustype, int busno, int irq, int flags) polarity = flagstopolarity(bustype, flags); trigger = flagstotrigger(bustype, flags); if(polarity == -1 || trigger == -1){ - print("addirq: bad polarity: gsi %d %s busno %d irq %d flags %.8ux\n", + jehanne_print("addirq: bad polarity: gsi %d %s busno %d irq %d flags %.8ux\n", gsi, bustype == BusPCI? "pci": "isa", busno, irq, flags); return; } @@ -471,7 +471,7 @@ pcibusno(void *dot) return -1; adr = amlint(p); /* if root bridge, then we are done here */ - if(id != nil && (strcmp(id, "PNP0A03")==0 || strcmp(id, "PNP0A08")==0)) + if(id != nil && (jehanne_strcmp(id, "PNP0A03")==0 || jehanne_strcmp(id, "PNP0A08")==0)) return adr; x = amlwalk(dot, "^"); if(x == nil || x == dot) @@ -494,7 +494,7 @@ getirqs(void *d, uint8_t pmask[32], int *pflags) uint8_t *p; *pflags = 0; - memset(pmask, 0, 32); + jehanne_memset(pmask, 0, 32); if(amltag(d) != 'b') return -1; p = amlval(d); @@ -528,7 +528,7 @@ setirq(void *d, uint32_t irq) if(amltag(d) != 'b') return nil; p = amlnew('b', amllen(d)); - memmove(p, d, amllen(p)); + jehanne_memmove(p, d, amllen(p)); if(p[0] == 0x22 || p[0] == 0x23) put16(p, 1<sig, name, 4) == 0){ + if(jehanne_memcmp(t->sig, name, 4) == 0){ amlload(t->data, tbldlen(t)); if(!all) break; @@ -666,7 +666,7 @@ readtbls(Chan* _1, void *v, long n, int64_t o) m = l - o; if(m > n) m = n; - memmove(p, (uint8_t*)t + o, m); + jehanne_memmove(p, (uint8_t*)t + o, m); p += m; n -= m; o = 0; @@ -719,7 +719,7 @@ parseapic(Tbl *t, Parsedat *dat) addirq(get32(p+4), BusISA, 0, p[3], get16(p+8)); break; case 0x03: /* NMI Source */ - print("acpi: ignoring nmi source\n"); + jehanne_print("acpi: ignoring nmi source\n"); break; case 0x04: /* Local APIC NMI */ DBG("acpi: lapic nmi %.2ux flags %.4ux lint# %d (ignored)\n", @@ -733,7 +733,7 @@ parseapic(Tbl *t, Parsedat *dat) case 0x0A: /* x2APIC NMI */ case 0x0B: /* GIC */ case 0x0C: /* GICD */ - print("acpi: ignoring entry: %.2ux\n", *p); + jehanne_print("acpi: ignoring entry: %.2ux\n", *p); break; } } @@ -769,7 +769,7 @@ parsesrat(Tbl *t, Parsedat* _1) lapicsetdom(get32(p+8), get32(p+4)); break; default: - print("acpi: SRAT type %.2ux unknown\n", p[0]); + jehanne_print("acpi: SRAT type %.2ux unknown\n", p[0]); break; } } @@ -794,25 +794,25 @@ Gfmt(Fmt* f) case CmosSpace: case PcibarSpace: case IpmiSpace: - fmtprint(f, "[%s", regnames[g->spc]); + jehanne_fmtprint(f, "[%s", regnames[g->spc]); break; case PcicfgSpace: - fmtprint(f, "[pci %T", (int)g->addr); + jehanne_fmtprint(f, "[pci %T", (int)g->addr); break; // case FixedhwSpace: // undeclared -// fmtprint(f, "[hw"); +// jehanne_fmtprint(f, "[hw"); // break; default: - fmtprint(f, "[%#ux", g->spc); + jehanne_fmtprint(f, "[%#ux", g->spc); break; } - fmtprint(f, " %#llux", g->addr); + jehanne_fmtprint(f, " %#llux", g->addr); if(g->off != 0) - fmtprint(f, "+%d", g->off); - fmtprint(f, " len %d", g->len); + jehanne_fmtprint(f, "+%d", g->off); + jehanne_fmtprint(f, " len %d", g->len); if(g->accsz != 0) - fmtprint(f, " accsz %d", g->accsz); - return fmtprint(f, "]"); + jehanne_fmtprint(f, " accsz %d", g->accsz); + return jehanne_fmtprint(f, "]"); } static void @@ -840,68 +840,68 @@ readfadt(Chan* _1, void *a, long n, int64_t o) s = smalloc(READSTR); if(waserror()){ - free(s); + jehanne_free(s); nexterror(); } p = s; e = s+READSTR; f = &fadt; - p = seprint(p, e, "facs %#ux\n", f->facs); - p = seprint(p, e, "dsdt %#ux\n", f->dsdt); - p = seprint(p, e, "pmprofile %#ux\n", f->pmprofile); - p = seprint(p, e, "sciint %d\n", f->sciint); - p = seprint(p, e, "smicmd %#ux\n", f->smicmd); - p = seprint(p, e, "acpienable %#ux\n", f->acpienable); - p = seprint(p, e, "acpidisable %#ux\n", f->acpidisable); - p = seprint(p, e, "s4biosreq %#ux\n", f->s4biosreq); - p = seprint(p, e, "pstatecnt %#ux\n", f->pstatecnt); - p = seprint(p, e, "pm1aevtblk %#ux\n", f->pm1aevtblk); - p = seprint(p, e, "pm1bevtblk %#ux\n", f->pm1bevtblk); - p = seprint(p, e, "pm1acntblk %#ux\n", f->pm1acntblk); - p = seprint(p, e, "pm1bcntblk %#ux\n", f->pm1bcntblk); - p = seprint(p, e, "pm2cntblk %#ux\n", f->pm2cntblk); - p = seprint(p, e, "pmtmrblk %#ux\n", f->pmtmrblk); - p = seprint(p, e, "gpe0blk %#ux\n", f->gpe0blk); - p = seprint(p, e, "gpe1blk %#ux\n", f->gpe1blk); - p = seprint(p, e, "pm1evtlen %#ux\n", f->pm1evtlen); - p = seprint(p, e, "pm1cntlen %#ux\n", f->pm1cntlen); - p = seprint(p, e, "pm2cntlen %#ux\n", f->pm2cntlen); - p = seprint(p, e, "pmtmrlen %#ux\n", f->pmtmrlen); - p = seprint(p, e, "gpe0blklen %#ux\n", f->gpe0blklen); - p = seprint(p, e, "gpe1blklen %#ux\n", f->gpe1blklen); - p = seprint(p, e, "gp1base %#ux\n", f->gp1base); - p = seprint(p, e, "cstcnt %#ux\n", f->cstcnt); - p = seprint(p, e, "plvl2lat %#ux\n", f->plvl2lat); - p = seprint(p, e, "plvl3lat %#ux\n", f->plvl3lat); - p = seprint(p, e, "flushsz %#ux\n", f->flushsz); - p = seprint(p, e, "flushstride %#ux\n", f->flushstride); - p = seprint(p, e, "dutyoff %#ux\n", f->dutyoff); - p = seprint(p, e, "dutywidth %#ux\n", f->dutywidth); - p = seprint(p, e, "dayalrm %#ux\n", f->dayalrm); - p = seprint(p, e, "monalrm %#ux\n", f->monalrm); - p = seprint(p, e, "century %#ux\n", f->century); - p = seprint(p, e, "iapcbootarch %#ux\n", f->iapcbootarch); - p = seprint(p, e, "flags %#ux\n", f->flags); - p = seprint(p, e, "resetreg %G\n", &f->resetreg); + p = jehanne_seprint(p, e, "facs %#ux\n", f->facs); + p = jehanne_seprint(p, e, "dsdt %#ux\n", f->dsdt); + p = jehanne_seprint(p, e, "pmprofile %#ux\n", f->pmprofile); + p = jehanne_seprint(p, e, "sciint %d\n", f->sciint); + p = jehanne_seprint(p, e, "smicmd %#ux\n", f->smicmd); + p = jehanne_seprint(p, e, "acpienable %#ux\n", f->acpienable); + p = jehanne_seprint(p, e, "acpidisable %#ux\n", f->acpidisable); + p = jehanne_seprint(p, e, "s4biosreq %#ux\n", f->s4biosreq); + p = jehanne_seprint(p, e, "pstatecnt %#ux\n", f->pstatecnt); + p = jehanne_seprint(p, e, "pm1aevtblk %#ux\n", f->pm1aevtblk); + p = jehanne_seprint(p, e, "pm1bevtblk %#ux\n", f->pm1bevtblk); + p = jehanne_seprint(p, e, "pm1acntblk %#ux\n", f->pm1acntblk); + p = jehanne_seprint(p, e, "pm1bcntblk %#ux\n", f->pm1bcntblk); + p = jehanne_seprint(p, e, "pm2cntblk %#ux\n", f->pm2cntblk); + p = jehanne_seprint(p, e, "pmtmrblk %#ux\n", f->pmtmrblk); + p = jehanne_seprint(p, e, "gpe0blk %#ux\n", f->gpe0blk); + p = jehanne_seprint(p, e, "gpe1blk %#ux\n", f->gpe1blk); + p = jehanne_seprint(p, e, "pm1evtlen %#ux\n", f->pm1evtlen); + p = jehanne_seprint(p, e, "pm1cntlen %#ux\n", f->pm1cntlen); + p = jehanne_seprint(p, e, "pm2cntlen %#ux\n", f->pm2cntlen); + p = jehanne_seprint(p, e, "pmtmrlen %#ux\n", f->pmtmrlen); + p = jehanne_seprint(p, e, "gpe0blklen %#ux\n", f->gpe0blklen); + p = jehanne_seprint(p, e, "gpe1blklen %#ux\n", f->gpe1blklen); + p = jehanne_seprint(p, e, "gp1base %#ux\n", f->gp1base); + p = jehanne_seprint(p, e, "cstcnt %#ux\n", f->cstcnt); + p = jehanne_seprint(p, e, "plvl2lat %#ux\n", f->plvl2lat); + p = jehanne_seprint(p, e, "plvl3lat %#ux\n", f->plvl3lat); + p = jehanne_seprint(p, e, "flushsz %#ux\n", f->flushsz); + p = jehanne_seprint(p, e, "flushstride %#ux\n", f->flushstride); + p = jehanne_seprint(p, e, "dutyoff %#ux\n", f->dutyoff); + p = jehanne_seprint(p, e, "dutywidth %#ux\n", f->dutywidth); + p = jehanne_seprint(p, e, "dayalrm %#ux\n", f->dayalrm); + p = jehanne_seprint(p, e, "monalrm %#ux\n", f->monalrm); + p = jehanne_seprint(p, e, "century %#ux\n", f->century); + p = jehanne_seprint(p, e, "iapcbootarch %#ux\n", f->iapcbootarch); + p = jehanne_seprint(p, e, "flags %#ux\n", f->flags); + p = jehanne_seprint(p, e, "resetreg %G\n", &f->resetreg); if(f->rev >= 3){ - p = seprint(p, e, "resetval %#ux\n", f->resetval); - p = seprint(p, e, "xfacs %#llux\n", f->xfacs); - p = seprint(p, e, "xdsdt %#llux\n", f->xdsdt); - p = seprint(p, e, "xpm1aevtblk %G\n", &f->xpm1aevtblk); - p = seprint(p, e, "xpm1bevtblk %G\n", &f->xpm1bevtblk); - p = seprint(p, e, "xpm1acntblk %G\n", &f->xpm1acntblk); - p = seprint(p, e, "xpm1bcntblk %G\n", &f->xpm1bcntblk); - p = seprint(p, e, "xpm2cntblk %G\n", &f->xpm2cntblk); - p = seprint(p, e, "xpmtmrblk %G\n", &f->xpmtmrblk); - p = seprint(p, e, "xgpe0blk %G\n", &f->xgpe0blk); - p = seprint(p, e, "xgpe1blk %G\n", &f->xgpe1blk); + p = jehanne_seprint(p, e, "resetval %#ux\n", f->resetval); + p = jehanne_seprint(p, e, "xfacs %#llux\n", f->xfacs); + p = jehanne_seprint(p, e, "xdsdt %#llux\n", f->xdsdt); + p = jehanne_seprint(p, e, "xpm1aevtblk %G\n", &f->xpm1aevtblk); + p = jehanne_seprint(p, e, "xpm1bevtblk %G\n", &f->xpm1bevtblk); + p = jehanne_seprint(p, e, "xpm1acntblk %G\n", &f->xpm1acntblk); + p = jehanne_seprint(p, e, "xpm1bcntblk %G\n", &f->xpm1bcntblk); + p = jehanne_seprint(p, e, "xpm2cntblk %G\n", &f->xpm2cntblk); + p = jehanne_seprint(p, e, "xpmtmrblk %G\n", &f->xpmtmrblk); + p = jehanne_seprint(p, e, "xgpe0blk %G\n", &f->xgpe0blk); + p = jehanne_seprint(p, e, "xgpe1blk %G\n", &f->xgpe1blk); } USED(p); n = readstr(o, a, n, s); poperror(); - free(s); + jehanne_free(s); return n; } @@ -1028,7 +1028,7 @@ parsemcfg(Tbl *t, Parsedat* _1) mc->pciseg = get16(p+8); mc->start = p[10]; mc->end = p[11]; -print("MCFG: %d-%d %d %#P\n", mc->start, mc->end, mc->pciseg, mc->base); +jehanne_print("MCFG: %d-%d %d %#P\n", mc->start, mc->end, mc->pciseg, mc->base); } } @@ -1090,16 +1090,16 @@ parsetables(Parsedat *dat) Tbl *t; Ptab *p; - print("acpi parse: "); + jehanne_print("acpi parse: "); for(i = 0; i < nelem(ptab); i++){ p = ptab + i; if((t = acpigettbl(p->sig)) != nil){ p->parse(t, dat); - print("%s ", p->sig); + jehanne_print("%s ", p->sig); }else if(p->required) panic("acpi: parsetables: no %s table\n", p->sig); } - print("\n"); + jehanne_print("\n"); } int @@ -1116,7 +1116,7 @@ checkpnpid(void *dot, char *pnpid) id = eisaid(p); if(id == nil) return -1; - return strcmp(id, pnpid); + return jehanne_strcmp(id, pnpid); } enum { @@ -1151,7 +1151,7 @@ evalini(void *dot) return -1; if((x = amlwalk(dot, "_INI")) != nil){ if(amleval(x, "", &p) == 0) - print("eval _INI → %V\n", p); + jehanne_print("eval _INI → %V\n", p); } return 0; } @@ -1164,9 +1164,9 @@ cfgpwerb(void) dot = amlwalk(amlroot, "\\_SB_.PWRB"); if(checkpnpid(dot, "PNP0C0C") != 0) return 0; -// print("PWRB %V\n", dot); +// jehanne_print("PWRB %V\n", dot); if(evalini(dot) == -1){ - print("PWRB evalini fails\n"); + jehanne_print("PWRB evalini fails\n"); return 0; } return 1; @@ -1187,7 +1187,7 @@ cfgsleep(void) /* look for the proper ones */ for(i = 0; i < 6; i++){ t = acpicfg.sval[i]; - snprint(buf, sizeof buf, "\\_S%d_", i); + jehanne_snprint(buf, sizeof buf, "\\_S%d_", i); v = amlval(amlwalk(amlroot, buf)); if(v != nil && amltag(v) == 'p' && amllen(v) == 4){ t[0] = amlint(v[0]); @@ -1202,14 +1202,14 @@ acpiinit(int maxmach) int i; Parsedat dat; - print("acpiinit\n"); - fmtinstall('G', Gfmt); + jehanne_print("acpiinit\n"); + jehanne_fmtinstall('G', Gfmt); maptables(); amlinit(); loadtbls("DSDT", 0); loadtbls("SSDT", 1); - memset(&dat, 0, sizeof dat); + jehanne_memset(&dat, 0, sizeof dat); dat.maxmach = maxmach; parsetables(&dat); if(fadt.smicmd != 0) @@ -1224,10 +1224,10 @@ acpiinit(int maxmach) addarchfile("acpifadt", 0444, readfadt, nil); /* hack */ addarchfile("acpitbls", 0444, readtbls, nil); if(1||DBGFLG){ - print("acpi load: "); + jehanne_print("acpi load: "); for(i = 0; i < ntblmap; i++) - print("%.4s ", (char*)tblmap[i]->sig); - print("\n"); + jehanne_print("%.4s ", (char*)tblmap[i]->sig); + jehanne_print("\n"); } lapicdump(); iordtdump(); diff --git a/sys/src/kern/amd64/archamd64.c b/sys/src/kern/amd64/archamd64.c index f38afa6..942b878 100644 --- a/sys/src/kern/amd64/archamd64.c +++ b/sys/src/kern/amd64/archamd64.c @@ -18,7 +18,7 @@ cpuidinit(void) return 0; m->ncpuinfos++; - if(memcmp(&m->cpuinfo[0][1], "GenuntelineI", 12) == 0) + if(jehanne_memcmp(&m->cpuinfo[0][1], "GenuntelineI", 12) == 0) m->isintelcpu = 1; cpuid(1, 0, m->cpuinfo[1]); @@ -56,7 +56,7 @@ cpuidhz(uint32_t info[2][4]) int64_t hz; uint64_t msr; - if(memcmp(&info[0][1], "GenuntelineI", 12) == 0){ + if(jehanne_memcmp(&info[0][1], "GenuntelineI", 12) == 0){ switch(info[1][0] & 0x0fff3ff0){ default: return 0; @@ -157,7 +157,7 @@ cpuidhz(uint32_t info[2][4]) } DBG("cpuidhz: 0x2a: %#llux hz %lld\n", rdmsr(0x2a), hz); } - else if(memcmp(&info[0][1], "AuthcAMDenti", 12) == 0){ + else if(jehanne_memcmp(&info[0][1], "AuthcAMDenti", 12) == 0){ switch(info[1][0] & 0x0fff0ff0){ default: return 0; @@ -307,9 +307,9 @@ fmtP(Fmt* f) pa = va_arg(f->args, uintmem); if(f->flags & FmtSharp) - return fmtprint(f, "%#16.16llux", pa); + return jehanne_fmtprint(f, "%#16.16llux", pa); - return fmtprint(f, "%llud", pa); + return jehanne_fmtprint(f, "%llud", pa); } static int @@ -319,7 +319,7 @@ fmtL(Fmt* f) pl = va_arg(f->args, Mpl); - return fmtprint(f, "%#16.16llux", pl); + return jehanne_fmtprint(f, "%#16.16llux", pl); } static int @@ -329,7 +329,7 @@ fmtR(Fmt* f) r = va_arg(f->args, uint64_t); - return fmtprint(f, "%#16.16llux", r); + return jehanne_fmtprint(f, "%#16.16llux", r); } /* virtual address fmt */ @@ -339,7 +339,7 @@ fmtW(Fmt *f) uint64_t va; va = va_arg(f->args, uint64_t); - return fmtprint(f, "%#ullx=0x[%ullx][%ullx][%ullx][%ullx][%ullx]", va, + return jehanne_fmtprint(f, "%#ullx=0x[%ullx][%ullx][%ullx][%ullx][%ullx]", va, PTLX(va, 3), PTLX(va, 2), PTLX(va, 1), PTLX(va, 0), va & ((1<r, memblack, ZP, nil, ZP, S); flushmemscreen(gscreen->r); @@ -139,7 +139,7 @@ screenaperture(int size, int align) * The driver will tell the card to use it. */ size = ROUNDUP(sizeof(size), 4*KiB); - scr->paddr = (uint64_t)malloc(size); + scr->paddr = (uint64_t)jehanne_malloc(size); if(scr->paddr == 0) return -1; scr->vaddr = vmap(scr->paddr, size); @@ -219,7 +219,7 @@ flushmemscreen(Rectangle r) scr->dev->page(scr, page); for(y = r.min.y; y < r.max.y; y++) { if(sdisp + incs < edisp) { - memmove(sdisp, sp, len); + jehanne_memmove(sdisp, sp, len); sp += incs; sdisp += incs; } @@ -228,13 +228,13 @@ flushmemscreen(Rectangle r) page++; if(off <= len){ if(off > 0) - memmove(sdisp, sp, off); + jehanne_memmove(sdisp, sp, off); scr->dev->page(scr, page); if(len - off > 0) - memmove(disp, sp+off, len - off); + jehanne_memmove(disp, sp+off, len - off); } else { - memmove(sdisp, sp, len); + jehanne_memmove(sdisp, sp, len); scr->dev->page(scr, page); } sp += incs; @@ -645,7 +645,7 @@ swcursorinit(void) if(scr->dev == nil || scr->dev->linear == nil){ if(!warned){ - print("cannot use software cursor on non-linear vga screen\n"); + jehanne_print("cannot use software cursor on non-linear vga screen\n"); warned = 1; } return; @@ -665,7 +665,7 @@ swcursorinit(void) swimg = allocmemimage(Rect(0,0,16,16), GREY8); swimg1 = allocmemimage(Rect(0,0,16,16), GREY1); if(swback==nil || swmask==nil || swmask1==nil || swimg==nil || swimg1 == nil){ - print("software cursor: allocmemimage fails"); + jehanne_print("software cursor: allocmemimage fails"); return; } diff --git a/sys/src/kern/amd64/cga.c b/sys/src/kern/amd64/cga.c index ab99eda..c314726 100644 --- a/sys/src/kern/amd64/cga.c +++ b/sys/src/kern/amd64/cga.c @@ -113,7 +113,7 @@ cgaputc(int c) cga[cgapos++] = Attr; } if(cgapos >= (Width*Height)-Postlen*2){ - memmove(cga, &cga[Width], Width*(Height-1)); + jehanne_memmove(cga, &cga[Width], Width*(Height-1)); p = &cga[Width*(Height-1)-Postlen*2]; for(i = 0; i < Width/2; i++){ *p++ = ' '; @@ -133,7 +133,7 @@ cgaprint(int off, char *fmt, ...) int i, n; va_start(va, fmt); - n = vsnprint(buf, sizeof buf, fmt, va); + n = jehanne_vsnprint(buf, sizeof buf, fmt, va); va_end(va); cga = CGA; @@ -214,7 +214,7 @@ cgaread(Chan* c, void *vbuf, long len, int64_t off) if(off+len > Cgasize) len = Cgasize - off; cga = CGA; - memmove(vbuf, cga + off, len); + jehanne_memmove(vbuf, cga + off, len); return len; } @@ -230,7 +230,7 @@ cgawrite(Chan* c, void *vbuf, long len, int64_t off) if(off+len > Cgasize) len = Cgasize - off; cga = CGA; - memmove(cga + off, vbuf, len); + jehanne_memmove(cga + off, vbuf, len); return len; } diff --git a/sys/src/kern/amd64/dat.h b/sys/src/kern/amd64/dat.h index 21f9e55..7ae0376 100644 --- a/sys/src/kern/amd64/dat.h +++ b/sys/src/kern/amd64/dat.h @@ -373,4 +373,4 @@ register Proc* up asm("r14"); extern char dbgflg[256]; -#define dbgprint print /* for now */ +#define dbgprint jehanne_print /* for now */ diff --git a/sys/src/kern/amd64/devacpi.c b/sys/src/kern/amd64/devacpi.c index c63ca93..1b420d9 100644 --- a/sys/src/kern/amd64/devacpi.c +++ b/sys/src/kern/amd64/devacpi.c @@ -126,7 +126,7 @@ getbanked(int ra, int rb, int sz) r |= inl(rb); break; default: - print("getbanked: wrong size\n"); + jehanne_print("getbanked: wrong size\n"); } return r; } @@ -157,7 +157,7 @@ setbanked(int ra, int rb, int sz, int v) outl(rb, v); break; default: - print("setbanked: wrong size\n"); + jehanne_print("setbanked: wrong size\n"); } return r; } @@ -294,7 +294,7 @@ acpiintr(Ureg* _1, void* _2) setgpeen(i, 0); clrgpests(i); if(en != 0) - print("acpinitr: calling gpe %d\n", i); + jehanne_print("acpinitr: calling gpe %d\n", i); /* queue gpe. reenable after done */ } sts = getpm1sts(); /* § 4.8.3.3.1 */ @@ -319,7 +319,7 @@ initgpes(void) n0 = fadt.gpe0blklen/2; n1 = fadt.gpe1blklen/2; ngpe = n0 + n1; - gpes = mallocz(sizeof(Gpe) * ngpe, 1); + gpes = jehanne_mallocz(sizeof(Gpe) * ngpe, 1); for(i = 0; i < n0; i++){ gpes[i].nb = i; gpes[i].stsbit = i&7; @@ -346,7 +346,7 @@ acpiioalloc(uint32_t addr, int len, char *name) char buf[32]; if(addr != 0){ - snprint(buf, sizeof buf, "acpi %s", name); + jehanne_snprint(buf, sizeof buf, "acpi %s", name); ioalloc(addr, len, 0, buf); } } @@ -381,7 +381,7 @@ init(void) outb(fadt.smicmd, fadt.acpienable); for(i = 0;; i++){ if(i == 10){ - print("acpi: failed to enable\n"); + jehanne_print("acpi: failed to enable\n"); outb(fadt.smicmd, fadt.acpidisable); return; } @@ -391,7 +391,7 @@ init(void) } if(0){ - print("acpi: enable interrupt\n"); + jehanne_print("acpi: enable interrupt\n"); setpm1sts(getpm1sts()); setpm1en(Epowerbtn); intrenable(fadt.sciint, acpiintr, 0, BUSUNKNOWN, "acpi"); @@ -476,8 +476,8 @@ acpiread(Chan *c, void *a, long n, int64_t off) s = "??"; else s = pwrbuttab[i].name; - p = seprint(p, e, "powerbutton %s\n", s); - p = seprint(p, e, "ngpe %d\n", ngpe); + p = jehanne_seprint(p, e, "powerbutton %s\n", s); + p = jehanne_seprint(p, e, "ngpe %d\n", ngpe); USED(p); return readstr(off, a, n, buf); @@ -500,13 +500,13 @@ acpiwrite(Chan *c, void *a, long n, int64_t _1) cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, ctls, nelem(ctls)); switch(ct->index){ case CMgpe: - i = strtoul(cb->f[1], nil, 0); + i = jehanne_strtoul(cb->f[1], nil, 0); if(i >= ngpe) error("gpe out of range"); kstrdup(&gpes[i].obj, cb->f[2]); @@ -515,7 +515,7 @@ acpiwrite(Chan *c, void *a, long n, int64_t _1) break; case CMpowerbut: for(i = 0; i < nelem(pwrbuttab); i++) - if(strcmp(cb->f[1], pwrbuttab[i].name) == 0){ + if(jehanne_strcmp(cb->f[1], pwrbuttab[i].name) == 0){ ilock(&aconf); aconf.powerbutton = pwrbuttab[i].f; iunlock(&aconf); @@ -525,14 +525,14 @@ acpiwrite(Chan *c, void *a, long n, int64_t _1) error("unknown power button action"); break; case CMpower: - if(strcmp(cb->f[1], "off") == 0) + if(jehanne_strcmp(cb->f[1], "off") == 0) aconf.powerbutton(); else error("unknown power button command"); break; } poperror(); - free(cb); + jehanne_free(cb); return n; } diff --git a/sys/src/kern/amd64/devarch.c b/sys/src/kern/amd64/devarch.c index ccbd91c..79b16d4 100644 --- a/sys/src/kern/amd64/devarch.c +++ b/sys/src/kern/amd64/devarch.c @@ -68,19 +68,19 @@ addarchfile(char *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn) Dirtab d; Dirtab *dp; - memset(&d, 0, sizeof d); - strcpy(d.name, name); + jehanne_memset(&d, 0, sizeof d); + jehanne_strcpy(d.name, name); d.perm = perm; lock(&archwlock); if(narchdir >= Qmax){ unlock(&archwlock); - print("addarchfile: out of entries for %s\n", name); + jehanne_print("addarchfile: out of entries for %s\n", name); return nil; } for(i=0; istart = port; map->end = port + size; map->reserved = 1; - strncpy(map->tag, tag, sizeof(map->tag)); + jehanne_strncpy(map->tag, tag, sizeof(map->tag)); map->tag[sizeof(map->tag)-1] = 0; *l = map; @@ -243,7 +243,7 @@ ioalloc(int port, int size, int align, char *tag) } map = iomap.free; if(map == nil){ - print("ioalloc: out of maps"); + jehanne_print("ioalloc: out of maps"); unlock(&iomap); return port; } @@ -251,7 +251,7 @@ ioalloc(int port, int size, int align, char *tag) map->next = *l; map->start = port; map->end = port + size; - strncpy(map->tag, tag, sizeof(map->tag)); + jehanne_strncpy(map->tag, tag, sizeof(map->tag)); map->tag[sizeof(map->tag)-1] = 0; *l = map; @@ -402,7 +402,7 @@ archread(Chan *c, void *a, long n, int64_t offset) break; } - if((buf = malloc(n)) == nil) + if((buf = jehanne_malloc(n)) == nil) error(Enomem); p = buf; n = n/Linelen; @@ -412,15 +412,15 @@ archread(Chan *c, void *a, long n, int64_t offset) for(map = iomap.map; n > 0 && map != nil; map = map->next){ if(offset-- > 0) continue; - sprint(p, "%#8lux %#8lux %-12.12s\n", map->start, map->end-1, map->tag); + jehanne_sprint(p, "%#8lux %#8lux %-12.12s\n", map->start, map->end-1, map->tag); p += Linelen; n--; } unlock(&iomap); n = p - buf; - memmove(a, buf, n); - free(buf); + jehanne_memmove(a, buf, n); + jehanne_free(buf); return n; } @@ -514,7 +514,7 @@ cputyperead(Chan* _1, void *a, long n, int64_t off) { char str[32]; - snprint(str, sizeof(str), "%s %ud\n", "AMD64", m->cpumhz); + jehanne_snprint(str, sizeof(str), "%s %ud\n", "AMD64", m->cpumhz); return readstr(off, a, n, str); } @@ -522,7 +522,7 @@ static long numcoresread(Chan* c, void *a, long n, int64_t off) { char buf[8]; - snprint(buf, 8, "%d\n", sys->nmach); + jehanne_snprint(buf, 8, "%d\n", sys->nmach); return readstr(off, a, n, buf); } @@ -550,7 +550,7 @@ archreset(void) * The reset register (0xcf9) is usually in one of the bridge * chips. The actual location and sequence could be extracted from * ACPI but why bother, this is the end of the line anyway. - print("Takes a licking and keeps on ticking...\n"); + jehanne_print("Takes a licking and keeps on ticking...\n"); */ *(uint16_t*)KADDR(0x472) = 0x1234; /* BIOS warm-boot flag */ i = inb(0xcf9); /* ICHx reset control */ diff --git a/sys/src/kern/amd64/devkbin.c b/sys/src/kern/amd64/devkbin.c index a7ccf40..06df08b 100644 --- a/sys/src/kern/amd64/devkbin.c +++ b/sys/src/kern/amd64/devkbin.c @@ -60,7 +60,7 @@ kbinclose(Chan *c) if((c->flag & COPEN) == 0) return; if(c->aux){ - free(c->aux); + jehanne_free(c->aux); c->aux = nil; } if(c->qid.path == Qkbd) diff --git a/sys/src/kern/amd64/devvga.c b/sys/src/kern/amd64/devvga.c index 1a552ef..65d1f9e 100644 --- a/sys/src/kern/amd64/devvga.c +++ b/sys/src/kern/amd64/devvga.c @@ -87,7 +87,7 @@ rmemrw(int isr, void *a, long n, int64_t off) return 0; if(off+n >= MB) n = MB - off; - memmove(a, KADDR((uintptr_t)off), n); + jehanne_memmove(a, KADDR((uintptr_t)off), n); }else{ /* realmode buf page ok, allow vga framebuf's access */ if(off >= MB) @@ -102,7 +102,7 @@ rmemrw(int isr, void *a, long n, int64_t off) error("off < 0xa0000"); if (off+n > 0xB0000+0x10000) error("off+n > 0xb0000+0x10000"); - memmove(KADDR((uintptr_t)off), a, n); + jehanne_memmove(KADDR((uintptr_t)off), a, n); } return n; } @@ -133,7 +133,7 @@ vgareset(void) static Chan* vgaattach(Chan *c, Chan *ac, char *spec, int flags) { - if(*spec && strcmp(spec, "0")) + if(*spec && jehanne_strcmp(spec, "0")) error(Eio); return devattach('v', spec); } @@ -159,7 +159,7 @@ vgaopen(Chan* c, unsigned long omode) scr = &vgascreen[0]; if ((uint32_t)c->qid.path == Qvgaovlctl) { if (scr->dev && scr->dev->ovlctl) - scr->dev->ovlctl(scr, c, openctl, strlen(openctl)); + scr->dev->ovlctl(scr, c, openctl, jehanne_strlen(openctl)); else error(Enonexist); } @@ -176,10 +176,10 @@ vgaclose(Chan* c) if((uint32_t)c->qid.path == Qvgaovlctl) if(scr->dev && scr->dev->ovlctl){ if(waserror()){ - print("ovlctl error: %s\n", up->errstr); + jehanne_print("ovlctl error: %s\n", up->errstr); return; } - scr->dev->ovlctl(scr, c, closectl, strlen(closectl)); + scr->dev->ovlctl(scr, c, closectl, jehanne_strlen(closectl)); poperror(); } } @@ -203,17 +203,17 @@ vgaread(Chan* c, void* a, long n, int64_t off) return 0; if(offset+n >= 0x100000) n = 0x100000 - offset; - memmove(a, (unsigned char*)KADDR(0)+offset, n); + jehanne_memmove(a, (unsigned char*)KADDR(0)+offset, n); return n; case Qvgactl: scr = &vgascreen[0]; - p = malloc(READSTR); + p = jehanne_malloc(READSTR); if(p == nil) error(Enomem); if(waserror()){ - free(p); + jehanne_free(p); nexterror(); } @@ -223,30 +223,30 @@ vgaread(Chan* c, void* a, long n, int64_t off) s = scr->dev->name; else s = "cga"; - len += snprint(p+len, READSTR-len, "type %s\n", s); + len += jehanne_snprint(p+len, READSTR-len, "type %s\n", s); if(scr->gscreen) { - len += snprint(p+len, READSTR-len, "size %dx%dx%d %s\n", + len += jehanne_snprint(p+len, READSTR-len, "size %dx%dx%d %s\n", scr->gscreen->r.max.x, scr->gscreen->r.max.y, scr->gscreen->depth, chantostr(chbuf, scr->gscreen->chan)); if(Dx(scr->gscreen->r) != Dx(physgscreenr) || Dy(scr->gscreen->r) != Dy(physgscreenr)) - len += snprint(p+len, READSTR-len, "actualsize %dx%d\n", + len += jehanne_snprint(p+len, READSTR-len, "actualsize %dx%d\n", physgscreenr.max.x, physgscreenr.max.y); } - len += snprint(p+len, READSTR-len, "blank time %lud idle %d state %s\n", + len += jehanne_snprint(p+len, READSTR-len, "blank time %lud idle %d state %s\n", blanktime, drawidletime(), scr->isblank ? "off" : "on"); - len += snprint(p+len, READSTR-len, "hwaccel %s\n", hwaccel ? "on" : "off"); - len += snprint(p+len, READSTR-len, "hwblank %s\n", hwblank ? "on" : "off"); - len += snprint(p+len, READSTR-len, "panning %s\n", panning ? "on" : "off"); - len += snprint(p+len, READSTR-len, "addr p 0x%lux v 0x%p size 0x%ux\n", scr->paddr, scr->vaddr, scr->apsize); + len += jehanne_snprint(p+len, READSTR-len, "hwaccel %s\n", hwaccel ? "on" : "off"); + len += jehanne_snprint(p+len, READSTR-len, "hwblank %s\n", hwblank ? "on" : "off"); + len += jehanne_snprint(p+len, READSTR-len, "panning %s\n", panning ? "on" : "off"); + len += jehanne_snprint(p+len, READSTR-len, "addr p 0x%lux v 0x%p size 0x%ux\n", scr->paddr, scr->vaddr, scr->apsize); USED(len); n = readstr(offset, a, n, p); poperror(); - free(p); + jehanne_free(p); return n; @@ -278,7 +278,7 @@ vgactl(Cmdbuf *cb) ct = lookupcmd(cb, vgactlmsg, nelem(vgactlmsg)); switch(ct->index){ case CMhwgc: - if(strcmp(cb->f[1], "off") == 0){ + if(jehanne_strcmp(cb->f[1], "off") == 0){ lock(&cursor.l); if(scr->cur){ if(scr->cur->disable) @@ -288,7 +288,7 @@ vgactl(Cmdbuf *cb) unlock(&cursor.l); return; } - if(strcmp(cb->f[1], "soft") == 0){ + if(jehanne_strcmp(cb->f[1], "soft") == 0){ lock(&cursor.l); swcursorinit(); if(scr->cur && scr->cur->disable) @@ -300,7 +300,7 @@ vgactl(Cmdbuf *cb) return; } for(i = 0; vgacur[i]; i++){ - if(strcmp(cb->f[1], vgacur[i]->name)) + if(jehanne_strcmp(cb->f[1], vgacur[i]->name)) continue; lock(&cursor.l); if(scr->cur && scr->cur->disable) @@ -315,7 +315,7 @@ vgactl(Cmdbuf *cb) case CMtype: for(i = 0; vgadev[i]; i++){ - if(strcmp(cb->f[1], vgadev[i]->name)) + if(jehanne_strcmp(cb->f[1], vgadev[i]->name)) continue; if(scr->dev && scr->dev->disable) scr->dev->disable(scr); @@ -331,19 +331,19 @@ vgactl(Cmdbuf *cb) return; case CMsize: - x = strtoul(cb->f[1], &p, 0); + x = jehanne_strtoul(cb->f[1], &p, 0); if(x == 0 || x > 10240) error(Ebadarg); if(*p) p++; - y = strtoul(p, &p, 0); + y = jehanne_strtoul(p, &p, 0); if(y == 0 || y > 10240) error(Ebadarg); if(*p) p++; - z = strtoul(p, &p, 0); + z = jehanne_strtoul(p, &p, 0); chanstr = cb->f[2]; if((chan = strtochan(chanstr)) == 0) @@ -365,13 +365,13 @@ vgactl(Cmdbuf *cb) if(scr->gscreen == nil) error("set the screen size first"); - x = strtoul(cb->f[1], &p, 0); + x = jehanne_strtoul(cb->f[1], &p, 0); if(x == 0 || x > 2048) error(Ebadarg); if(*p) p++; - y = strtoul(p, nil, 0); + y = jehanne_strtoul(p, nil, 0); if(y == 0 || y > 2048) error(Ebadarg); @@ -383,7 +383,7 @@ vgactl(Cmdbuf *cb) return; case CMpalettedepth: - x = strtoul(cb->f[1], &p, 0); + x = jehanne_strtoul(cb->f[1], &p, 0); if(x != 8 && x != 6) error(Ebadarg); @@ -400,17 +400,17 @@ vgactl(Cmdbuf *cb) case CMlinear: if(cb->nf!=2 && cb->nf!=3) error(Ebadarg); - size = strtoul(cb->f[1], 0, 0); + size = jehanne_strtoul(cb->f[1], 0, 0); if(cb->nf == 2) align = 0; else - align = strtoul(cb->f[2], 0, 0); + align = jehanne_strtoul(cb->f[2], 0, 0); if(screenaperture(size, align) < 0) error("not enough free address space"); return; /* case CMmemset: - memset((void*)strtoul(cb->f[1], 0, 0), atoi(cb->f[2]), atoi(cb->f[3])); + jehanne_memset((void*)jehanne_strtoul(cb->f[1], 0, 0), jehanne_atoi(cb->f[2]), jehanne_atoi(cb->f[3])); return; */ @@ -423,11 +423,11 @@ vgactl(Cmdbuf *cb) return; case CMblanktime: - blanktime = strtoul(cb->f[1], 0, 0); + blanktime = jehanne_strtoul(cb->f[1], 0, 0); return; case CMpanning: - if(strcmp(cb->f[1], "on") == 0){ + if(jehanne_strcmp(cb->f[1], "on") == 0){ if(scr == nil || scr->cur == nil) error("set screen first"); if(!scr->cur->doespanning) @@ -435,7 +435,7 @@ vgactl(Cmdbuf *cb) scr->gscreen->clipr = scr->gscreen->r; panning = 1; } - else if(strcmp(cb->f[1], "off") == 0){ + else if(jehanne_strcmp(cb->f[1], "off") == 0){ scr->gscreen->clipr = physgscreenr; panning = 0; }else @@ -443,18 +443,18 @@ vgactl(Cmdbuf *cb) return; case CMhwaccel: - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) hwaccel = 1; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) hwaccel = 0; else break; return; case CMhwblank: - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) hwblank = 1; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) hwblank = 0; else break; @@ -483,12 +483,12 @@ vgawrite(Chan* c, void* a, long n, int64_t off) error(Ebadarg); cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } vgactl(cb); poperror(); - free(cb); + jehanne_free(cb); return n; case Qvgaovl: diff --git a/sys/src/kern/amd64/fpu.c b/sys/src/kern/amd64/fpu.c index 53911e6..c6a070b 100644 --- a/sys/src/kern/amd64/fpu.c +++ b/sys/src/kern/amd64/fpu.c @@ -107,12 +107,12 @@ fpudevprocio(Proc* proc, void* a, int32_t n, uintptr_t offset, int write) default: if(offset+n > sizeof(Fxsave)) n = sizeof(Fxsave) - offset; - memmove(p+offset, a, n); + jehanne_memmove(p+offset, a, n); break; case 0: if(offset+n > sizeof(Fxsave)) n = sizeof(Fxsave) - offset; - memmove(a, p+offset, n); + jehanne_memmove(a, p+offset, n); break; } @@ -178,7 +178,7 @@ fpusysrforkchild(Proc* child, Proc* parent) if(child->FPU.fpustate == Init) return; - memmove(child->FPU.fpusave, parent->FPU.fpusave, sizeof(Fxsave)); + jehanne_memmove(child->FPU.fpusave, parent->FPU.fpusave, sizeof(Fxsave)); } void @@ -298,7 +298,7 @@ fpunote(void) else cm = "Unknown"; - snprint(up->genbuf, sizeof(up->genbuf), + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "sys: fp: %s Exception ipo=%#llux fsw=%#ux", cm, fpusave->rip, fsw); return up->genbuf; @@ -348,7 +348,7 @@ xfpuxf(Ureg* ureg, void* v) else cm = "Unknown"; - snprint(up->genbuf, sizeof(up->genbuf), + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "sys: fp: %s Exception mxcsr=%#ux", cm, mxcsr); return up->genbuf; } @@ -524,7 +524,7 @@ fpuinit(void) _fninit(); fxsave = (Fxsave*)((PTR2UINT(buf) + 15) & ~15); - memset(fxsave, 0, sizeof(Fxsave)); + jehanne_memset(fxsave, 0, sizeof(Fxsave)); _fxsave(fxsave); m->FPU.fcw = RCn|PCd|P|U|D; if(fxsave->mxcsrmask == 0) diff --git a/sys/src/kern/amd64/hpet.c b/sys/src/kern/amd64/hpet.c index 899819f..ae2e5ca 100644 --- a/sys/src/kern/amd64/hpet.c +++ b/sys/src/kern/amd64/hpet.c @@ -65,7 +65,7 @@ hpetinit(uint32_t id, uint32_t seqno, uintmem pa, int minticks) int i, n; Hpet *hpet; - print("hpet: id %#ux seqno %d pa %#P minticks %d\n", id, seqno, pa, minticks); + jehanne_print("hpet: id %#ux seqno %d pa %#P minticks %d\n", id, seqno, pa, minticks); if(seqno >= nelem(etb)) return; if((hpet = vmap(pa, 1024)) == nil) /* HPET §3.2.4 */ @@ -73,9 +73,9 @@ hpetinit(uint32_t id, uint32_t seqno, uintmem pa, int minticks) memreserve(pa, 1024); etb[seqno] = hpet; - print("HPET: cap %#8.8ux period %#8.8ux\n", hpet->cap, hpet->period); - print("HPET: cnf %#8.8ux sts %#8.8ux\n",hpet->cnf, hpet->sts); - print("HPET: counter %#.16llux\n", hpet->counter); + jehanne_print("HPET: cap %#8.8ux period %#8.8ux\n", hpet->cap, hpet->period); + jehanne_print("HPET: cnf %#8.8ux sts %#8.8ux\n",hpet->cnf, hpet->sts); + jehanne_print("HPET: counter %#.16llux\n", hpet->counter); n = ((hpet->cap>>8) & 0x0F) + 1; for(i = 0; i < n; i++){ diff --git a/sys/src/kern/amd64/i8254.c b/sys/src/kern/amd64/i8254.c index 03e08bb..0f5c5b2 100644 --- a/sys/src/kern/amd64/i8254.c +++ b/sys/src/kern/amd64/i8254.c @@ -90,7 +90,7 @@ i8254hz(uint32_t info[2][4]) * cycles for the AAM instruction. */ ax = info[1][0] & 0x00000f00; - if(memcmp(&info[0][1], "GenuntelineI", 12) == 0){ + if(jehanne_memcmp(&info[0][1], "GenuntelineI", 12) == 0){ switch(ax){ default: return 0; @@ -100,7 +100,7 @@ i8254hz(uint32_t info[2][4]) break; } } - else if(memcmp(&info[0][1], "AuthcAMDenti", 12) == 0){ + else if(jehanne_memcmp(&info[0][1], "AuthcAMDenti", 12) == 0){ switch(ax){ default: return 0; @@ -110,7 +110,7 @@ i8254hz(uint32_t info[2][4]) break; } } - else if(memcmp(&info[0][1], "CentaulsaurH", 12) == 0){ + else if(jehanne_memcmp(&info[0][1], "CentaulsaurH", 12) == 0){ switch(ax){ default: return 0; diff --git a/sys/src/kern/amd64/ioapic.c b/sys/src/kern/amd64/ioapic.c index 0822282..891c5d3 100644 --- a/sys/src/kern/amd64/ioapic.c +++ b/sys/src/kern/amd64/ioapic.c @@ -60,7 +60,7 @@ ioapicisabus(int busno) if(isabusno != -1){ if(busno == isabusno) return; - print("ioapic: isabus redefined: %d ↛ %d\n", isabusno, busno); + jehanne_print("ioapic: isabus redefined: %d ↛ %d\n", isabusno, busno); // return; } DBG("ioapic: isa busno %d\n", busno); @@ -96,7 +96,7 @@ gsitoapicid(int gsi, uint32_t *intin) return a - xioapic; } } -// print("gsitoapicid: no ioapic found for gsi %d\n", gsi); +// jehanne_print("gsitoapicid: no ioapic found for gsi %d\n", gsi); return -1; } @@ -157,7 +157,7 @@ ioapicintrinit(int bustype, int busno, int apicno, int intin, int devno, uint32_ rdt = rdtlookup(apic, intin); if(rdt == nil){ if(nrdtarray == nelem(rdtarray)){ - print("ioapic: intrinit: rdtarray too small\n"); + jehanne_print("ioapic: intrinit: rdtarray too small\n"); return; } rdt = &rdtarray[nrdtarray++]; @@ -170,14 +170,14 @@ ioapicintrinit(int bustype, int busno, int apicno, int intin, int devno, uint32_ DBG("override: isa %d %.8ux\n", intin, rdt->lo); return; /* expected; default was overridden*/ } - print("multiple irq botch type %d bus %d %d/%d/%d lo %.8ux vs %.8ux\n", + jehanne_print("multiple irq botch type %d bus %d %d/%d/%d lo %.8ux vs %.8ux\n", bustype, busno, apicno, intin, devno, lo, rdt->lo); return; } DBG("dup rdt %d %d %d %d %.8ux\n", busno, apicno, intin, devno, lo); } rdt->ref++; - rbus = malloc(sizeof(*rbus)); + rbus = jehanne_malloc(sizeof(*rbus)); rbus->rdt = rdt; rbus->bustype = bustype; rbus->devno = devno; @@ -221,7 +221,7 @@ ioapicinit(int id, int ibase, uintmem pa) return apic; if((p = dupaddr(pa)) != nil){ - print("ioapic%d: same pa as apic%ld\n", id, p-xioapic); + jehanne_print("ioapic%d: same pa as apic%ld\n", id, p-xioapic); if(ibase != -1) return nil; /* mp irqs reference mp apic#s */ apic->addr = p->addr; @@ -229,7 +229,7 @@ ioapicinit(int id, int ibase, uintmem pa) else{ //adrmapck(pa, 1024, Ammio, Mfree, Cnone); /* not in adr? */ /* TO DO */ if((apic->addr = vmap(pa, 1024)) == nil){ - print("ioapic%d: can't vmap %#P\n", id, pa); + jehanne_print("ioapic%d: can't vmap %#P\n", id, pa); return nil; } } @@ -269,10 +269,10 @@ iordtdump(void) for(i = 0; i < Nbus; i++){ if((rbus = rdtbus[i]) == nil) continue; - print("iointr bus %d:\n", i); + jehanne_print("iointr bus %d:\n", i); for(; rbus != nil; rbus = rbus->next){ rdt = rbus->rdt; - print(" apic %ld devno %#ux (%d %d) intin %d lo %#ux ref %d\n", + jehanne_print(" apic %ld devno %#ux (%d %d) intin %d lo %#ux ref %d\n", rdt->apic-xioapic, rbus->devno, rbus->devno>>2, rbus->devno & 0x03, rdt->intin, rdt->lo, rdt->ref); } @@ -292,13 +292,13 @@ ioapicdump(void) apic = &xioapic[i]; if(!apic->useable || apic->addr == 0) continue; - print("ioapic %d addr %#p nrdt %d ibase %d\n", + jehanne_print("ioapic %d addr %#p nrdt %d ibase %d\n", i, apic->addr, apic->nrdt, apic->gsib); for(n = 0; n < apic->nrdt; n++){ lock(apic); rtblget(apic, n, &hi, &lo); unlock(apic); - print(" rdt %2.2d %#8.8ux %#8.8ux\n", n, hi, lo); + jehanne_print(" rdt %2.2d %#8.8ux %#8.8ux\n", n, hi, lo); } } } @@ -309,12 +309,12 @@ ioapicprint(char *p, char *e, IOapic *a, int i) char *s; s = "ioapic"; - p = seprint(p, e, "%-8s ", s); - p = seprint(p, e, "%8ux ", i); - p = seprint(p, e, "%6d ", a->gsib); - p = seprint(p, e, "%6d ", a->gsib+a->nrdt-1); - p = seprint(p, e, "%#P ", a->paddr); - p = seprint(p, e, "\n"); + p = jehanne_seprint(p, e, "%-8s ", s); + p = jehanne_seprint(p, e, "%8ux ", i); + p = jehanne_seprint(p, e, "%6d ", a->gsib); + p = jehanne_seprint(p, e, "%6d ", a->gsib+a->nrdt-1); + p = jehanne_seprint(p, e, "%#P ", a->paddr); + p = jehanne_seprint(p, e, "\n"); return p; } @@ -324,7 +324,7 @@ ioapicread(Chan* _1, void *a, long n, int64_t off) char *s, *e, *p; long i, r; - s = malloc(READSTR); + s = jehanne_malloc(READSTR); e = s+READSTR; p = s; @@ -336,7 +336,7 @@ ioapicread(Chan* _1, void *a, long n, int64_t off) r = readstr(off, a, n, s); poperror(); } - free(s); + jehanne_free(s); return r; } @@ -356,7 +356,7 @@ ioapiconline(void) unlock(apic); } } - print("init ioapic dump\n"); + jehanne_print("init ioapic dump\n"); ioapicdump(); } diff --git a/sys/src/kern/amd64/lapic.c b/sys/src/kern/amd64/lapic.c index 620ef4c..704adb0 100644 --- a/sys/src/kern/amd64/lapic.c +++ b/sys/src/kern/amd64/lapic.c @@ -9,7 +9,7 @@ #include "adr.h" #undef DBG -#define DBG print +#define DBG jehanne_print enum { /* Local APIC registers */ Id = 0x0020, /* Identification */ @@ -131,14 +131,14 @@ lapicprint(char *p, char *e, Lapic *a, int i) char *s; s = "proc"; - p = seprint(p, e, "%-8s ", s); - p = seprint(p, e, "%8ux ", i); -// p = seprint(p, e, "%.8ux ", a->dest); -// p = seprint(p, e, "%.8ux ", a->mask); -// p = seprint(p, e, "%c", a->flags & PcmpBP? 'b': ' '); -// p = seprint(p, e, "%c ", a->flags & PcmpEN? 'e': ' '); -// p = seprint(p, e, "%8ux %8ux", a->lintr[0], a->lintr[1]); - p = seprint(p, e, "%12d\n", a->machno); + p = jehanne_seprint(p, e, "%-8s ", s); + p = jehanne_seprint(p, e, "%8ux ", i); +// p = jehanne_seprint(p, e, "%.8ux ", a->dest); +// p = jehanne_seprint(p, e, "%.8ux ", a->mask); +// p = jehanne_seprint(p, e, "%c", a->flags & PcmpBP? 'b': ' '); +// p = jehanne_seprint(p, e, "%c ", a->flags & PcmpEN? 'e': ' '); +// p = jehanne_seprint(p, e, "%8ux %8ux", a->lintr[0], a->lintr[1]); + p = jehanne_seprint(p, e, "%12d\n", a->machno); return p; } @@ -148,7 +148,7 @@ lapicread(Chan* _1, void *a, long n, int64_t off) char *s, *e, *p; long i, r; - s = malloc(READSTR); + s = jehanne_malloc(READSTR); e = s+READSTR; p = s; @@ -160,7 +160,7 @@ lapicread(Chan* _1, void *a, long n, int64_t off) r = readstr(off, a, n, s); poperror(); } - free(s); + jehanne_free(s); return r; } @@ -181,7 +181,7 @@ lapicinit(int lapicno, uintmem pa, int isbp) return; } if((apic = &xlapic[lapicno])->useable){ - print("lapicinit%d: already initialised\n", lapicno); + jehanne_print("lapicinit%d: already initialised\n", lapicno); return; } if(lapicbase == nil){ @@ -220,7 +220,7 @@ lapicsetdom(int lapicno, int dom) if((apic = &xlapic[lapicno])->useable) apic->dom = dom; else - print("lapic%d: lapicsetdom: apic not usable\n", lapicno); + jehanne_print("lapic%d: lapicsetdom: apic not usable\n", lapicno); } int @@ -288,7 +288,7 @@ lapiconline(void) ver = lapicrget(Ver); nlvt = ((ver>>16) & 0xff) + 1; if(nlvt > nelem(apic->lvt)){ - print("lapiconline%d: nlvt %d > max (%d)\n", + jehanne_print("lapiconline%d: nlvt %d > max (%d)\n", apicno, nlvt, nelem(apic->lvt)); nlvt = nelem(apic->lvt); } @@ -299,7 +299,7 @@ lapiconline(void) * These don't really matter in Physical mode; * set the defaults anyway. */ -// if(memcmp(m->cpuinfo, "AuthenticAMD", 12) == 0) +// if(jehanne_memcmp(m->cpuinfo, "AuthenticAMD", 12) == 0) // dfr = 0xf0000000; // else dfr = 0xffffffff; @@ -344,7 +344,7 @@ lapiconline(void) apic->div = ((m->cpuhz/apic->max)+HZ/2)/HZ; if(m->machno == 0 || DBGFLG){ - print("lapic%d: hz %lld max %lld min %lld div %lld\n", apicno, + jehanne_print("lapic%d: hz %lld max %lld min %lld div %lld\n", apicno, apic->hz, apic->max, apic->min, apic->div); } @@ -420,7 +420,7 @@ lapictimerset(uint64_t next) period = apic->max; if(next != 0){ if(apic->div == 0){ - print("lapictimerset: apic not ready, wait for gdb\n"); + jehanne_print("lapictimerset: apic not ready, wait for gdb\n"); waitdebugger(); } period = next - fastticks(nil); /* fastticks is just rdtsc() */ diff --git a/sys/src/kern/amd64/main.c b/sys/src/kern/amd64/main.c index a5ee393..8e60ac7 100644 --- a/sys/src/kern/amd64/main.c +++ b/sys/src/kern/amd64/main.c @@ -58,8 +58,8 @@ static int vflag = 1; void optionsinit(char* s) { - oargblen = strecpy(oargb, oargb+sizeof(oargb), s) - oargb; - oargc = tokenize(oargb, oargv, nelem(oargv)-1); + oargblen = jehanne_strecpy(oargb, oargb+sizeof(oargb), s) - oargb; + oargc = jehanne_tokenize(oargb, oargv, nelem(oargv)-1); oargv[oargc] = nil; } @@ -84,24 +84,24 @@ options(int argc, char* argv[]) while(o = *++argv[0]){ if(!(o >= 'A' && o <= 'Z') && !(o >= 'a' && o <= 'z')) continue; - n = strtol(argv[0]+1, &p, 0); + n = jehanne_strtol(argv[0]+1, &p, 0); if(p == argv[0]+1 || n < 1 || n > 127) n = 1; argv[0] = p-1; dbgflg[o] = n; } - }else if(strcmp(next, "waitgdb") == 0){ + }else if(jehanne_strcmp(next, "waitgdb") == 0){ waitdebugger(); - }else if(strcmp(next, "idlespin") == 0){ + }else if(jehanne_strcmp(next, "idlespin") == 0){ onIdleSpin(); }else{ - strncpy(envcopy, next, sizeof(envcopy)-1); - gettokens(envcopy, env, 2, "="); - if(strcmp(env[0], "maxcores") == 0){ - maxcores = strtol(env[1], 0, 0); + jehanne_strncpy(envcopy, next, sizeof(envcopy)-1); + jehanne_gettokens(envcopy, env, 2, "="); + if(jehanne_strcmp(env[0], "maxcores") == 0){ + maxcores = jehanne_strtol(env[1], 0, 0); } - if(strcmp(env[0], "numtcs") == 0){ - numtcs = strtol(env[1], 0, 0); + if(jehanne_strcmp(env[0], "numtcs") == 0){ + numtcs = jehanne_strtol(env[1], 0, 0); } } } @@ -119,10 +119,10 @@ loadenv(int argc, char* argv[]) while(--argc > 0){ char* next = *++argv; if(next[0] !='-'){ - if (gettokens(next, env, 2, "=") == 2){; + if (jehanne_gettokens(next, env, 2, "=") == 2){; ksetenv(env[0], env[1], 1); }else{ - print("Ignoring parameter with no value: %s\n", env[0]); + jehanne_print("Ignoring parameter with no value: %s\n", env[0]); } } } @@ -195,7 +195,7 @@ squidboy(int apicno) lapictimerenable(); lapicpri(0); - print("mach%d: online color %d\n", m->machno, m->color); + jehanne_print("mach%d: online color %d\n", m->machno, m->color); schedinit(); panic("squidboy returns (type %d)", m->mode); @@ -210,7 +210,7 @@ main(uint32_t ax, uint32_t bx) int64_t hz; char *p; - memset(edata, 0, end - edata); + jehanne_memset(edata, 0, end - edata); /* * ilock via i8250enable via i8250console @@ -218,7 +218,7 @@ main(uint32_t ax, uint32_t bx) * also 'up' set to nil. */ cgapost(sizeof(uintptr_t)*8); - memset(m, 0, sizeof(Mach)); + jehanne_memset(m, 0, sizeof(Mach)); m->machno = 0; m->online = 1; sys->machptr[m->machno] = &sys->mach; @@ -256,10 +256,10 @@ main(uint32_t ax, uint32_t bx) active.exiting = 0; fmtinit(); - print("\nJehanne Operating System\n"); + jehanne_print("\nJehanne Operating System\n"); if(vflag){ - print("&ax = %#p, ax = %#ux, bx = %#ux\n", &ax, ax, bx); + jehanne_print("&ax = %#p, ax = %#ux, bx = %#ux\n", &ax, ax, bx); multiboot(ax, bx, vflag); } e820(); @@ -333,7 +333,7 @@ D('k'); D('l'); p = getconf("*procmax"); if(p != nil) - procmax = strtoull(p, nil, 0); + procmax = jehanne_strtoull(p, nil, 0); if(procmax == 0) procmax = 2000; psinit(procmax); @@ -400,7 +400,7 @@ init0(void) devtabinit(); if(!waserror()){ - snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile); + jehanne_snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile); loadenv(oargc, oargv); ksetenv("terminal", buf, 0); ksetenv("cputype", "amd64", 0); @@ -431,7 +431,7 @@ bootargs(uintptr_t base) */ i = oargblen+1; p = UINT2PTR(STACKALIGN(base + PGSZ - sizeof(up->arg) - i)); - memmove(p, oargb, i); + jehanne_memmove(p, oargb, i); /* * Now push argc and the argv pointers. diff --git a/sys/src/kern/amd64/memory.c b/sys/src/kern/amd64/memory.c index 55a65ce..5e2e421 100644 --- a/sys/src/kern/amd64/memory.c +++ b/sys/src/kern/amd64/memory.c @@ -118,7 +118,7 @@ meminit(void) assert(m->pgszlg2[1] == 21); assert((sys->vmunmapped & m->pgszmask[1]) == 0); - print("vmunmapped %#llux\n", sys->vmunmapped); + jehanne_print("vmunmapped %#llux\n", sys->vmunmapped); n = TMFM; if(n > sys->pmoccupied) @@ -146,10 +146,10 @@ memdebug(void) if(DBGFLG || 1){ rmapprint(&rmapram); rmapprint(&rmapunavail); - print("k ptes:"); + jehanne_print("k ptes:"); for(i = 0; i < nelem(npg); i++) - print(" %d", npg[i]); - print("\n"); + jehanne_print(" %d", npg[i]); + jehanne_print("\n"); } } @@ -210,13 +210,13 @@ e820(void) for(s = p;;){ if(*s == 0) break; - type = strtoul(s, &s, 16); + type = jehanne_strtoul(s, &s, 16); if(*s != ' ') break; - base = strtoull(s, &s, 16); + base = jehanne_strtoull(s, &s, 16); if(*s != ' ') break; - len = strtoull(s, &s, 16) - base; + len = jehanne_strtoull(s, &s, 16) - base; if(*s != ' ' && *s != 0 || len == 0) break; DBG("E820: %llux %llux %#ux\n", base, len, type); diff --git a/sys/src/kern/amd64/mmu.c b/sys/src/kern/amd64/mmu.c index 4bbbd08..95ac303 100644 --- a/sys/src/kern/amd64/mmu.c +++ b/sys/src/kern/amd64/mmu.c @@ -7,7 +7,7 @@ #include "amd64.h" //#undef DBG -//#define DBG(...) print(__VA_ARGS__) +//#define DBG(...) jehanne_print(__VA_ARGS__) #define PDMAP (0xffffffffff800000ull) #define PDPX(v) PTLX((v), 2) @@ -44,7 +44,7 @@ void mmuflushtlb(uint64_t _1) { if(m->pml4->ptoff){ - memset(m->pml4->pte, 0, m->pml4->ptoff*sizeof(PTE)); + jehanne_memset(m->pml4->pte, 0, m->pml4->ptoff*sizeof(PTE)); m->pml4->ptoff = 0; } cr3put(m->pml4->pa); @@ -74,7 +74,7 @@ mmuptpfree(Proc* proc, int clear) continue; for(; (page = *last) != nil; last = &page->next){ if(l <= 2 && clear) - memset(page->pte, 0, PTSZ); + jehanne_memset(page->pte, 0, PTSZ); pte = page->parent->pte; pte[page->ptoff] = 0; proc->nptpbusy--; @@ -106,7 +106,7 @@ mmuptpalloc(void) } if(page != nil){ page->next = nil; -memset(page->pte, 0, PTSZ); + jehanne_memset(page->pte, 0, PTSZ); return page; } pa = physalloc(PTSZ); @@ -115,7 +115,7 @@ memset(page->pte, 0, PTSZ); panic("mmuptpalloc"); } DBG("ptp %#P\n", pa); - page = mallocz(sizeof(*page), 0); + page = jehanne_mallocz(sizeof(*page), 0); if(page == nil) panic("mmuptpalloc 2"); page->pte = KADDR(pa); @@ -123,7 +123,7 @@ memset(page->pte, 0, PTSZ); page->next = nil; page->parent = nil; page->ptoff = 0; - memset(page->pte, 0, PTSZ); + jehanne_memset(page->pte, 0, PTSZ); return page; } @@ -139,7 +139,7 @@ mmuswitch(Proc* proc) } if(m->pml4->ptoff){ - memset(m->pml4->pte, 0, m->pml4->ptoff*sizeof(PTE)); + jehanne_memset(m->pml4->pte, 0, m->pml4->ptoff*sizeof(PTE)); m->pml4->ptoff = 0; } @@ -186,7 +186,7 @@ mmurelease(Proc* proc) } if(proc->nptpbusy) - print("%ud: ptpbusy %s %d\n", proc->pid, proc->text, proc->nptpbusy); + jehanne_print("%ud: ptpbusy %s %d\n", proc->pid, proc->text, proc->nptpbusy); proc->nptpbusy = 0; tssrsp0(STACKALIGN(m->stack+MACHSTKSZ)); @@ -325,8 +325,8 @@ pdmap(uintmem pa, int attr, uintptr_t va, usize size) if(pdpa == 0) panic("pdmap"); *pde = pdpa|PteRW|PteP; -//print("*pde %#llux va %#p\n", *pde, va); - memset(pt, 0, PTSZ); +//jehanne_print("*pde %#llux va %#p\n", *pde, va); + jehanne_memset(pt, 0, PTSZ); } pte = &pt[PTX(va)]; @@ -444,7 +444,7 @@ vmap(uintptr_t pa, usize size) sz = ROUNDUP(size+o, PGSZ); if(pa == 0){ - print("vmap(0, %lud) pc=%#p\n", size, getcallerpc()); + jehanne_print("vmap(0, %lud) pc=%#p\n", size, getcallerpc()); return nil; } ilock(&vmaplock); @@ -506,11 +506,11 @@ mmuwalk(uintptr_t va, int level, PTE** ret, uint64_t (*alloc)(usize)) pa = alloc(PTSZ); if(pa == ~(uintmem)0 || pa == 0) return -1; -if(pa & 0xfffull) print("mmuwalk pa %#llux\n", pa); +if(pa & 0xfffull) jehanne_print("mmuwalk pa %#llux\n", pa); *pte = pa|PteRW|PteP; if((ptp = mmuptpget(va, l-1)) == nil) panic("mmuwalk: mmuptpget(%#p, %d)", va, l-1); - memset(ptp, 0, PTSZ); + jehanne_memset(ptp, 0, PTSZ); } else if(*pte & PtePS) break; @@ -566,13 +566,13 @@ mmuinit(void) */ p = UINT2PTR(m->stack); p += MACHSTKSZ; - memmove(p, mach0pml4.pte, PTSZ); + jehanne_memmove(p, mach0pml4.pte, PTSZ); m->pml4 = &m->pml4kludge; m->pml4->pte = (PTE*)p; m->pml4->pa = PADDR(p); m->pml4->ptoff = mach0pml4.ptoff; /* # of user mappings in pml4 */ if(m->pml4->ptoff){ - memset(p, 0, m->pml4->ptoff*sizeof(PTE)); + jehanne_memset(p, 0, m->pml4->ptoff*sizeof(PTE)); m->pml4->ptoff = 0; } pte = (PTE*)p; @@ -612,7 +612,7 @@ pte[PTLX(KSEG1PML4, 3)] = m->pml4->pa|PteRW|PteP; */ o = sys->pmstart; sz = ROUNDUP(o+128*KiB, 4*MiB) - o; /* add extra 128k for initial pt/pd allocations */ -print("mmuinit: rmapalloc: %#P pmstart=%#llux\n", o, sys->pmstart); +jehanne_print("mmuinit: rmapalloc: %#P pmstart=%#llux\n", o, sys->pmstart); pa = rmapalloc(&rmapram, o, sz, 0); if(pa != o) panic("mmuinit: pa %#llux memstart %#llux\n", pa, o); @@ -622,7 +622,7 @@ print("mmuinit: rmapalloc: %#P pmstart=%#llux\n", o, sys->pmstart); sys->vmunused = sys->vmstart + ROUNDUP(o, 4*KiB); sys->vmunmapped = sys->vmstart + o + sz; - print("mmuinit: vmstart %#p vmunused %#p vmunmapped %#p\n", + jehanne_print("mmuinit: vmstart %#p vmunused %#p vmunmapped %#p\n", sys->vmstart, sys->vmunused, sys->vmunmapped); /* @@ -634,7 +634,7 @@ print("mmuinit: rmapalloc: %#P pmstart=%#llux\n", o, sys->pmstart); * map below. */ sys->pd[PDX(PDMAP)] = sys->pdp[PDPX(PDMAP)] & ~(PteD|PteA); - print("sys->pd %#p %#p\n", sys->pd[PDX(PDMAP)], sys->pdp[PDPX(PDMAP)]); + jehanne_print("sys->pd %#p %#p\n", sys->pd[PDX(PDMAP)], sys->pdp[PDPX(PDMAP)]); assert((pdeget(PDMAP) & ~(PteD|PteA)) == (PADDR(sys->pd)|PteRW|PteP)); @@ -650,13 +650,13 @@ print("mmuinit: rmapalloc: %#P pmstart=%#llux\n", o, sys->pmstart); cr3put(m->pml4->pa); if((l = mmuwalk(KZERO, 3, &pte, nil)) >= 0) - print("l %d %#p %llux\n", l, pte, *pte); + jehanne_print("l %d %#p %llux\n", l, pte, *pte); if((l = mmuwalk(KZERO, 2, &pte, nil)) >= 0) - print("l %d %#p %llux\n", l, pte, *pte); + jehanne_print("l %d %#p %llux\n", l, pte, *pte); if((l = mmuwalk(KZERO, 1, &pte, nil)) >= 0) - print("l %d %#p %llux\n", l, pte, *pte); + jehanne_print("l %d %#p %llux\n", l, pte, *pte); if((l = mmuwalk(KZERO, 0, &pte, nil)) >= 0) - print("l %d %#p %llux\n", l, pte, *pte); + jehanne_print("l %d %#p %llux\n", l, pte, *pte); mmuphysaddr(PTR2UINT(end)); } @@ -669,10 +669,10 @@ mmudump(Proc *p) for(l = 3; l >= 0; l--){ for(ptp = p->mmuptp[l]; ptp != nil; ptp = ptp->next){ - print("pid %d level %d ptp %#p\n", p->pid, l, ptp); + jehanne_print("pid %d level %d ptp %#p\n", p->pid, l, ptp); for(i = 0; i < PTSZ/sizeof(PTE); i++) if(ptp->pte[i]) - print("%.4d %#P\n", i, ptp->pte[i]); + jehanne_print("%.4d %#P\n", i, ptp->pte[i]); } } } @@ -688,7 +688,7 @@ checkmmu(uintptr_t va, uintmem pa) mpa = mmuphysaddr(va); if(mpa != ~(uintmem)0 && (mpa & (PteNX-1)) != pa) - print("***%d %s: mmu mismatch va=%#p pa=%#P mmupa=%#P\n", + jehanne_print("***%d %s: mmu mismatch va=%#p pa=%#P mmupa=%#P\n", up->pid, up->text, va, pa, mpa); } @@ -698,7 +698,7 @@ tabs(int n) int i; for(i = 0; i < n; i++) - print(" "); + jehanne_print(" "); } void @@ -712,12 +712,12 @@ dumpptepg(int lvl, uintmem pa) for(i = 0; i < PTSZ/sizeof(PTE); i++) if(pte[i] & PteP){ tabs(tab); - print("l%d %#p[%#05x]: %#llux\n", lvl, pa, i, pte[i]); + jehanne_print("l%d %#p[%#05x]: %#llux\n", lvl, pa, i, pte[i]); /* skip kernel mappings */ if((pte[i]&PteU) == 0){ tabs(tab+1); - print("...kern...\n"); + jehanne_print("...kern...\n"); continue; } if(lvl > 2) @@ -731,15 +731,15 @@ dumpmmu(Proc *p) int i; Ptpage *pt; - print("proc %#p\n", p); + jehanne_print("proc %#p\n", p); for(i = 3; i >= 0; i--){ - print("mmuptp[%d]:\n", i); + jehanne_print("mmuptp[%d]:\n", i); for(pt = p->mmuptp[i]; pt != nil; pt = pt->next) - print("\tpt %#p = va %#p pa %#P" + jehanne_print("\tpt %#p = va %#p pa %#P" " ptoff %#ux next %#p parent %#p\n", pt, pt->pte, pt->pa, pt->ptoff, pt->next, pt->parent); } - print("pml4 %#P\n", m->pml4->pa); + jehanne_print("pml4 %#P\n", m->pml4->pa); if(0)dumpptepg(4, m->pml4->pa); } @@ -750,13 +750,13 @@ dumpmmuwalk(uintmem addr) PTE *pte; if((l = mmuwalk(addr, 3, &pte, nil)) >= 0) - print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); + jehanne_print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); if((l = mmuwalk(addr, 2, &pte, nil)) >= 0) - print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); + jehanne_print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); if((l = mmuwalk(addr, 1, &pte, nil)) >= 0) - print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); + jehanne_print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); if((l = mmuwalk(addr, 0, &pte, nil)) >= 0) - print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); + jehanne_print("cpu%d: mmu l%d pte %#p = %llux\n", m->machno, l, pte, *pte); } #ifdef DO_mmuptpcheck static void diff --git a/sys/src/kern/amd64/mouse.c b/sys/src/kern/amd64/mouse.c index b34ebaf..9ec4f61 100644 --- a/sys/src/kern/amd64/mouse.c +++ b/sys/src/kern/amd64/mouse.c @@ -210,7 +210,7 @@ mousectl(Cmdbuf *cb) ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg)); switch(ct->index){ case CMaccelerated: - setaccelerated(cb->nf == 1 ? 1 : atoi(cb->f[1])); + setaccelerated(cb->nf == 1 ? 1 : jehanne_atoi(cb->f[1])); break; case CMintellimouse: setintellimouse(); @@ -228,7 +228,7 @@ mousectl(Cmdbuf *cb) break; case CMres: if(cb->nf >= 2) - setres(atoi(cb->f[1])); + setres(jehanne_atoi(cb->f[1])); else setres(1); break; @@ -242,9 +242,9 @@ mousectl(Cmdbuf *cb) setintellimouse(); break; case CMhwaccel: - if(strcmp(cb->f[1], "on")==0) + if(jehanne_strcmp(cb->f[1], "on")==0) mousehwaccel = 1; - else if(strcmp(cb->f[1], "off")==0) + else if(jehanne_strcmp(cb->f[1], "off")==0) mousehwaccel = 0; else cmderror(cb, "bad mouse control message"); diff --git a/sys/src/kern/amd64/mp.c b/sys/src/kern/amd64/mp.c index 8ed6556..1c6603f 100644 --- a/sys/src/kern/amd64/mp.c +++ b/sys/src/kern/amd64/mp.c @@ -8,7 +8,7 @@ #include "apic.h" #undef DBG -#define DBG print +#define DBG jehanne_print /* * MultiProcessor Specification Version 1.[14]. */ @@ -59,11 +59,11 @@ mpintrprint(char* s, uint8_t* p) b = buf; e = b + sizeof(buf); - b = seprint(b, e, "mpparse: intr:"); + b = jehanne_seprint(b, e, "mpparse: intr:"); if(s != nil) - b = seprint(b, e, " %s:", s); - seprint(b, e, format, p[1], l16get(p+2), p[4], p[5], p[6], p[7]); - print(buf); + b = jehanne_seprint(b, e, " %s:", s); + jehanne_seprint(b, e, format, p[1], l16get(p+2), p[4], p[5], p[6], p[7]); + jehanne_print(buf); } static uint32_t @@ -189,14 +189,14 @@ mpparse(PCMP* pcmp) e = ((uint8_t*)pcmp)+l16get(pcmp->length); while(p < e) switch(*p){ default: - print("mpparse: unknown PCMP type %d (e-p %#ld)\n", *p, e-p); + jehanne_print("mpparse: unknown PCMP type %d (e-p %#ld)\n", *p, e-p); for(i = 0; p < e; i++){ if(i && ((i & 0x0f) == 0)) - print("\n"); - print(" %#2.2ux", *p); + jehanne_print("\n"); + jehanne_print(" %#2.2ux", *p); p++; } - print("\n"); + jehanne_print("\n"); break; case 0: /* processor */ /* @@ -215,16 +215,16 @@ mpparse(PCMP* pcmp) case 1: /* bus */ DBG("mpparse: bus: %d type %6.6s\n", p[1], (char*)p+2); if(mpbus[p[1]] != nil){ - print("mpparse: bus %d already allocated\n", p[1]); + jehanne_print("mpparse: bus %d already allocated\n", p[1]); p += 8; break; } for(i = 0; i < nelem(mpbusdef); i++){ - if(memcmp(p+2, mpbusdef[i].type, 6) != 0) + if(jehanne_memcmp(p+2, mpbusdef[i].type, 6) != 0) continue; - if(memcmp(p+2, "ISA ", 6) == 0){ + if(jehanne_memcmp(p+2, "ISA ", 6) == 0){ if(mpisabusno != -1){ - print("mpparse: bus %d already have ISA bus %d\n", + jehanne_print("mpparse: bus %d already have ISA bus %d\n", p[1], mpisabusno); continue; } @@ -234,7 +234,7 @@ mpparse(PCMP* pcmp) break; } if(mpbus[p[1]] == nil) - print("mpparse: bus %d type %6.6s unknown\n", + jehanne_print("mpparse: bus %d type %6.6s unknown\n", p[1], (char*)p+2); p += 8; @@ -280,9 +280,9 @@ mpparse(PCMP* pcmp) * (but unlikely). */ bustype = -1; - if(memcmp(mpbus[p[4]]->type, "PCI ", 6) == 0) + if(jehanne_memcmp(mpbus[p[4]]->type, "PCI ", 6) == 0) bustype = BusPCI; /* had devno = p[5]<<2 */ - else if(memcmp(mpbus[p[4]]->type, "ISA ", 6) == 0) + else if(jehanne_memcmp(mpbus[p[4]]->type, "ISA ", 6) == 0) bustype = BusISA; if(bustype != -1) ioapicintrinit(bustype, p[4], p[6], p[7], p[5], lo); @@ -328,14 +328,14 @@ mpparse(PCMP* pcmp) while(p < e) switch(*p){ default: n = p[1]; - print("mpparse: unknown extended entry %d length %d\n", *p, n); + jehanne_print("mpparse: unknown extended entry %d length %d\n", *p, n); for(i = 0; i < n; i++){ if(i && ((i & 0x0f) == 0)) - print("\n"); - print(" %#2.2ux", *p); + jehanne_print("\n"); + jehanne_print(" %#2.2ux", *p); p++; } - print("\n"); + jehanne_print("\n"); break; case 128: DBG("address space mapping\n"); @@ -410,7 +410,7 @@ mpsinit(void) p = ((uint8_t*)pcmp) + l16get(pcmp->length); i = checksum(p, l16get(pcmp->xlength)); if(((i+pcmp->xchecksum) & 0xff) != 0){ - print("extended table checksums to %#ux\n", i); + jehanne_print("extended table checksums to %#ux\n", i); vunmap(pcmp, n); return; } diff --git a/sys/src/kern/amd64/msi.c b/sys/src/kern/amd64/msi.c index e6e221c..6c74f1a 100644 --- a/sys/src/kern/amd64/msi.c +++ b/sys/src/kern/amd64/msi.c @@ -93,7 +93,7 @@ pcimsienable(Pcidev *p, uint64_t vec) pcicfgw32(p, c + datao + 4, 0); /* leave vectors configured but disabled for debugging */ - if((s = getconf("*nomsi")) != nil && atoi(s) != 0) + if((s = getconf("*nomsi")) != nil && jehanne_atoi(s) != 0) return -1; pcicfgw16(p, c + 2, f); diff --git a/sys/src/kern/amd64/multiboot.c b/sys/src/kern/amd64/multiboot.c index b4e7645..8a0c21c 100644 --- a/sys/src/kern/amd64/multiboot.c +++ b/sys/src/kern/amd64/multiboot.c @@ -66,19 +66,19 @@ multiboot(uint32_t magic, uint32_t pmbi, int vflag) uint64_t addr, len; if(vflag) - print("magic %#ux pmbi %#ux\n", magic, pmbi); + jehanne_print("magic %#ux pmbi %#ux\n", magic, pmbi); if(magic != 0x2badb002){ //return -1; - print("wrong magic in multiboot\n"); + jehanne_print("wrong magic in multiboot\n"); } mbi = KADDR(pmbi); if(vflag) - print("flags %#ux\n", mbi->flags); + jehanne_print("flags %#ux\n", mbi->flags); if(mbi->flags & Fcmdline){ p = KADDR(mbi->cmdline); if(vflag) - print("cmdline <%s>\n", p); + jehanne_print("cmdline <%s>\n", p); else optionsinit(p); } @@ -90,11 +90,11 @@ multiboot(uint32_t magic, uint32_t pmbi, int vflag) else p = ""; if(vflag) - print("mod %#ux %#ux <%s>\n", + jehanne_print("mod %#ux %#ux <%s>\n", mod->modstart, mod->modend, p); else { asmmodinit(mod->modstart, mod->modend, p); - modname = strrchr(p, '/'); + modname = jehanne_strrchr(p, '/'); if(modname == nil) modname = p; if(*modname == '/') @@ -112,35 +112,35 @@ multiboot(uint32_t magic, uint32_t pmbi, int vflag) switch(mmap->type){ default: if(vflag) - print("type %ud", mmap->type); + jehanne_print("type %ud", mmap->type); break; case 1: if(vflag) - print("Memory"); + jehanne_print("Memory"); else asmmapinit(addr, len, mmap->type); break; case 2: if(vflag) - print("reserved"); + jehanne_print("reserved"); else asmmapinit(addr, len, mmap->type); break; case 3: if(vflag) - print("ACPI Reclaim Memory"); + jehanne_print("ACPI Reclaim Memory"); else asmmapinit(addr, len, mmap->type); break; case 4: if(vflag) - print("ACPI NVS Memory"); + jehanne_print("ACPI NVS Memory"); else asmmapinit(addr, len, mmap->type); break; } if(vflag) - print("\n\t%#16.16llux %#16.16llux (%llud)\n", + jehanne_print("\n\t%#16.16llux %#16.16llux (%llud)\n", addr, addr+len, len); n += mmap->size+sizeof(mmap->size); @@ -149,7 +149,7 @@ multiboot(uint32_t magic, uint32_t pmbi, int vflag) } if(vflag && (mbi->flags & Fbootloadername)){ p = KADDR(mbi->bootloadername); - print("bootloadername <%s>\n", p); + jehanne_print("bootloadername <%s>\n", p); } return 0; diff --git a/sys/src/kern/amd64/options.c b/sys/src/kern/amd64/options.c index 3bb3656..774be19 100644 --- a/sys/src/kern/amd64/options.c +++ b/sys/src/kern/amd64/options.c @@ -58,11 +58,11 @@ confoptions(void) } *p = 0; - n = getfields(cp, line, MAXCONF, 1, "\n"); + n = jehanne_getfields(cp, line, MAXCONF, 1, "\n"); for(i = 0; i < n; i++){ if(*line[i] == '#') continue; - cp = strchr(line[i], '='); + cp = jehanne_strchr(line[i], '='); if(cp == nil) continue; *cp++ = '\0'; @@ -78,7 +78,7 @@ getconf(char *name) int i; for(i = 0; i < nconf; i++) - if(cistrcmp(confname[i], name) == 0) + if(jehanne_cistrcmp(confname[i], name) == 0) return confval[i]; return 0; } @@ -101,29 +101,29 @@ isaconfig(char *class, int ctlrno, ISAConf *isa) char cc[32], *p; int i; - snprint(cc, sizeof cc, "%s%d", class, ctlrno); + jehanne_snprint(cc, sizeof cc, "%s%d", class, ctlrno); p = getconf(cc); if(p == nil) return 0; isa->type = ""; - isa->nopt = tokenize(p, isa->opt, NISAOPT); + isa->nopt = jehanne_tokenize(p, isa->opt, NISAOPT); for(i = 0; i < isa->nopt; i++){ p = isa->opt[i]; - if(cistrncmp(p, "type=", 5) == 0) + if(jehanne_cistrncmp(p, "type=", 5) == 0) isa->type = p + 5; - else if(cistrncmp(p, "port=", 5) == 0) - isa->port = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "irq=", 4) == 0) - isa->irq = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "dma=", 4) == 0) - isa->dma = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "mem=", 4) == 0) - isa->mem = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "size=", 5) == 0) - isa->size = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "freq=", 5) == 0) - isa->freq = strtoul(p+5, &p, 0); + else if(jehanne_cistrncmp(p, "port=", 5) == 0) + isa->port = jehanne_strtoul(p+5, &p, 0); + else if(jehanne_cistrncmp(p, "irq=", 4) == 0) + isa->irq = jehanne_strtoul(p+4, &p, 0); + else if(jehanne_cistrncmp(p, "dma=", 4) == 0) + isa->dma = jehanne_strtoul(p+4, &p, 0); + else if(jehanne_cistrncmp(p, "mem=", 4) == 0) + isa->mem = jehanne_strtoul(p+4, &p, 0); + else if(jehanne_cistrncmp(p, "size=", 5) == 0) + isa->size = jehanne_strtoul(p+5, &p, 0); + else if(jehanne_cistrncmp(p, "freq=", 5) == 0) + isa->freq = jehanne_strtoul(p+5, &p, 0); } return 1; } diff --git a/sys/src/kern/amd64/screen.c b/sys/src/kern/amd64/screen.c index 7c6deb2..5fe2a0c 100644 --- a/sys/src/kern/amd64/screen.c +++ b/sys/src/kern/amd64/screen.c @@ -71,7 +71,7 @@ screensize(int x, int y, int z, uint32_t chan) int width = (x*z)/BI2WD; void *p; - p = malloc(width*BY2WD*y); + p = jehanne_malloc(width*BY2WD*y); if(p == nil) error("no memory for vga soft screen"); gscreendata.bdata = softscreen = p; @@ -103,7 +103,7 @@ screensize(int x, int y, int z, uint32_t chan) unlock(&vgascreenlock); poperror(); if(oldsoft) - free(oldsoft); + jehanne_free(oldsoft); memimagedraw(gscreen, gscreen->r, memblack, ZP, nil, ZP, S); flushmemscreen(gscreen->r); @@ -137,7 +137,7 @@ screenaperture(int size, int align) * The driver will tell the card to use it. */ size = ROUNDUP(sizeof(size), 4*KiB); - scr->paddr = (uint64_t)malloc(size); + scr->paddr = (uint64_t)jehanne_malloc(size); if(scr->paddr == 0) return -1; scr->vaddr = vmap(scr->paddr, size); @@ -217,7 +217,7 @@ flushmemscreen(Rectangle r) scr->dev->page(scr, page); for(y = r.min.y; y < r.max.y; y++) { if(sdisp + incs < edisp) { - memmove(sdisp, sp, len); + jehanne_memmove(sdisp, sp, len); sp += incs; sdisp += incs; } @@ -226,13 +226,13 @@ flushmemscreen(Rectangle r) page++; if(off <= len){ if(off > 0) - memmove(sdisp, sp, off); + jehanne_memmove(sdisp, sp, off); scr->dev->page(scr, page); if(len - off > 0) - memmove(disp, sp+off, len - off); + jehanne_memmove(disp, sp+off, len - off); } else { - memmove(sdisp, sp, len); + jehanne_memmove(sdisp, sp, len); scr->dev->page(scr, page); } sp += incs; @@ -705,7 +705,7 @@ swcursorinit(void) if(scr->dev == nil || scr->dev->linear == nil){ if(!warned){ - print("cannot use software cursor on non-linear vga screen\n"); + jehanne_print("cannot use software cursor on non-linear vga screen\n"); warned = 1; } return; @@ -725,7 +725,7 @@ swcursorinit(void) swimg = allocmemimage(Rect(0,0,16,16), GREY8); swimg1 = allocmemimage(Rect(0,0,16,16), GREY1); if(swback==nil || swmask==nil || swmask1==nil || swimg==nil || swimg1 == nil){ - print("software cursor: allocmemimage fails"); + jehanne_print("software cursor: allocmemimage fails"); return; } diff --git a/sys/src/kern/amd64/sdahci.c b/sys/src/kern/amd64/sdahci.c index a75cf0b..4dd2e48 100644 --- a/sys/src/kern/amd64/sdahci.c +++ b/sys/src/kern/amd64/sdahci.c @@ -18,9 +18,9 @@ #pragma varargck type "T" int #define dprint(...) if(debug) iprint(__VA_ARGS__); else USED(debug) -#define idprint(...) if(prid) print(__VA_ARGS__); else USED(prid) -#define aprint(...) if(datapi) print(__VA_ARGS__); else USED(datapi) -#define ledprint(...) if(dled) print(__VA_ARGS__); else USED(dled) +#define idprint(...) if(prid) jehanne_print(__VA_ARGS__); else USED(prid) +#define aprint(...) if(datapi) jehanne_print(__VA_ARGS__); else USED(datapi) +#define ledprint(...) if(dled) jehanne_print(__VA_ARGS__); else USED(dled) #define Ticks sys->ticks enum { @@ -447,7 +447,7 @@ ahcirecover(Aportc *pc) static void setupfis(Afis *f) { - f->base = mallocalign(0x100, 0x100, 0, 0); + f->base = jehanne_mallocalign(0x100, 0x100, 0, 0); f->d = f->base + 0; f->p = f->base + 0x20; f->r = f->base + 0x40; @@ -464,7 +464,7 @@ ahciwakeup(Aportc *c, uint32_t mode) if((s & Isleepy) == 0) return; if((s & Smask) != Spresent){ - print("ahci: slumbering drive missing %.3ux\n", s); + jehanne_print("ahci: slumbering drive missing %.3ux\n", s); return; } ahciportreset(c, mode); @@ -482,8 +482,8 @@ ahciconfigdrive(Ahba *h, Aportc *c, int mode) if(m->list == 0){ setupfis(&m->fis); - m->list = mallocalign(sizeof *m->list, 1024, 0, 0); - m->ctab = mallocalign(sizeof *m->ctab, 128, 0, 0); + m->list = jehanne_mallocalign(sizeof *m->list, 1024, 0, 0); + m->ctab = jehanne_mallocalign(sizeof *m->ctab, 128, 0, 0); } p->list = Pciwaddrl(m->list); @@ -588,7 +588,7 @@ ahcibioshandoff(Ahba *h) if((h->bios & Bos) == 0) return 0; - print("ahcibioshandoff: claim\n"); + jehanne_print("ahcibioshandoff: claim\n"); h->bios |= Oos; wait = 25; @@ -597,12 +597,12 @@ ahcibioshandoff(Ahba *h) if((h->bios & Bos) == 0) break; if(i < 25 && h->bios & Bb){ - print("ahcibioshandoff: busy\n"); + jehanne_print("ahcibioshandoff: busy\n"); wait = 2000; } } if(i == wait){ - print("ahcibioshandoff: timeout %.1ux\n", h->bios); + jehanne_print("ahcibioshandoff: timeout %.1ux\n", h->bios); h->bios = Oos; } return 0; @@ -750,7 +750,7 @@ pstatus(Drive *d, uint32_t s) d->lastseen = Ticks; switch(s){ default: - print("%s: pstatus: bad status %.3ux\n", dnam(d), s); + jehanne_print("%s: pstatus: bad status %.3ux\n", dnam(d), s); case Smissing: d->state = Dmissing; break; @@ -1123,7 +1123,7 @@ blink(Drive *d, uint32_t t) default: panic("%s: bad led type %d", dnam(d), c->enctype); case Elmt: - memset(&msg, 0, sizeof msg); + jehanne_memset(&msg, 0, sizeof msg); msg.type = Mled; msg.dsize = 0; msg.msize = Ledmsz - 4; @@ -1131,7 +1131,7 @@ blink(Drive *d, uint32_t t) msg.led[1] = d->ledbits>>8; msg.pm = 0; msg.hba = d->driveno; - memmove(c->enctx, &msg, Ledmsz); + jehanne_memmove(c->enctx, &msg, Ledmsz); break; } h->emctl |= Tmsg; @@ -1171,7 +1171,7 @@ blinkesb(Ctlr *c, uint32_t t) } if(s == 0) return 0; - memset(u, 0, sizeof u); + jehanne_memset(u, 0, sizeof u); for(i = 0; i < c->ndrive; i++){ d = c->drive[i]; s = Esbdrv0 + Esbiota*i; @@ -1215,7 +1215,7 @@ ledkproc(void*) Drive *d; j = 0; - memset(map, 0, sizeof map); + jehanne_memset(map, 0, sizeof map); for(i = 0; i < niactlr; i++) if(iactlr[i].enctype != 0){ ahciencreset(iactlr + i); @@ -1285,7 +1285,7 @@ iaenable(SDev *s) if(c->ndrive == 0) panic("iaenable: zero s->ctlr->ndrive"); pcisetbme(c->pci); - snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); + jehanne_snprint(name, sizeof name, "%s (%s)", s->name, s->ifc->name); intrenable(c->pci->intl, iainterrupt, c, c->pci->tbdf, name); /* supposed to squelch leftover interrupts here. */ ahcienable(c->hba); @@ -1372,7 +1372,7 @@ ahcibuildfis(Aportm *m, SDreq *r, void *data, uint32_t n) l = m->list; c = m->ctab->cfis; if((r->ataproto & Pprotom) != Ppkt){ - memmove(c, r->cmd, r->clen); + jehanne_memmove(c, r->cmd, r->clen); flags = Lpref; if(r->ataproto&Pout && n > 0) flags |= Lwrite; @@ -1483,12 +1483,12 @@ io(Drive *d, uint32_t proto, int totk, int interrupt) flag &= ~Fdone; /* either an error or do-over */ } if(flag == 0){ - print("%s: retry\n", dnam(d)); + jehanne_print("%s: retry\n", dnam(d)); return SDretry; } if(flag & (Fahdrs | Ferror)){ if((task & Eidnf) == 0) - print("%s: i/o error %ux\n", dnam(d), task); + jehanne_print("%s: i/o error %ux\n", dnam(d), task); return SDcheck; } return rv; @@ -1526,7 +1526,7 @@ iariopkt(SDreq *r, Drive *d) r->rlen = d->portm.list->len; return SDok; } - print("%s: atapi timeout %dms\n", dnam(d), TK2MS(δ)); + jehanne_print("%s: atapi timeout %dms\n", dnam(d), TK2MS(δ)); return r->status = SDcheck; } @@ -1575,7 +1575,7 @@ sdr0(Drive *d) uint8_t *c; c = d->portm.fis.r; - memmove(c, bogusrfis, sizeof bogusrfis); + jehanne_memmove(c, bogusrfis, sizeof bogusrfis); coherence(); } @@ -1591,7 +1591,7 @@ sdr(SDreq *r, Drive *d, int st) st = t >> 8 + 4 & 0xf; } c = d->portm.fis.r; - memmove(r->cmd, c, 16); + jehanne_memmove(r->cmd, c, 16); r->status = st; if(st == SDcheck) st = SDok; @@ -1687,7 +1687,7 @@ iasetupahci(Ctlr *c) static void sbsetupahci(Pcidev *p) { - print("sbsetupahci: tweaking %.4ux ccru %.2ux ccrp %.2ux\n", + jehanne_print("sbsetupahci: tweaking %.4ux ccru %.2ux ccrp %.2ux\n", p->did, p->ccru, p->ccrp); pcicfgw8(p, 0x40, pcicfgr8(p, 0x40) | 1); pcicfgw8(p, PciCCRu, 6); @@ -1819,7 +1819,7 @@ iapnp(void) if(done) return nil; done = 1; - memset(olds, 0xff, sizeof olds); + jehanne_memset(olds, 0xff, sizeof olds); p = nil; loop: while((p = pcimatch(p, 0, 0)) != nil){ @@ -1828,18 +1828,18 @@ loop: if(p->mem[Abar].bar == 0) continue; if(niactlr == NCtlr){ - print("iapnp: %s: too many controllers\n", cttab[type].name); + jehanne_print("iapnp: %s: too many controllers\n", cttab[type].name); break; } c = iactlr + niactlr; s = sdevs + niactlr; - memset(c, 0, sizeof *c); - memset(s, 0, sizeof *s); + jehanne_memset(c, 0, sizeof *c); + jehanne_memset(s, 0, sizeof *s); c->type = cttab + type; io = p->mem[Abar].bar & ~(uintmem)0xf; c->mmio = vmap(io, p->mem[Abar].size); if(c->mmio == nil){ - print("%s: %T: address %#P in use\n", + jehanne_print("%s: %T: address %#P in use\n", tnam(c), p->tbdf, io); continue; } @@ -1868,7 +1868,7 @@ loop: c->ndrive = s->nunit = nunit; /* map the drives -- they don't all need to be enabled. */ - memset(c->rawdrive, 0, sizeof c->rawdrive); + jehanne_memset(c->rawdrive, 0, sizeof c->rawdrive); n = 0; for(i = 0; i < NCtlrdrv; i++){ d = c->rawdrive + i; @@ -1881,7 +1881,7 @@ loop: d->ctlr = c; if((c->pi & 1<name, sizeof d->name, "iahci%d.%d", niactlr, i); + jehanne_snprint(d->name, sizeof d->name, "iahci%d.%d", niactlr, i); d->port = (Aport*)(c->mmio + 0x80*i + 0x100); d->portc.p = d->port; d->portc.m = &d->portm; @@ -1891,7 +1891,7 @@ loop: } for(i = 0; i < n; i++) if(ahciidle(c->drive[i]->port) == -1){ - print("%s: port %d wedged; abort\n", + jehanne_print("%s: port %d wedged; abort\n", tnam(c), i); goto loop; } @@ -1905,7 +1905,7 @@ loop: niactlr++; sdadddevs(s); i = (c->hba->cap >> 21) & 1; - print("#S/%s: %s: sata-%s with %d ports\n", s->name, + jehanne_print("#S/%s: %s: sata-%s with %d ports\n", s->name, tnam(c), "I\0II" + i*2, nunit); } return nil; @@ -1940,7 +1940,7 @@ capfmt(char *p, char *e, Htab *t, int n, uint32_t cap) *p = 0; for(i = 0; i < n; i++) if(cap & t[i].bit) - p = seprint(p, e, "%s ", t[i].name); + p = jehanne_seprint(p, e, "%s ", t[i].name); return p; } @@ -1962,16 +1962,16 @@ iarctl(SDunit *u, char *p, int l) if(d->state == Dready) p = sfisxrdctl(&d->portm, p, e); else - p = seprint(p, e, "no disk present [%s]\n", dstate(d->state)); + p = jehanne_seprint(p, e, "no disk present [%s]\n", dstate(d->state)); serrstr(o->serror, buf, buf + sizeof buf - 1); - p = seprint(p, e, "reg\ttask %ux cmd %ux serr %ux %s ci %ux is %ux " + p = jehanne_seprint(p, e, "reg\ttask %ux cmd %ux serr %ux %s ci %ux is %ux " "sig %ux sstatus %.3ux\n", o->task, o->cmd, o->serror, buf, o->ci, o->isr, o->sig, o->sstatus); - p = seprint(p, e, "cmd\t"); + p = jehanne_seprint(p, e, "cmd\t"); p = capfmt(p, e, ctab, nelem(ctab), o->cmd); - p = seprint(p, e, "\n"); - p = seprint(p, e, "mode\t%s %s\n", modes[d->mode], modes[maxmode(c)]); - p = seprint(p, e, "geometry %llud %lud\n", u->sectors, u->secsize); + p = jehanne_seprint(p, e, "\n"); + p = jehanne_seprint(p, e, "mode\t%s %s\n", modes[d->mode], modes[maxmode(c)]); + p = jehanne_seprint(p, e, "geometry %llud %lud\n", u->sectors, u->secsize); return p - op; } @@ -1981,7 +1981,7 @@ forcemode(Drive *d, char *mode) int i; for(i = 0; i < nelem(modes); i++) - if(strcmp(mode, modes[i]) == 0) + if(jehanne_strcmp(mode, modes[i]) == 0) break; if(i == nelem(modes)) i = 0; @@ -1996,7 +1996,7 @@ forcestate(Drive *d, char *state) int i; for(i = 1; i < nelem(diskstates); i++) - if(strcmp(state, diskstates[i]) == 0) + if(jehanne_strcmp(state, diskstates[i]) == 0) break; if(i == nelem(diskstates)) error(Ebadctl); @@ -2014,9 +2014,9 @@ iawctl(SDunit *u, Cmdbuf *cmd) d = c->drive[u->subno]; f = cmd->f; - if(strcmp(f[0], "mode") == 0) + if(jehanne_strcmp(f[0], "mode") == 0) forcemode(d, f[1]? f[1]: "satai"); - else if(strcmp(f[0], "state") == 0) + else if(jehanne_strcmp(f[0], "state") == 0) forcestate(d, f[1]? f[1]: "null"); else cmderror(cmd, Ebadctl); @@ -2033,18 +2033,18 @@ portr(char *p, char *e, uint32_t x) for(i = 0; i < 32; i++){ if((x & (1< 0) - p = seprint(p, e, ", "); - p = seprint(p, e, "%d", a = i); + p = jehanne_seprint(p, e, ", "); + p = jehanne_seprint(p, e, "%d", a = i); } } if(a != -1 && i - 1 != a) - p = seprint(p, e, "-%d", i - 1); + p = jehanne_seprint(p, e, "-%d", i - 1); return p; } @@ -2096,12 +2096,12 @@ iartopctl(SDev *s, char *p, char *e) c = s->ctlr; h = c->hba; cap = h->cap; - p = seprint(p, e, "sd%c ahci %s port %#p: ", s->idno, tnam(c), h); + p = jehanne_seprint(p, e, "sd%c ahci %s port %#p: ", s->idno, tnam(c), h); p = capfmt(p, e, htab, nelem(htab), cap); p = capfmt(p, e, htab2, nelem(htab2), h->cap2); p = capfmt(p, e, emtab, nelem(emtab), h->emctl); portr(pr, pr + sizeof pr, h->pi); - return seprint(p, e, + return jehanne_seprint(p, e, "iss %d ncs %d np %d ghc %ux isr %ux pi %ux %s ver %ux\n", (cap>>20) & 0xf, (cap>>8) & 0x1f, 1 + (cap & 0x1f), h->ghc, h->isr, h->pi, pr, h->ver); @@ -2116,13 +2116,13 @@ iawtopctl(SDev *, Cmdbuf *cmd) f = cmd->f; v = 0; - if(strcmp(f[0], "debug") == 0) + if(jehanne_strcmp(f[0], "debug") == 0) v = &debug; - else if(strcmp(f[0], "idprint") == 0) + else if(jehanne_strcmp(f[0], "idprint") == 0) v = &prid; - else if(strcmp(f[0], "aprint") == 0) + else if(jehanne_strcmp(f[0], "aprint") == 0) v = &datapi; - else if(strcmp(f[0], "ledprint") == 0) + else if(jehanne_strcmp(f[0], "ledprint") == 0) v = &dled; else cmderror(cmd, Ebadctl); @@ -2134,7 +2134,7 @@ iawtopctl(SDev *, Cmdbuf *cmd) *v ^= 1; return 0; case 2: - *v = strcmp(f[1], "on") == 0; + *v = jehanne_strcmp(f[1], "on") == 0; return 0; } } diff --git a/sys/src/kern/amd64/sdata.c b/sys/src/kern/amd64/sdata.c index 2e10f71..b5fec17 100644 --- a/sys/src/kern/amd64/sdata.c +++ b/sys/src/kern/amd64/sdata.c @@ -380,27 +380,27 @@ atadumpstate(Drive* drive, uint8_t* cmd, int64_t lba, int count) } ctlr = drive->ctlr; - print("sdata: command %2.2uX\n", ctlr->command); - print("data %8.8p limit %8.8p dlen %d status %uX error %uX\n", + jehanne_print("sdata: command %2.2uX\n", ctlr->command); + jehanne_print("data %8.8p limit %8.8p dlen %d status %uX error %uX\n", drive->data, drive->limit, drive->dlen, drive->status, drive->error); if(cmd != nil){ - print("lba %d -> %lld, count %d -> %d (%d)\n", + jehanne_print("lba %d -> %lld, count %d -> %d (%d)\n", (cmd[2]<<24)|(cmd[3]<<16)|(cmd[4]<<8)|cmd[5], lba, (cmd[7]<<8)|cmd[8], count, drive->count); } if(!(inb(ctlr->ctlport+As) & Bsy)){ for(i = 1; i < 7; i++) - print(" 0x%2.2uX", inb(ctlr->cmdport+i)); - print(" 0x%2.2uX\n", inb(ctlr->ctlport+As)); + jehanne_print(" 0x%2.2uX", inb(ctlr->cmdport+i)); + jehanne_print(" 0x%2.2uX\n", inb(ctlr->ctlport+As)); } if(drive->command == Cwd || drive->command == Crd){ bmiba = ctlr->bmiba; prd = ctlr->prdt; - print("bmicx %2.2uX bmisx %2.2uX prdt %8.8p\n", + jehanne_print("bmicx %2.2uX bmisx %2.2uX prdt %8.8p\n", inb(bmiba+Bmicx), inb(bmiba+Bmisx), prd); for(;;){ - print("pa 0x%8.8luX count %8.8uX\n", + jehanne_print("pa 0x%8.8luX count %8.8uX\n", prd->pa, prd->count); if(prd->count & PrdEOT) break; @@ -409,10 +409,10 @@ atadumpstate(Drive* drive, uint8_t* cmd, int64_t lba, int count) } if(ctlr->pcidev && ctlr->pcidev->vid == 0x8086){ p = ctlr->pcidev; - print("0x40: %4.4uX 0x42: %4.4uX", + jehanne_print("0x40: %4.4uX 0x42: %4.4uX", pcicfgr16(p, 0x40), pcicfgr16(p, 0x42)); - print("0x48: %2.2uX\n", pcicfgr8(p, 0x48)); - print("0x4A: %4.4uX\n", pcicfgr16(p, 0x4A)); + jehanne_print("0x48: %2.2uX\n", pcicfgr8(p, 0x48)); + jehanne_print("0x4A: %4.4uX\n", pcicfgr16(p, 0x4A)); } } @@ -429,21 +429,21 @@ atadebug(int cmdport, int ctlport, char* fmt, ...) } va_start(arg, fmt); - n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); if(cmdport){ if(buf[n-1] == '\n') n--; - n += snprint(buf+n, PRINTSIZE-n, " ataregs 0x%uX:", + n += jehanne_snprint(buf+n, PRINTSIZE-n, " ataregs 0x%uX:", cmdport); for(i = Features; i < Command; i++) - n += snprint(buf+n, PRINTSIZE-n, " 0x%2.2uX", + n += jehanne_snprint(buf+n, PRINTSIZE-n, " 0x%2.2uX", inb(cmdport+i)); if(ctlport) - n += snprint(buf+n, PRINTSIZE-n, " 0x%2.2uX", + n += jehanne_snprint(buf+n, PRINTSIZE-n, " 0x%2.2uX", inb(ctlport+As)); - n += snprint(buf+n, PRINTSIZE-n, "\n"); + n += jehanne_snprint(buf+n, PRINTSIZE-n, "\n"); } putstrn(buf, n); @@ -609,7 +609,7 @@ ataidentify(int cmdport, int ctlport, int dev, int pkt, void* info) if(as & Err) return as; - memset(info, 0, 512); + jehanne_memset(info, 0, 512); inss(cmdport+Data, info, 256); inb(cmdport+Status); @@ -620,11 +620,11 @@ ataidentify(int cmdport, int ctlport, int dev, int pkt, void* info) sp = (uint16_t*)info; for(i = 0; i < 256; i++){ if(i && (i%16) == 0) - print("\n"); - print(" %4.4uX", *sp); + jehanne_print("\n"); + jehanne_print(" %4.4uX", *sp); sp++; } - print("\n"); + jehanne_print("\n"); } return 0; @@ -651,10 +651,10 @@ retry: goto retry; } - if((drive = malloc(sizeof(Drive))) == nil) + if((drive = jehanne_malloc(sizeof(Drive))) == nil) return nil; drive->dev = dev; - memmove(drive->info, buf, sizeof(drive->info)); + jehanne_memmove(drive->info, buf, sizeof(drive->info)); drive->sense[0] = 0x70; drive->sense[7] = sizeof(drive->sense)-7; @@ -716,15 +716,15 @@ retry: atadmamode(drive); if(DEBUG & DbgCONFIG){ - print("dev %2.2uX port %uX config %4.4uX capabilities %4.4uX", + jehanne_print("dev %2.2uX port %uX config %4.4uX capabilities %4.4uX", dev, cmdport, iconfig, drive->info[Icapabilities]); - print(" mwdma %4.4uX", drive->info[Imwdma]); + jehanne_print(" mwdma %4.4uX", drive->info[Imwdma]); if(drive->info[Ivalid] & 0x04) - print(" udma %4.4uX", drive->info[Iudma]); - print(" dma %8.8uX rwm %ud", drive->dma, drive->rwm); + jehanne_print(" udma %4.4uX", drive->info[Iudma]); + jehanne_print(" dma %8.8uX rwm %ud", drive->dma, drive->rwm); if(drive->flags&Lba48) - print("\tLLBA sectors %lld", drive->sectors); - print("\n"); + jehanne_print("\tLLBA sectors %lld", drive->sectors); + jehanne_print("\n"); } return drive; @@ -756,15 +756,15 @@ ataprobe(int cmdport, int ctlport, int irq) static int nonlegacy = 'C'; if(cmdport == 0) { - print("ataprobe: cmdport is 0\n"); + jehanne_print("ataprobe: cmdport is 0\n"); return nil; } if(ioalloc(cmdport, 8, 0, "atacmd") < 0) { - print("ataprobe: Cannot allocate %X\n", cmdport); + jehanne_print("ataprobe: Cannot allocate %X\n", cmdport); return nil; } if(ioalloc(ctlport+As, 1, 0, "atactl") < 0){ - print("ataprobe: Cannot allocate %X\n", ctlport + As); + jehanne_print("ataprobe: Cannot allocate %X\n", ctlport + As); iofree(cmdport); return nil; } @@ -860,17 +860,17 @@ tryedd1: */ if((drive = atadrive(cmdport, ctlport, dev)) == nil) goto release; - if((ctlr = malloc(sizeof(Ctlr))) == nil){ - free(drive); + if((ctlr = jehanne_malloc(sizeof(Ctlr))) == nil){ + jehanne_free(drive); goto release; } - memset(ctlr, 0, sizeof(Ctlr)); - if((sdev = malloc(sizeof(SDev))) == nil){ - free(ctlr); - free(drive); + jehanne_memset(ctlr, 0, sizeof(Ctlr)); + if((sdev = jehanne_malloc(sizeof(SDev))) == nil){ + jehanne_free(ctlr); + jehanne_free(drive); goto release; } - memset(sdev, 0, sizeof(SDev)); + jehanne_memset(sdev, 0, sizeof(SDev)); drive->ctlr = ctlr; if(dev == Dev0){ ctlr->drive[0] = drive; @@ -933,17 +933,17 @@ ataclear(SDev *sdev) iofree(ctlr->ctlport + As); if (ctlr->drive[0]) - free(ctlr->drive[0]); + jehanne_free(ctlr->drive[0]); if (ctlr->drive[1]) - free(ctlr->drive[1]); + jehanne_free(ctlr->drive[1]); if (sdev->name) - free(sdev->name); + jehanne_free(sdev->name); if (sdev->unitflg) - free(sdev->unitflg); + jehanne_free(sdev->unitflg); if (sdev->unit) - free(sdev->unit); - free(ctlr); - free(sdev); + jehanne_free(sdev->unit); + jehanne_free(ctlr); + jehanne_free(sdev); } static char * @@ -951,7 +951,7 @@ atastat(SDev *sdev, char *p, char *e) { Ctlr *ctlr = sdev->ctlr; - return seprint(p, e, "%s ata port %X ctl %X irq %d " + return jehanne_seprint(p, e, "%s ata port %X ctl %X irq %d " "intr-ok %lud intr-busy %lud intr-nil-drive %lud\n", sdev->name, ctlr->cmdport, ctlr->ctlport, ctlr->irq, ctlr->intok, ctlr->intbusy, ctlr->intnil); @@ -966,10 +966,10 @@ ataprobew(DevConf *cf) if (cf->nports != 2) error(Ebadarg); - memset(&isa, 0, sizeof isa); + jehanne_memset(&isa, 0, sizeof isa); isa.port = cf->ports[0].port; isa.irq = cf->intnum; - //if((p=strchr(cf->type, '/')) == nil || pcmspecial(p+1, &isa) < 0) + //if((p=jehanne_strchr(cf->type, '/')) == nil || pcmspecial(p+1, &isa) < 0) // error("cannot find controller"); return ataprobe(cf->ports[0].port, cf->ports[1].port, cf->intnum); @@ -1008,10 +1008,10 @@ atamodesense(Drive* drive, uint8_t* cmd) return atasetsense(drive, SDcheck, 0x05, 0x1A, 0); if(drive->data == nil || drive->dlen < len) return atasetsense(drive, SDcheck, 0x05, 0x20, 1); - memset(drive->data, 0, 8); + jehanne_memset(drive->data, 0, 8); drive->data[0] = sizeof(drive->info)>>8; drive->data[1] = (uint8_t)sizeof(drive->info); - memmove(drive->data+8, drive->info, sizeof(drive->info)); + jehanne_memmove(drive->data+8, drive->info, sizeof(drive->info)); drive->data += 8+sizeof(drive->info); return SDok; @@ -1122,7 +1122,7 @@ atadmasetup(Drive* drive, int len) prd = ctlr->prdt; if(prd == nil){ drive->dmactl = 0; - print("disabling dma: not on a busmastering controller\n"); + jehanne_print("disabling dma: not on a busmastering controller\n"); return -1; } @@ -1277,8 +1277,8 @@ atapktio(Drive* drive, uint8_t* cmd, int clen) r = SDok; drive->command = Cpkt; - memmove(drive->pktcmd, cmd, clen); - memset(drive->pktcmd+clen, 0, drive->pkt-clen); + jehanne_memmove(drive->pktcmd, cmd, clen); + jehanne_memset(drive->pktcmd+clen, 0, drive->pkt-clen); drive->limit = drive->data+drive->dlen; ctlr = drive->ctlr; @@ -1437,7 +1437,7 @@ atageniostart(Drive* drive, uint64_t lba) cmd = cmd48[cmd]; if(DEBUG & Dbg48BIT) - print("using 48-bit commands\n"); + jehanne_print("using 48-bit commands\n"); } else{ outb(cmdport+Count, drive->count); @@ -1482,7 +1482,7 @@ atagenioretry(Drive* drive) { if(drive->dmactl){ drive->dmactl = 0; - print("atagenioretry: disabling dma\n"); + jehanne_print("atagenioretry: disabling dma\n"); } else if(drive->rwmctl) drive->rwmctl = 0; @@ -1521,7 +1521,7 @@ atagenio(Drive* drive, uint8_t* cmd, int clen) else len = sizeof(drive->sense); if(drive->data && drive->dlen >= len){ - memmove(drive->data, drive->sense, len); + jehanne_memmove(drive->data, drive->sense, len); drive->data += len; } return SDok; @@ -1532,7 +1532,7 @@ atagenio(Drive* drive, uint8_t* cmd, int clen) else len = sizeof(drive->inquiry); if(drive->data && drive->dlen >= len){ - memmove(drive->data, drive->inquiry, len); + jehanne_memmove(drive->data, drive->inquiry, len); drive->data += len; } return SDok; @@ -1695,7 +1695,7 @@ atario(SDreq* r) case 0x08: /* read */ case 0x0A: /* write */ cmdp = cmd10; - memset(cmdp, 0, sizeof(cmd10)); + jehanne_memset(cmdp, 0, sizeof(cmd10)); cmdp[0] = r->cmd[0]|0x20; cmdp[1] = r->cmd[1] & 0xE0; cmdp[5] = r->cmd[3]; @@ -1725,7 +1725,7 @@ retry: status = atagenio(drive, cmdp, clen); if(status == SDretry){ if(DbgDEBUG) - print("%s: retry: dma %8.8uX rwm %4.4uX\n", + jehanne_print("%s: retry: dma %8.8uX rwm %4.4uX\n", unit->SDperm.name, drive->dmactl, drive->rwmctl); goto retry; } @@ -1740,7 +1740,7 @@ retry: } else if(status == SDcheck && !(r->flags & SDnosense)){ drive->write = 0; - memset(cmd10, 0, sizeof(cmd10)); + jehanne_memset(cmd10, 0, sizeof(cmd10)); cmd10[0] = 0x03; cmd10[1] = r->lun<<5; cmd10[4] = sizeof(r->sense)-1; @@ -1807,7 +1807,7 @@ atainterrupt(Ureg *ureg, void* arg) ctlr->intbusy++; iunlock(&ctlr->l); if(DEBUG & DbgBsy) - print("IBsy+"); + jehanne_print("IBsy+"); return; } cmdport = ctlr->cmdport; @@ -1818,7 +1818,7 @@ atainterrupt(Ureg *ureg, void* arg) ctlr->irqack(ctlr); iunlock(&ctlr->l); if((DEBUG & DbgINL) && ctlr->command != Cedd) - print("Inil%2.2uX+", ctlr->command); + jehanne_print("Inil%2.2uX+", ctlr->command); return; } @@ -2115,7 +2115,7 @@ atapnp(void) ctlr = sdev->ctlr; if(ispc87415) { ctlr->ienable = pc87415ienable; - print("pc87415disable: not yet implemented\n"); + jehanne_print("pc87415disable: not yet implemented\n"); } if(head != nil) @@ -2161,11 +2161,11 @@ ataenable(SDev* sdev) #define ALIGN (4 * 1024) if(ctlr->pcidev != nil) pcisetbme(ctlr->pcidev); - ctlr->prdt = mallocalign(Nprd*sizeof(Prd), 4, 0, 4*1024); + ctlr->prdt = jehanne_mallocalign(Nprd*sizeof(Prd), 4, 0, 4*1024); if(ctlr->prdt == nil) error(Enomem); } - snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name); + jehanne_snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name); ctlr->vector = intrenable(ctlr->irq, atainterrupt, ctlr, ctlr->tbdf, name); outb(ctlr->ctlport+Dc, 0); if(ctlr->ienable) @@ -2184,12 +2184,12 @@ atadisable(SDev *sdev) outb(ctlr->ctlport+Dc, Nien); /* disable interrupts */ if (ctlr->idisable) ctlr->idisable(ctlr); - snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name); + jehanne_snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name); intrdisable(ctlr->vector); if (ctlr->bmiba) { if (ctlr->pcidev) pciclrbme(ctlr->pcidev); - free(ctlr->prdt); + jehanne_free(ctlr->prdt); } return 0; } @@ -2206,27 +2206,27 @@ atarctl(SDunit* unit, char* p, int l) drive = ctlr->drive[unit->subno]; qlock(&drive->ql); - n = snprint(p, l, "config %4.4uX capabilities %4.4uX", + n = jehanne_snprint(p, l, "config %4.4uX capabilities %4.4uX", drive->info[Iconfig], drive->info[Icapabilities]); if(drive->dma) - n += snprint(p+n, l-n, " dma %8.8uX dmactl %8.8uX", + n += jehanne_snprint(p+n, l-n, " dma %8.8uX dmactl %8.8uX", drive->dma, drive->dmactl); if(drive->rwm) - n += snprint(p+n, l-n, " rwm %ud rwmctl %ud", + n += jehanne_snprint(p+n, l-n, " rwm %ud rwmctl %ud", drive->rwm, drive->rwmctl); if(drive->flags&Lba48) - n += snprint(p+n, l-n, " lba48always %s", + n += jehanne_snprint(p+n, l-n, " lba48always %s", (drive->flags&Lba48always) ? "on" : "off"); - n += snprint(p+n, l-n, "\n"); - n += snprint(p+n, l-n, "interrupts read %lud write %lud cmds %lud\n", + n += jehanne_snprint(p+n, l-n, "\n"); + n += jehanne_snprint(p+n, l-n, "interrupts read %lud write %lud cmds %lud\n", drive->intrd, drive->intwr, drive->intcmd); if(drive->sectors){ - n += snprint(p+n, l-n, "geometry %lld %d", + n += jehanne_snprint(p+n, l-n, "geometry %lld %d", drive->sectors, drive->secsize); if(drive->pkt == 0) - n += snprint(p+n, l-n, " %d %d %d", + n += jehanne_snprint(p+n, l-n, " %d %d %d", drive->c, drive->h, drive->s); - n += snprint(p+n, l-n, "\n"); + n += jehanne_snprint(p+n, l-n, "\n"); } qunlock(&drive->ql); @@ -2256,32 +2256,32 @@ atawctl(SDunit* unit, Cmdbuf* cb) * correctly already either by the BIOS or when * the drive was initially identified. */ - if(strcmp(cb->f[0], "dma") == 0){ + if(jehanne_strcmp(cb->f[0], "dma") == 0){ if(cb->nf != 2 || drive->dma == 0) error(Ebadctl); - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) drive->dmactl = drive->dma; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) drive->dmactl = 0; else error(Ebadctl); } - else if(strcmp(cb->f[0], "rwm") == 0){ + else if(jehanne_strcmp(cb->f[0], "rwm") == 0){ if(cb->nf != 2 || drive->rwm == 0) error(Ebadctl); - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) drive->rwmctl = drive->rwm; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) drive->rwmctl = 0; else error(Ebadctl); } - else if(strcmp(cb->f[0], "standby") == 0){ + else if(jehanne_strcmp(cb->f[0], "standby") == 0){ switch(cb->nf){ default: error(Ebadctl); case 2: - period = strtol(cb->f[1], 0, 0); + period = jehanne_strtol(cb->f[1], 0, 0); if(period && (period < 30 || period > 240*5)) error(Ebadctl); period /= 5; @@ -2290,12 +2290,12 @@ atawctl(SDunit* unit, Cmdbuf* cb) if(atastandby(drive, period) != SDok) error(Ebadctl); } - else if(strcmp(cb->f[0], "lba48always") == 0){ + else if(jehanne_strcmp(cb->f[0], "lba48always") == 0){ if(cb->nf != 2 || !(drive->flags&Lba48)) error(Ebadctl); - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) drive->flags |= Lba48always; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) drive->flags &= ~Lba48always; else error(Ebadctl); diff --git a/sys/src/kern/amd64/sipi.c b/sys/src/kern/amd64/sipi.c index 9cfd13a..8c95e81 100644 --- a/sys/src/kern/amd64/sipi.c +++ b/sys/src/kern/amd64/sipi.c @@ -44,8 +44,8 @@ sipi(void) if((sipipa & (4*KiB - 1)) || sipipa > (1*MiB - 2*4*KiB)) return; sipiptr = UINT2PTR(SIPIHANDLER); - memmove(sipiptr, sipihandler, sizeof(sipihandler)); - memset(sipiptr+4*KiB, 0, sizeof(Sipi)*Napic); + jehanne_memmove(sipiptr, sipihandler, sizeof(sipihandler)); + jehanne_memset(sipiptr+4*KiB, 0, sizeof(Sipi)*Napic); /* * Notes: @@ -61,7 +61,7 @@ sipi(void) if(apic == nil || !apic->useable || apic->machno == 0) continue; if(++nproc >= MACHMAX){ - print("sipi: MACHMAX too small, need %d\n", nproc); + jehanne_print("sipi: MACHMAX too small, need %d\n", nproc); break; } sipi = &((Sipi*)(sipiptr+4*KiB))[apicno]; @@ -71,10 +71,10 @@ sipi(void) * bootstrap processor, until this code is worked out, * so only the Mach and stack portions are used below. */ - alloc = mallocalign(MACHSTKSZ+4*PTSZ+4*KiB+MACHSZ, 4096, 0, 0); + alloc = jehanne_mallocalign(MACHSTKSZ+4*PTSZ+4*KiB+MACHSZ, 4096, 0, 0); if(alloc == nil) continue; - memset(alloc, 0, MACHSTKSZ+4*PTSZ+4*KiB+MACHSZ); + jehanne_memset(alloc, 0, MACHSTKSZ+4*PTSZ+4*KiB+MACHSZ); p = alloc+MACHSTKSZ; sipi->pml4 = cr3get(); diff --git a/sys/src/kern/amd64/syscall.c b/sys/src/kern/amd64/syscall.c index 1a485a9..4164798 100644 --- a/sys/src/kern/amd64/syscall.c +++ b/sys/src/kern/amd64/syscall.c @@ -84,7 +84,7 @@ noted(Ureg* cur, uintptr_t arg0) nur->flags &= (Of|Df|Sf|Zf|Af|Pf|Cf); nur->flags |= cur->flags & ~(Of|Df|Sf|Zf|Af|Pf|Cf); - memmove(cur, nur, sizeof(Ureg)); + jehanne_memmove(cur, nur, sizeof(Ureg)); switch((int)arg0){ case NCONT: @@ -115,13 +115,13 @@ noted(Ureg* cur, uintptr_t arg0) cur->sp = PTR2UINT(nf); break; default: - memmove(¬e, &up->lastnote, sizeof(Note)); + jehanne_memmove(¬e, &up->lastnote, sizeof(Note)); qunlock(&up->debug); pprint("suicide: bad arg %#p in noted: %s\n", arg0, note.msg); pexit(note.msg, 0); break; case NDFLT: - memmove(¬e, &up->lastnote, sizeof(Note)); + jehanne_memmove(¬e, &up->lastnote, sizeof(Note)); qunlock(&up->debug); if(note.flag == NDebug) pprint("suicide: %s\n", note.msg); @@ -155,12 +155,12 @@ notify(Ureg* ureg) up->notepending = 0; up->notedeferred = 0; - memmove(¬e, &up->note[0], sizeof(Note)); - if(strncmp(note.msg, "sys:", 4) == 0){ - l = strlen(note.msg); + jehanne_memmove(¬e, &up->note[0], sizeof(Note)); + if(jehanne_strncmp(note.msg, "sys:", 4) == 0){ + l = jehanne_strlen(note.msg); if(l > ERRMAX-sizeof(" pc=0x0123456789abcdef")) l = ERRMAX-sizeof(" pc=0x0123456789abcdef"); - sprint(note.msg+l, " pc=%#p", ureg->ip); + jehanne_sprint(note.msg+l, " pc=%#p", ureg->ip); } if(note.flag != NUser && (up->notified || up->notify == nil)){ @@ -195,10 +195,10 @@ notify(Ureg* ureg) } nf = UINT2PTR(sp); - memmove(&nf->ureg, ureg, sizeof(Ureg)); + jehanne_memmove(&nf->ureg, ureg, sizeof(Ureg)); nf->old = up->ureg; up->ureg = nf; - memmove(nf->msg, note.msg, ERRMAX); + jehanne_memmove(nf->msg, note.msg, ERRMAX); nf->arg1 = nf->msg; nf->arg0 = &nf->ureg; ureg->di = (uintptr_t)nf->arg0; @@ -210,8 +210,8 @@ notify(Ureg* ureg) ureg->ip = PTR2UINT(up->notify); up->notified = 1; up->nnote--; - memmove(&up->lastnote, ¬e, sizeof(Note)); - memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note)); + jehanne_memmove(&up->lastnote, ¬e, sizeof(Note)); + jehanne_memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note)); qunlock(&up->debug); splx(s); @@ -266,27 +266,27 @@ syscall(Syscalls scallnr, Ureg* ureg) if(sp < (USTKTOP-PGSZ) || sp > (USTKTOP-sizeof(up->arg)-BY2SE)) validaddr(UINT2PTR(sp), sizeof(up->arg)+BY2SE, 0); - memmove(up->arg, UINT2PTR(sp+BY2SE), sizeof(up->arg)); + jehanne_memmove(up->arg, UINT2PTR(sp+BY2SE), sizeof(up->arg)); up->psstate = tmp; if(printallsyscalls || up->syscallq != nil){ str = syscallfmt(scallnr, ureg); if(printallsyscalls){ - print("%s\n", str); + jehanne_print("%s\n", str); } if(up->syscallq != nil){ qlock(&up->debug); if(up->syscallq != nil){ notedefer(); if(!waserror()){ - qwrite(up->syscallq, str, strlen(str)); + qwrite(up->syscallq, str, jehanne_strlen(str)); poperror(); } noteallow(); } qunlock(&up->debug); } - free(str); + jehanne_free(str); startns = todget(nil); } dispatch_syscall(scallnr, ureg, &retv); @@ -302,9 +302,9 @@ syscall(Syscalls scallnr, Ureg* ureg) up->text, syscall_name(scallnr), up->syserrstr); } if(up->nerrlab){ - print("bad errstack [%d]: %d extra\n", scallnr, up->nerrlab); + jehanne_print("bad errstack [%d]: %d extra\n", scallnr, up->nerrlab); for(i = 0; i < NERR; i++) - print("sp=%#p pc=%#p\n", + jehanne_print("sp=%#p pc=%#p\n", up->errlab[i].sp, up->errlab[i].pc); panic("error stack"); } @@ -319,21 +319,21 @@ syscall(Syscalls scallnr, Ureg* ureg) stopns = todget(nil); str = sysretfmt(scallnr, ureg, &retv, startns, stopns); if(printallsyscalls){ - print("%s\n", str); + jehanne_print("%s\n", str); } if(up->syscallq != nil){ qlock(&up->debug); if(up->syscallq != nil){ notedefer(); if(!waserror()){ - qwrite(up->syscallq, str, strlen(str)); + qwrite(up->syscallq, str, jehanne_strlen(str)); poperror(); } noteallow(); } qunlock(&up->debug); } - free(str); + jehanne_free(str); } if(up->procctl == Proc_tracesyscall){ @@ -382,7 +382,7 @@ sysexecstack(uintptr_t stack, int argc) /* but we need to align the stack to 16 bytes, not 8 */ sp -= sp & 8 ? 8 : 0; - //print("For %d args, sp is now %p\n", argc, sp); + //jehanne_print("For %d args, sp is now %p\n", argc, sp); return sp; } @@ -394,7 +394,7 @@ sysexecregs(uintptr_t entry, uint32_t ssize) // We made sure it was correctly aligned in sysexecstack, above. if (ssize & 0xf) { - print("your stack is wrong: stacksize is not 16-byte aligned: %d\n", ssize); + jehanne_print("your stack is wrong: stacksize is not 16-byte aligned: %d\n", ssize); panic("misaligned stack in sysexecregs"); } sp = (uintptr_t*)(USTKTOP - ssize); @@ -436,7 +436,7 @@ sysrforkchild(Proc* child, Proc* parent) child->sched.pc = PTR2UINT(sysrforkret); cureg = (Ureg*)(child->sched.sp+STACKPAD*BY2SE); - memmove(cureg, parent->dbgreg, sizeof(Ureg)); + jehanne_memmove(cureg, parent->dbgreg, sizeof(Ureg)); /* Things from bottom of syscall which were never executed */ child->psstate = 0; diff --git a/sys/src/kern/amd64/trap.c b/sys/src/kern/amd64/trap.c index c3da721..c71dacd 100644 --- a/sys/src/kern/amd64/trap.c +++ b/sys/src/kern/amd64/trap.c @@ -54,27 +54,27 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name) Vctl *v; if(f == nil){ - print("intrenable: nil handler for %d, tbdf %#ux for %s\n", + jehanne_print("intrenable: nil handler for %d, tbdf %#ux for %s\n", irq, tbdf, name); return nil; } - v = malloc(sizeof(Vctl)); + v = jehanne_malloc(sizeof(Vctl)); v->isintr = 1; v->irq = irq; v->tbdf = tbdf; v->f = f; v->a = a; - strncpy(v->name, name, KNAMELEN-1); + jehanne_strncpy(v->name, name, KNAMELEN-1); v->name[KNAMELEN-1] = 0; ilock(&vctllock); vno = ioapicintrenable(v); if(vno == -1){ iunlock(&vctllock); - print("intrenable: couldn't enable irq %d, tbdf %#ux for %s\n", + jehanne_print("intrenable: couldn't enable irq %d, tbdf %#ux for %s\n", irq, tbdf, v->name); - free(v); + jehanne_free(v); return nil; } if(vctl[vno]){ @@ -118,7 +118,7 @@ intrdisable(void* vector) ioapicintrdisable(v->vno); iunlock(&vctllock); - free(v); + jehanne_free(v); return 0; } @@ -138,7 +138,7 @@ irqallocread(Chan* _1, void *vbuf, long n, int64_t offset) buf = vbuf; for(vno=0; vnonext){ - ns = snprint(str, sizeof str, "%11d %11d %.*s\n", vno, v->irq, KNAMELEN, v->name); + ns = jehanne_snprint(str, sizeof str, "%11d %11d %.*s\n", vno, v->irq, KNAMELEN, v->name); if(ns <= offset) /* if do not want this, skip entry */ offset -= ns; else{ @@ -150,7 +150,7 @@ irqallocread(Chan* _1, void *vbuf, long n, int64_t offset) /* write at most max(n,ns) bytes */ if(ns > n) ns = n; - memmove(buf, p, ns); + jehanne_memmove(buf, p, ns); n -= ns; buf += ns; @@ -169,11 +169,11 @@ trapenable(int vno, void (*f)(Ureg*, void*), void* a, char *name) if(vno < 0 || vno >= 256) panic("trapenable: vno %d\n", vno); - v = malloc(sizeof(Vctl)); + v = jehanne_malloc(sizeof(Vctl)); v->tbdf = BUSUNKNOWN; v->f = f; v->a = a; - strncpy(v->name, name, KNAMELEN); + jehanne_strncpy(v->name, name, KNAMELEN); v->name[KNAMELEN-1] = 0; ilock(&vctllock); @@ -336,7 +336,7 @@ trap(Ureg* ureg) spllo(); if(vno == 0xd) /* General Protection */ dumpregs(ureg); - snprint(buf, sizeof(buf), "sys: trap: %s", excname[vno]); + jehanne_snprint(buf, sizeof(buf), "sys: trap: %s", excname[vno]); postnote(up, 1, buf, NDebug); } else if(vno >= VectorPIC){ /* @@ -487,7 +487,7 @@ void callwithureg(void (*fn)(Ureg*)) { Ureg ureg; - memset(&ureg, 0, sizeof(ureg)); + jehanne_memset(&ureg, 0, sizeof(ureg)); ureg.ip = getcallerpc(); ureg.sp = PTR2UINT(&fn); fn(&ureg); @@ -501,7 +501,7 @@ dumpstackwithureg(Ureg* ureg) char *s; int x; - if((s = getconf("*nodumpstack")) != nil && atoi(s) != 0){ + if((s = getconf("*nodumpstack")) != nil && jehanne_atoi(s) != 0){ iprint("dumpstack disabled\n"); return; } @@ -555,7 +555,7 @@ debugbpt(Ureg* ureg, void* _1) panic("kernel bpt"); /* restore pc to instruction that caused the trap */ ureg->ip--; - sprint(buf, "sys: breakpoint"); + jehanne_sprint(buf, "sys: breakpoint"); postnote(up, 1, buf, NDebug); } @@ -609,7 +609,7 @@ faultamd64(Ureg* ureg, void* _1) insyscall = up->insyscall; up->insyscall = 1; if(iskaddr(addr)){ - print("kaddr %#llux pc %#p\n", addr, ureg->ip); + jehanne_print("kaddr %#llux pc %#p\n", addr, ureg->ip); // prflush(); dumpregs(ureg); } @@ -619,7 +619,7 @@ if(iskaddr(addr)){ dumpregs(ureg); panic("fault: %#llux pc %#p\n", addr, ureg->ip); } - sprint(buf, "sys: trap: fault %s addr=%#llux", + jehanne_sprint(buf, "sys: trap: fault %s addr=%#llux", fault_types[ftype], addr); proc_check_pages(); postnote(up, 1, buf, NDebug); @@ -656,7 +656,7 @@ setregisters(Ureg* ureg, char* pureg, char* uva, int n) // fs = ureg->cs; // es = ureg->cs; // ds = ureg->cs; - memmove(pureg, uva, n); + jehanne_memmove(pureg, uva, n); // ureg->ds = ds; // ureg->es = es; // ureg->fs = fs; diff --git a/sys/src/kern/amd64/usbehci.h b/sys/src/kern/amd64/usbehci.h index c256e4e..35d0407 100644 --- a/sys/src/kern/amd64/usbehci.h +++ b/sys/src/kern/amd64/usbehci.h @@ -3,10 +3,10 @@ #undef ddprint #undef deprint #undef ddeprint -#define dprint(...) do if(ehcidebug)print(__VA_ARGS__); while(0) -#define ddprint(...) do if(ehcidebug>1)print(__VA_ARGS__); while(0) -#define deprint(...) do if(ehcidebug || ep->debug)print(__VA_ARGS__); while(0) -#define ddeprint(...) do if(ehcidebug>1 || ep->debug>1)print(__VA_ARGS__); while(0) +#define dprint(...) do if(ehcidebug)jehanne_print(__VA_ARGS__); while(0) +#define ddprint(...) do if(ehcidebug>1)jehanne_print(__VA_ARGS__); while(0) +#define deprint(...) do if(ehcidebug || ep->debug)jehanne_print(__VA_ARGS__); while(0) +#define ddeprint(...) do if(ehcidebug>1 || ep->debug>1)jehanne_print(__VA_ARGS__); while(0) typedef struct Ctlr Ctlr; typedef struct Eopio Eopio; diff --git a/sys/src/kern/amd64/usbehcipc.c b/sys/src/kern/amd64/usbehcipc.c index 8547204..036d4e6 100644 --- a/sys/src/kern/amd64/usbehcipc.c +++ b/sys/src/kern/amd64/usbehcipc.c @@ -51,7 +51,7 @@ getehci(Ctlr* ctlr) delay(10); } if(i == 100) - print("ehci %#p: bios timed out\n", ctlr->capio); + jehanne_print("ehci %#p: bios timed out\n", ctlr->capio); } pcicfgw32(ctlr->pcidev, off+CLcontrol, 0); /* no SMIs */ } @@ -97,7 +97,7 @@ ehcireset(Ctlr *ctlr) delay(1); } if(i == 100) - print("ehci %#p controller reset timed out\n", ctlr->capio); + jehanne_print("ehci %#p controller reset timed out\n", ctlr->capio); } opio->cmd |= Citc1; /* 1 intr. per µframe */ coherence(); @@ -142,7 +142,7 @@ shutdown(Hci *hp) delay(1); } if(i >= 100) - print("ehci %#p controller reset timed out\n", ctlr->capio); + jehanne_print("ehci %#p controller reset timed out\n", ctlr->capio); delay(100); ehcirun(ctlr, 0); opio->frbase = 0; @@ -177,16 +177,16 @@ scanpci(void) continue; } if(io == 0){ - print("usbehci: %x %x: failed to map registers\n", + jehanne_print("usbehci: %x %x: failed to map registers\n", p->vid, p->did); continue; } dprint("usbehci: %#x %#x: port %#p size %#x irq %d\n", p->vid, p->did, io, p->mem[0].size, p->intl); - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil){ - print("usbehci: no memory\n"); + jehanne_print("usbehci: no memory\n"); continue; } ctlr->pcidev = p; @@ -200,7 +200,7 @@ scanpci(void) break; } if(i >= Nhcis) - print("ehci: bug: more than %d controllers\n", Nhcis); + jehanne_print("ehci: bug: more than %d controllers\n", Nhcis); /* * currently, if we enable a second ehci controller, @@ -226,7 +226,7 @@ reset(Hci *hp) s = getconf("*maxehci"); if (s != nil && s[0] >= '0' && s[0] <= '9') - maxehci = atoi(s); + maxehci = jehanne_atoi(s); if(maxehci == 0 || getconf("*nousbehci")) return -1; ilock(&resetlck); diff --git a/sys/src/kern/amd64/usbohci.c b/sys/src/kern/amd64/usbohci.c index ed87e80..a276cbc 100644 --- a/sys/src/kern/amd64/usbohci.c +++ b/sys/src/kern/amd64/usbohci.c @@ -352,10 +352,10 @@ struct Ctlr Pcidev* pcidev; }; -#define dqprint if(debug || io && io->debug)print -#define ddqprint if(debug>1 || (io && io->debug>1))print -#define diprint if(debug || iso && iso->debug)print -#define ddiprint if(debug>1 || (iso && iso->debug>1))print +#define dqprint if(debug || io && io->debug)jehanne_print +#define ddqprint if(debug>1 || (io && io->debug>1))jehanne_print +#define diprint if(debug || iso && iso->debug)jehanne_print +#define ddiprint if(debug>1 || (iso && iso->debug>1))jehanne_print #define TRUNC(x, sz) ((x) & ((sz)-1)) static int ohciinterrupts[Nttypes]; @@ -435,7 +435,7 @@ static void edlinked(Ed *ed, Ed *next) { if(ed == nil) - print("edlinked: nil ed: pc %#p\n", getcallerpc()); + jehanne_print("edlinked: nil ed: pc %#p\n", getcallerpc()); ed->nexted = ptr2pa(next); ed->next = next; } @@ -471,7 +471,7 @@ unlinkctl(Ctlr *ctlr, Ed *ed) this = this->next; } if(this == nil){ - print("unlinkctl: not found\n"); + jehanne_print("unlinkctl: not found\n"); return; } next = this->next; @@ -498,7 +498,7 @@ unlinkbulk(Ctlr *ctlr, Ed *ed) this = this->next; } if(this == nil){ - print("unlinkbulk: not found\n"); + jehanne_print("unlinkbulk: not found\n"); return; } next = this->next; @@ -580,7 +580,7 @@ tdalloc(void) lock(&tdpool.l); if(tdpool.free == nil){ ddprint("ohci: tdalloc %d Tds\n", Incr); - pool = mallocalign(Incr*ROUNDUP(sizeof(Td), Tdalign), Tdalign, 0, 0); + pool = jehanne_mallocalign(Incr*ROUNDUP(sizeof(Td), Tdalign), Tdalign, 0, 0); if(pool == nil) panic("ohci: tdalloc"); for(i=Incr; --i>=0;){ @@ -597,7 +597,7 @@ tdalloc(void) tdpool.free = td->next; unlock(&tdpool.l); assert(((uintptr_t)td & 0x1F) == 0); - memset(td, 0, sizeof(Td)); + jehanne_memset(td, 0, sizeof(Td)); return td; } @@ -611,7 +611,7 @@ tdfree(Td *td) lock(&tdpool.l); if(td->nexttd == 0x77777777) panic("ohci: tdfree: double free"); - memset(td, 7, sizeof(Td)); /* poison */ + jehanne_memset(td, 7, sizeof(Td)); /* poison */ td->next = tdpool.free; tdpool.free = td; tdpool.ninuse--; @@ -629,7 +629,7 @@ edalloc(void) lock(&edpool.l); if(edpool.free == nil){ ddprint("ohci: edalloc %d Eds\n", Incr); - pool = mallocalign(Incr*ROUNDUP(sizeof(Ed), Edalign), Edalign, 0, 0); + pool = jehanne_mallocalign(Incr*ROUNDUP(sizeof(Ed), Edalign), Edalign, 0, 0); if(pool == nil) panic("ohci: edalloc"); for(i=Incr; --i>=0;){ @@ -646,7 +646,7 @@ edalloc(void) edpool.free = ed->next; unlock(&edpool.l); assert(((uintptr_t)ed & 0xF) == 0); - memset(ed, 0, sizeof(Ed)); + jehanne_memset(ed, 0, sizeof(Ed)); return ed; } @@ -663,14 +663,14 @@ edfree(Ed *ed) next = td->next; tdfree(td); if(i++ > 2000){ - print("ohci: bug: ed with more than 2000 tds\n"); + jehanne_print("ohci: bug: ed with more than 2000 tds\n"); break; } } lock(&edpool.l); if(ed->nexted == 0x99999999) panic("ohci: edfree: double free"); - memset(ed, 9, sizeof(Ed)); /* poison */ + jehanne_memset(ed, 9, sizeof(Ed)); /* poison */ ed->next = edpool.free; edpool.free = ed; edpool.ninuse--; @@ -743,7 +743,7 @@ schedq(Ctlr *ctlr, Qio *io, int pollival) q = pickschedq(ctlr->tree, pollival, io->bw, ~0); ddqprint("ohci: sched %#p q %d, ival %d, bw %ld\n", io, q, pollival, io->bw); if(q < 0){ - print("ohci: no room for ed\n"); + jehanne_print("ohci: no room for ed\n"); return -1; } ctlr->tree->bw[q] += io->bw; @@ -775,7 +775,7 @@ unschedq(Ctlr *ctlr, Qio *qio) this = this->next; } if(this == nil) - print("ohci: unschedq %d: not found\n", q); + jehanne_print("ohci: unschedq %d: not found\n", q); else{ next = this->next; edlinked(prev, next); @@ -786,7 +786,7 @@ unschedq(Ctlr *ctlr, Qio *qio) *l = (*l)->inext; return; } - print("ohci: unschedq: ed %#p not found\n", qio->ed); + jehanne_print("ohci: unschedq: ed %#p not found\n", qio->ed); } static char* @@ -794,13 +794,13 @@ seprinttdtok(char *s, char *e, int tok) { switch(tok){ case Tdtoksetup: - s = seprint(s, e, " setup"); + s = jehanne_seprint(s, e, " setup"); break; case Tdtokin: - s = seprint(s, e, " in"); + s = jehanne_seprint(s, e, " in"); break; case Tdtokout: - s = seprint(s, e, " out"); + s = jehanne_seprint(s, e, " out"); break; } return s; @@ -814,36 +814,36 @@ seprinttd(char *s, char *e, Td *td, int iso) Block *bp; if(td == nil) - return seprint(s, e, "\n"); - s = seprint(s, e, "%#p ep %#p ctrl %#lux", td, td->ep, td->ctrl); - s = seprint(s, e, " cc=%#ulx", (td->ctrl >> Tdccshift) & Tdccmask); + return jehanne_seprint(s, e, "\n"); + s = jehanne_seprint(s, e, "%#p ep %#p ctrl %#lux", td, td->ep, td->ctrl); + s = jehanne_seprint(s, e, " cc=%#ulx", (td->ctrl >> Tdccshift) & Tdccmask); if(iso == 0){ if((td->ctrl & Tdround) != 0) - s = seprint(s, e, " rnd"); + s = jehanne_seprint(s, e, " rnd"); s = seprinttdtok(s, e, td->ctrl & Tdtokmask); if((td->ctrl & Tdusetog) != 0) - s = seprint(s, e, " d%d", (td->ctrl & Tddata1) ? 1 : 0); + s = jehanne_seprint(s, e, " d%d", (td->ctrl & Tddata1) ? 1 : 0); else - s = seprint(s, e, " d-"); - s = seprint(s, e, " ec=%uld", (td->ctrl >> Tderrshift) & Tderrmask); + s = jehanne_seprint(s, e, " d-"); + s = jehanne_seprint(s, e, " ec=%uld", (td->ctrl >> Tderrshift) & Tderrmask); }else{ - s = seprint(s, e, " fc=%uld", (td->ctrl >> Tdfcshift) & Tdfcmask); - s = seprint(s, e, " sf=%uld", td->ctrl & Tdsfmask); + s = jehanne_seprint(s, e, " fc=%uld", (td->ctrl >> Tdfcshift) & Tdfcmask); + s = jehanne_seprint(s, e, " sf=%uld", td->ctrl & Tdsfmask); } - s = seprint(s, e, " cbp0 %#lux cbp %#lux next %#lux be %#lux %s", + s = jehanne_seprint(s, e, " cbp0 %#lux cbp %#lux next %#lux be %#lux %s", td->cbp0, td->cbp, td->nexttd, td->be, td->last ? "last" : ""); - s = seprint(s, e, "\n\t\t%ld bytes", td->nbytes); + s = jehanne_seprint(s, e, "\n\t\t%ld bytes", td->nbytes); if((bp = td->bp) != nil){ - s = seprint(s, e, " rp %#p wp %#p ", bp->rp, bp->wp); + s = jehanne_seprint(s, e, " rp %#p wp %#p ", bp->rp, bp->wp); if(BLEN(bp) > 0) s = seprintdata(s, e, bp->rp, bp->wp - bp->rp); } if(iso == 0) - return seprint(s, e, "\n"); - s = seprint(s, e, "\n\t\t"); + return jehanne_seprint(s, e, "\n"); + s = jehanne_seprint(s, e, "\n\t\t"); /* we use only offsets[0] */ i = 0; - s = seprint(s, e, "[%d] %#ux cc=%#ux sz=%ud\n", i, td->offsets[i], + s = jehanne_seprint(s, e, "[%d] %#ux cc=%#ux sz=%ud\n", i, td->offsets[i], (td->offsets[i] >> Tdiccshift) & Tdiccmask, td->offsets[i] & 0x7FF); return s; @@ -855,11 +855,11 @@ dumptd(Td *td, char *p, int iso) static char buf[512]; /* Too much */ char *s; - s = seprint(buf, buf+sizeof(buf), "%s: ", p); + s = jehanne_seprint(buf, buf+sizeof(buf), "%s: ", p); s = seprinttd(s, buf+sizeof(buf), td, iso); if(s > buf && s[-1] != '\n') s[-1] = '\n'; - print("\t%s", buf); + jehanne_print("\t%s", buf); } static void @@ -872,7 +872,7 @@ dumptds(Td *td, char *p, int iso) if(td->last) break; if(tdtok(td) == Tdtokin && ++i > 2){ - print("\t\t...\n"); + jehanne_print("\t\t...\n"); break; } } @@ -884,33 +884,33 @@ dumped(Ed *ed) char *buf, *s, *e; if(ed == nil){ - print("\n"); + jehanne_print("\n"); return; } - buf = malloc(512); + buf = jehanne_malloc(512); /* no waserror; may want to use from interrupt context */ if(buf == nil) return; e = buf+512; - s = seprint(buf, e, "\ted %#p: ctrl %#lux", ed, ed->ctrl); + s = jehanne_seprint(buf, e, "\ted %#p: ctrl %#lux", ed, ed->ctrl); if((ed->ctrl & Edskip) != 0) - s = seprint(s, e, " skip"); + s = jehanne_seprint(s, e, " skip"); if((ed->ctrl & Ediso) != 0) - s = seprint(s, e, " iso"); + s = jehanne_seprint(s, e, " iso"); if((ed->ctrl & Edlow) != 0) - s = seprint(s, e, " low"); - s = seprint(s, e, " d%d", (ed->head & Edtoggle) ? 1 : 0); + s = jehanne_seprint(s, e, " low"); + s = jehanne_seprint(s, e, " d%d", (ed->head & Edtoggle) ? 1 : 0); if((ed->ctrl & Eddirmask) == Edin) - s = seprint(s, e, " in"); + s = jehanne_seprint(s, e, " in"); if((ed->ctrl & Eddirmask) == Edout) - s = seprint(s, e, " out"); + s = jehanne_seprint(s, e, " out"); if(edhalted(ed)) - s = seprint(s, e, " hlt"); - s = seprint(s, e, " ep%uld.%uld", (ed->ctrl>>7)&Epmax, ed->ctrl&0x7f); - s = seprint(s, e, " maxpkt %uld", (ed->ctrl>>Edmpsshift)&Edmpsmask); - seprint(s, e, " tail %#lux head %#lux next %#lux\n",ed->tail,ed->head,ed->nexted); - print("%s", buf); - free(buf); + s = jehanne_seprint(s, e, " hlt"); + s = jehanne_seprint(s, e, " ep%uld.%uld", (ed->ctrl>>7)&Epmax, ed->ctrl&0x7f); + s = jehanne_seprint(s, e, " maxpkt %uld", (ed->ctrl>>Edmpsshift)&Edmpsmask); + jehanne_seprint(s, e, " tail %#lux head %#lux next %#lux\n",ed->tail,ed->head,ed->nexted); + jehanne_print("%s", buf); + jehanne_free(buf); if(ed->tds != nil && (ed->ctrl & Ediso) == 0) dumptds(ed->tds, "td", 0); } @@ -918,11 +918,11 @@ dumped(Ed *ed) static char* seprintio(char *s, char *e, Qio *io, char *pref) { - s = seprint(s, e, "%s qio %#p ed %#p", pref, io, io->ed); - s = seprint(s, e, " tog %d iot %ld err %s id %#ulx", + s = jehanne_seprint(s, e, "%s qio %#p ed %#p", pref, io, io->ed); + s = jehanne_seprint(s, e, " tog %d iot %ld err %s id %#ulx", io->toggle, io->iotime, io->err, io->usbid); s = seprinttdtok(s, e, io->tok); - s = seprint(s, e, " %s\n", iosname[io->state]); + s = jehanne_seprint(s, e, " %s\n", iosname[io->state]); return s; } @@ -934,14 +934,14 @@ seprintep(char* s, char* e, Ep *ep) Ctlio *cio; if(ep == nil) - return seprint(s, e, "\n"); + return jehanne_seprint(s, e, "\n"); if(ep->aux == nil) - return seprint(s, e, "no mdep\n"); + return jehanne_seprint(s, e, "no mdep\n"); switch(ep->ttype){ case Tctl: cio = ep->aux; s = seprintio(s, e, cio, "c"); - s = seprint(s, e, "\trepl %d ndata %d\n", ep->rhrepl, cio->ndata); + s = jehanne_seprint(s, e, "\trepl %d ndata %d\n", ep->rhrepl, cio->ndata); break; case Tbulk: case Tintr: @@ -954,7 +954,7 @@ seprintep(char* s, char* e, Ep *ep) case Tiso: iso = ep->aux; s = seprintio(s, e, iso, "w"); - s = seprint(s, e, "\tntds %d avail %d frno %uld left %uld next avail %#p\n", + s = jehanne_seprint(s, e, "\tntds %d avail %d frno %uld left %uld next avail %#p\n", iso->nframes, iso->navail, iso->frno, iso->left, iso->atds); break; } @@ -964,26 +964,26 @@ seprintep(char* s, char* e, Ep *ep) static char* seprintctl(char *s, char *se, uint32_t ctl) { - s = seprint(s, se, "en="); + s = jehanne_seprint(s, se, "en="); if((ctl&Cple) != 0) - s = seprint(s, se, "p"); + s = jehanne_seprint(s, se, "p"); if((ctl&Cie) != 0) - s = seprint(s, se, "i"); + s = jehanne_seprint(s, se, "i"); if((ctl&Ccle) != 0) - s = seprint(s, se, "c"); + s = jehanne_seprint(s, se, "c"); if((ctl&Cble) != 0) - s = seprint(s, se, "b"); + s = jehanne_seprint(s, se, "b"); switch(ctl & Cfsmask){ case Cfsreset: - return seprint(s, se, " reset"); + return jehanne_seprint(s, se, " reset"); case Cfsresume: - return seprint(s, se, " resume"); + return jehanne_seprint(s, se, " resume"); case Cfsoper: - return seprint(s, se, " run"); + return jehanne_seprint(s, se, " run"); case Cfssuspend: - return seprint(s, se, " suspend"); + return jehanne_seprint(s, se, " suspend"); default: - return seprint(s, se, " ???"); + return jehanne_seprint(s, se, " ???"); } } @@ -997,37 +997,37 @@ dump(Hci *hp) ctlr = hp->aux; ilock(&ctlr->l); seprintctl(cs, cs+sizeof(cs), ctlr->ohci->control); - print("ohci ctlr %#p: frno %#ux ctl %#lux %s sts %#lux intr %#lux\n", + jehanne_print("ohci ctlr %#p: frno %#ux ctl %#lux %s sts %#lux intr %#lux\n", ctlr, ctlr->hcca->framenumber, ctlr->ohci->control, cs, ctlr->ohci->cmdsts, ctlr->ohci->intrsts); - print("ctlhd %#ulx cur %#ulx bulkhd %#ulx cur %#ulx done %#ulx\n", + jehanne_print("ctlhd %#ulx cur %#ulx bulkhd %#ulx cur %#ulx done %#ulx\n", ctlr->ohci->ctlheaded, ctlr->ohci->ctlcurred, ctlr->ohci->bulkheaded, ctlr->ohci->bulkcurred, ctlr->ohci->donehead); if(ctlhd(ctlr) != nil) - print("[ctl]\n"); + jehanne_print("[ctl]\n"); for(ed = ctlhd(ctlr); ed != nil; ed = ed->next) dumped(ed); if(bulkhd(ctlr) != nil) - print("[bulk]\n"); + jehanne_print("[bulk]\n"); for(ed = bulkhd(ctlr); ed != nil; ed = ed->next) dumped(ed); if(ctlr->intrhd != nil) - print("[intr]\n"); + jehanne_print("[intr]\n"); for(ed = ctlr->intrhd; ed != nil; ed = ed->inext) dumped(ed); if(ctlr->tree->root[0]->next != nil) - print("[iso]"); + jehanne_print("[iso]"); for(ed = ctlr->tree->root[0]->next; ed != nil; ed = ed->next) dumped(ed); - print("%d eds in tree\n", ctlr->ntree); + jehanne_print("%d eds in tree\n", ctlr->ntree); iunlock(&ctlr->l); lock(&tdpool.l); - print("%d tds allocated = %d in use + %d free\n", + jehanne_print("%d tds allocated = %d in use + %d free\n", tdpool.nalloc, tdpool.ninuse, tdpool.nfree); unlock(&tdpool.l); lock(&edpool.l); - print("%d eds allocated = %d in use + %d free\n", + jehanne_print("%d eds allocated = %d in use + %d free\n", edpool.nalloc, edpool.ninuse, edpool.nfree); unlock(&edpool.l); } @@ -1049,13 +1049,13 @@ isodtdinit(Ep *ep, Isoio *iso, Td *td) iso->left = (ep->hz+iso->left) * ep->pollival % 1000; size *= ep->samplesz; if(size > ep->maxpkt){ - print("ohci: ep%d.%d: size > maxpkt\n", + jehanne_print("ohci: ep%d.%d: size > maxpkt\n", ep->dev->nb, ep->nb); - print("size = %uld max = %ld\n", size, ep->maxpkt); + jehanne_print("size = %uld max = %ld\n", size, ep->maxpkt); size = ep->maxpkt; } td->nbytes = size; - memset(bp->wp, 0, size); /* in case we don't fill it on time */ + jehanne_memset(bp->wp, 0, size); /* in case we don't fill it on time */ td->cbp0 = td->cbp = ptr2pa(bp->rp) & ~0xFFF; td->ctrl = TRUNC(iso->frno, Ntdframes); td->offsets[0] = (ptr2pa(bp->rp) & 0xFFF); @@ -1178,7 +1178,7 @@ qhinterrupt(Ctlr * _, Ep *ep, Qio *io, Td *td, int __) bp->wp = bp->rp; /* no bytes in xfer. */ io->err = errmsg(err); if(debug || ep->debug){ - print("tdinterrupt: failed err %d (%s)\n", err, io->err); + jehanne_print("tdinterrupt: failed err %d (%s)\n", err, io->err); dumptd(td, "failed", ed->ctrl & Ediso); } td->last = 1; @@ -1232,7 +1232,7 @@ isointerrupt(Ctlr *ctlr, Ep *ep, Qio *io, Td *td, int _) bp->wp = bp->rp; io->err = errmsg(err); if(debug || ep->debug){ - print("ohci: isointerrupt: ep%d.%d: err %d (%s) frnum 0x%lux\n", + jehanne_print("ohci: isointerrupt: ep%d.%d: err %d (%s) frnum 0x%lux\n", ep->dev->nb, ep->nb, err, errmsg(err), ctlr->ohci->fmnumber); dumptd(td, "failed", ed->ctrl & Ediso); @@ -1365,7 +1365,7 @@ epgettd(Ep *ep, Qio *io, Td **dtdp, int flags, void *a, int count) /* validaddr((uintptr_t)a, count, 0); DEBUG */ assert(bp != nil); assert(bp->wp != nil); - memmove(bp->wp, a, count); + jehanne_memmove(bp->wp, a, count); } bp->wp += count; } @@ -1482,7 +1482,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) ep->dev->nb, ep->nb, io, count); if((debug > 1 || ep->debug > 1) && io->tok != Tdtokin){ seprintdata(buf, buf+sizeof(buf), a, count); - print("\t%s\n", buf); + jehanne_print("\t%s\n", buf); } if(mustlock){ qlock(&io->ql); @@ -1555,7 +1555,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) n = BLEN(td->bp); tot += n; if(c != nil && tdtok(td) == Tdtokin && n > 0){ - memmove(c, td->bp->rp, n); + jehanne_memmove(c, td->bp->rp, n); c += n; } } @@ -1640,9 +1640,9 @@ epread(Ep *ep, void *a, int32_t count) if(count > cio->ndata) count = cio->ndata; if(count > 0) - memmove(a, cio->data, count); + jehanne_memmove(a, cio->data, count); /* BUG for big transfers */ - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; /* signal EOF next time */ } @@ -1650,7 +1650,7 @@ epread(Ep *ep, void *a, int32_t count) poperror(); if(debug>1 || ep->debug){ seprintdata(buf, buf+sizeof(buf), a, count); - print("epread: %s\n", buf); + jehanne_print("epread: %s\n", buf); } return count; case Tbulk: @@ -1699,12 +1699,12 @@ epctlio(Ep *ep, Ctlio *cio, void *a, int32_t count) if(count < Rsetuplen) error("short usb command"); qlock(&cio->ql); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; if(waserror()){ qunlock(&cio->ql); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; nexterror(); @@ -1780,7 +1780,7 @@ putsamples(Ctlr *ctlr, Ep *ep, Isoio *iso, uint8_t *b, int32_t n) n = td->nbytes - BLEN(td->bp); assert(td->bp->wp + n <= td->bp->lim); iunlock(&ctlr->l); /* We could page fault here */ - memmove(td->bp->wp, b, n); + jehanne_memmove(td->bp->wp, b, n); ilock(&ctlr->l); if(td == pa2ptr(iso->ed->tail)){ td->bp->wp += n; @@ -1983,7 +1983,7 @@ isoopen(Ctlr *ctlr, Ep *ep) iso->usbid = (ep->nb&Epmax)<<7 | (ep->dev->nb&Devmax); iso->bw = ep->hz * ep->samplesz; /* bytes/sec */ if(ep->mode != OWRITE){ - print("ohci: bug: iso input streams not implemented\n"); + jehanne_print("ohci: bug: iso input streams not implemented\n"); error("ohci iso input streams not implemented"); }else iso->tok = Tdtokout; @@ -1993,7 +1993,7 @@ isoopen(Ctlr *ctlr, Ep *ep) iso->frno = TRUNC(ctlr->ohci->fmnumber + 10, Ntdframes); iso->nframes = 1000 / ep->pollival; if(iso->nframes < 10){ - print("ohci: isoopen: less than 10 frames; using 10.\n"); + jehanne_print("ohci: isoopen: less than 10 frames; using 10.\n"); iso->nframes = 10; } iso->navail = iso->nframes; @@ -2034,7 +2034,7 @@ epopen(Ep *ep) if(ep->aux != nil) panic("ohci: epopen called with open ep"); if(waserror()){ - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; nexterror(); } @@ -2153,7 +2153,7 @@ epclose(Ep *ep) case Tctl: cio = ep->aux; cancelio(ep, cio); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; break; case Tbulk: @@ -2179,7 +2179,7 @@ epclose(Ep *ep) } deprint("ohci: epclose ep%d.%d: done\n", ep->dev->nb, ep->nb); - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; } @@ -2289,11 +2289,11 @@ dumpohci(Ctlr *ctlr) uint32_t *ohci; ohci = &ctlr->ohci->revision; - print("ohci registers: \n"); + jehanne_print("ohci registers: \n"); for(i = 0; i < sizeof(Ohci)/sizeof(uint32_t); i++) if(i < 3 || ohci[i] != 0) - print("\t[%#2.2x]\t%#8.8ulx\n", i * 4, ohci[i]); - print("\n"); + jehanne_print("\t[%#2.2x]\t%#8.8ulx\n", i * 4, ohci[i]); + jehanne_print("\n"); } static void @@ -2316,7 +2316,7 @@ init(Hci *hp) delay(1); /* wait till reset complete, Ohci says 10us max. */ } if(i == 100) - print("ohci: reset timed out\n"); + jehanne_print("ohci: reset timed out\n"); ohci->fminterval = fmi; /* @@ -2391,13 +2391,13 @@ scanpci(void) dprint("ohci: %x/%x port 0x%lux size 0x%x irq %d\n", p->vid, p->did, mem, p->mem[0].size, p->intl); if(mem == 0){ - print("ohci: failed to map registers\n"); + jehanne_print("ohci: failed to map registers\n"); continue; } - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil){ - print("ohci: no memory\n"); + jehanne_print("ohci: no memory\n"); continue; } ctlr->pcidev = p; @@ -2411,7 +2411,7 @@ scanpci(void) break; } if(i == Nhcis) - print("ohci: bug: no more controllers\n"); + jehanne_print("ohci: bug: no more controllers\n"); } } @@ -2434,13 +2434,13 @@ mkqhtree(Ctlr *ctlr) depth = flog2(32); n = (1 << (depth+1)) - 1; - qt = mallocz(sizeof(*qt), 1); + qt = jehanne_mallocz(sizeof(*qt), 1); if(qt == nil) panic("ohci: can't allocate scheduling tree"); qt->nel = n; qt->depth = depth; - qt->bw = mallocz(n * sizeof(qt->bw), 1); - qt->root = tree = mallocz(n * sizeof(Ed *), 1); + qt->bw = jehanne_mallocz(n * sizeof(qt->bw), 1); + qt->root = tree = jehanne_mallocz(n * sizeof(Ed *), 1); if(qt->bw == nil || qt->root == nil) panic("ohci: can't allocate scheduling tree"); for(i = 0; i < n; i++){ @@ -2467,7 +2467,7 @@ mkqhtree(Ctlr *ctlr) o |= 1; } if(leaf0 + o >= n){ - print("leaf0=%d o=%d i=%d n=%d\n", leaf0, o, i, n); + jehanne_print("leaf0=%d o=%d i=%d n=%d\n", leaf0, o, i, n); break; } ctlr->hcca->intrtable[i] = ptr2pa(tree[leaf0 + o]); @@ -2483,10 +2483,10 @@ ohcimeminit(Ctlr *ctlr) edfree(edalloc()); /* allocate pools now */ tdfree(tdalloc()); - hcca = mallocalign(sizeof(Hcca), 256, 0, 0); + hcca = jehanne_mallocalign(sizeof(Hcca), 256, 0, 0); if(hcca == nil) panic("ohci: no memory for Hcca"); - memset(hcca, 0, sizeof(*hcca)); + jehanne_memset(hcca, 0, sizeof(*hcca)); ctlr->hcca = hcca; mkqhtree(ctlr); @@ -2509,7 +2509,7 @@ ohcireset(Ctlr *ctlr) delay(1); } if(i == 100) - print("ohci: smm takeover timed out\n"); + jehanne_print("ohci: smm takeover timed out\n"); } /* diff --git a/sys/src/kern/amd64/usbuhci.c b/sys/src/kern/amd64/usbuhci.c index 2e9f3a4..c073d2a 100644 --- a/sys/src/kern/amd64/usbuhci.c +++ b/sys/src/kern/amd64/usbuhci.c @@ -283,10 +283,10 @@ struct Td #define QPTR(q) ((Qh*)PTR(q)) #define TPTR(q) ((Td*)PTR(q)) #define PORT(p) (Portsc0 + 2*(p)) -#define diprint if(debug || iso->debug)print -#define ddiprint if(debug>1 || iso->debug>1)print -#define dqprint if(debug || (qh->io && qh->io->debug))print -#define ddqprint if(debug>1 || (qh->io && qh->io->debug>1))print +#define diprint if(debug || iso->debug)jehanne_print +#define ddiprint if(debug>1 || iso->debug>1)jehanne_print +#define dqprint if(debug || (qh->io && qh->io->debug))jehanne_print +#define ddqprint if(debug>1 || (qh->io && qh->io->debug>1))jehanne_print static Ctlr* ctlrs[Nhcis]; @@ -347,65 +347,65 @@ tdtok(Td *td) static char* seprinttd(char *s, char *se, Td *td) { - s = seprint(s, se, "%#p link %#ulx", td, td->link); + s = jehanne_seprint(s, se, "%#p link %#ulx", td, td->link); if((td->link & Tdvf) != 0) - s = seprint(s, se, "V"); + s = jehanne_seprint(s, se, "V"); if((td->link & Tdterm) != 0) - s = seprint(s, se, "T"); + s = jehanne_seprint(s, se, "T"); if((td->link & Tdlinkqh) != 0) - s = seprint(s, se, "Q"); - s = seprint(s, se, " csw %#ulx ", td->csw); + s = jehanne_seprint(s, se, "Q"); + s = jehanne_seprint(s, se, " csw %#ulx ", td->csw); if(td->csw & Tdactive) - s = seprint(s, se, "a"); + s = jehanne_seprint(s, se, "a"); if(td->csw & Tdiso) - s = seprint(s, se, "I"); + s = jehanne_seprint(s, se, "I"); if(td->csw & Tdioc) - s = seprint(s, se, "i"); + s = jehanne_seprint(s, se, "i"); if(td->csw & Tdlow) - s = seprint(s, se, "l"); + s = jehanne_seprint(s, se, "l"); if((td->csw & (Tderr1|Tderr2)) == 0) - s = seprint(s, se, "z"); + s = jehanne_seprint(s, se, "z"); if(td->csw & Tderrors) - s = seprint(s, se, " err %#ulx", td->csw & Tderrors); + s = jehanne_seprint(s, se, " err %#ulx", td->csw & Tderrors); if(td->csw & Tdstalled) - s = seprint(s, se, "s"); + s = jehanne_seprint(s, se, "s"); if(td->csw & Tddberr) - s = seprint(s, se, "d"); + s = jehanne_seprint(s, se, "d"); if(td->csw & Tdbabble) - s = seprint(s, se, "b"); + s = jehanne_seprint(s, se, "b"); if(td->csw & Tdnak) - s = seprint(s, se, "n"); + s = jehanne_seprint(s, se, "n"); if(td->csw & Tdcrcto) - s = seprint(s, se, "c"); + s = jehanne_seprint(s, se, "c"); if(td->csw & Tdbitstuff) - s = seprint(s, se, "B"); - s = seprint(s, se, " stslen %d", tdlen(td)); + s = jehanne_seprint(s, se, "B"); + s = jehanne_seprint(s, se, " stslen %d", tdlen(td)); - s = seprint(s, se, " token %#ulx", td->token); + s = jehanne_seprint(s, se, " token %#ulx", td->token); if(td->token == 0) /* the BWS loopback Td, ignore rest */ return s; - s = seprint(s, se, " maxlen %d", maxtdlen(td)); + s = jehanne_seprint(s, se, " maxlen %d", maxtdlen(td)); if(td->token & Tddata1) - s = seprint(s, se, " d1"); + s = jehanne_seprint(s, se, " d1"); else - s = seprint(s, se, " d0"); - s = seprint(s, se, " id %#ulx:", (td->token>>15) & Epmax); - s = seprint(s, se, "%#ulx", (td->token>>8) & Devmax); + s = jehanne_seprint(s, se, " d0"); + s = jehanne_seprint(s, se, " id %#ulx:", (td->token>>15) & Epmax); + s = jehanne_seprint(s, se, "%#ulx", (td->token>>8) & Devmax); switch(tdtok(td)){ case Tdtokin: - s = seprint(s, se, " in"); + s = jehanne_seprint(s, se, " in"); break; case Tdtokout: - s = seprint(s, se, " out"); + s = jehanne_seprint(s, se, " out"); break; case Tdtoksetup: - s = seprint(s, se, " setup"); + s = jehanne_seprint(s, se, " setup"); break; default: - s = seprint(s, se, " BADPID"); + s = jehanne_seprint(s, se, " BADPID"); } - s = seprint(s, se, "\n\t buffer %#ulx data %#p", td->buffer, td->data); - s = seprint(s, se, " ndata %uld sbuff %#p buff %#p", + s = jehanne_seprint(s, se, "\n\t buffer %#ulx data %#p", td->buffer, td->data); + s = jehanne_seprint(s, se, " ndata %uld sbuff %#p buff %#p", td->ndata, td->sbuff, td->buff); if(td->ndata > 0) s = seprintdata(s, se, td->data, td->ndata); @@ -419,27 +419,27 @@ isodump(Isoio *iso, int all) Td *td; int i; - print("iso %#p %s state %d nframes %d" + jehanne_print("iso %#p %s state %d nframes %d" " td0 %#p tdu %#p tdi %#p data %#p\n", iso, iso->tok == Tdtokin ? "in" : "out", iso->state, iso->nframes, iso->tdps[iso->td0frno], iso->tdu, iso->tdi, iso->data); if(iso->err != nil) - print("\terr='%s'\n", iso->err); + jehanne_print("\terr='%s'\n", iso->err); if(all == 0){ seprinttd(buf, buf+sizeof(buf), iso->tdu); - print("\ttdu %s\n", buf); + jehanne_print("\ttdu %s\n", buf); seprinttd(buf, buf+sizeof(buf), iso->tdi); - print("\ttdi %s\n", buf); + jehanne_print("\ttdi %s\n", buf); }else{ td = iso->tdps[iso->td0frno]; for(i = 0; i < iso->nframes; i++){ seprinttd(buf, buf+sizeof(buf), td); if(td == iso->tdi) - print("i->"); + jehanne_print("i->"); if(td == iso->tdu) - print("u->"); - print("\t%s\n", buf); + jehanne_print("u->"); + jehanne_print("\t%s\n", buf); td = td->next; } } @@ -466,11 +466,11 @@ dumptd(Td *td, char *pref) for(; td != nil; td = td->next){ s = seprinttd(buf, se, td); if(!sameptr(td->next, td->link)) - seprint(s, se, " next %#p != link %#ulx %#p", + jehanne_seprint(s, se, " next %#p != link %#ulx %#p", td->next, td->link, TPTR(td->link)); - print("%std %s\n", pref, buf); + jehanne_print("%std %s\n", pref, buf); if(i++ > 20){ - print("...more tds...\n"); + jehanne_print("...more tds...\n"); break; } } @@ -487,41 +487,41 @@ qhdump(Qh *qh, char *pref) s = buf; se = buf+sizeof(buf); - s = seprint(s, se, "%sqh %s %#p state %s link %#ulx", pref, + s = jehanne_seprint(s, se, "%sqh %s %#p state %s link %#ulx", pref, qh->tag, qh, qhsname[qh->state], qh->link); if(!sameptr(qh->tds, qh->elink)) - s = seprint(s, se, " [tds %#p != elink %#ulx %#p]", + s = jehanne_seprint(s, se, " [tds %#p != elink %#ulx %#p]", qh->tds, qh->elink, TPTR(qh->elink)); if(!sameptr(qh->next, qh->link)) - s = seprint(s, se, " [next %#p != link %#ulx %#p]", + s = jehanne_seprint(s, se, " [next %#p != link %#ulx %#p]", qh->next, qh->link, QPTR(qh->link)); if((qh->link & Tdterm) != 0) - s = seprint(s, se, "T"); + s = jehanne_seprint(s, se, "T"); if((qh->link & Tdlinkqh) != 0) - s = seprint(s, se, "Q"); - s = seprint(s, se, " elink %#ulx", qh->elink); + s = jehanne_seprint(s, se, "Q"); + s = jehanne_seprint(s, se, " elink %#ulx", qh->elink); if((qh->elink & Tdterm) != 0) - s = seprint(s, se, "T"); + s = jehanne_seprint(s, se, "T"); if((qh->elink & Tdlinkqh) != 0) - s = seprint(s, se, "Q"); - s = seprint(s, se, " io %#p", qh->io); + s = jehanne_seprint(s, se, "Q"); + s = jehanne_seprint(s, se, " io %#p", qh->io); if(qh->io != nil && qh->io->err != nil) - seprint(s, se, " err='%s'", qh->io->err); - print("%s\n", buf); + jehanne_seprint(s, se, " err='%s'", qh->io->err); + jehanne_print("%s\n", buf); dumptd(qh->tds, "\t"); if((qh->elink & QHterm) == 0){ - print("\thw tds:"); + jehanne_print("\thw tds:"); i = 0; for(td = qh->elink; (td & Tdterm) == 0; td = TPTR(td)->link){ - print(" %#ulx", td); + jehanne_print(" %#ulx", td); if(td == TPTR(td)->link) /* BWS Td */ break; if(i++ > 40){ - print("..."); + jehanne_print("..."); break; } } - print("\n"); + jehanne_print("\n"); } } @@ -535,20 +535,20 @@ xdump(Ctlr *ctlr, int doilock) if(doilock){ if(ctlr == ctlrs[0]){ lock(&tdpool.l); - print("tds: alloc %d = inuse %d + free %d\n", + jehanne_print("tds: alloc %d = inuse %d + free %d\n", tdpool.nalloc, tdpool.ninuse, tdpool.nfree); unlock(&tdpool.l); lock(&qhpool.l); - print("qhs: alloc %d = inuse %d + free %d\n", + jehanne_print("qhs: alloc %d = inuse %d + free %d\n", qhpool.nalloc, qhpool.ninuse, qhpool.nfree); unlock(&qhpool.l); } ilock(&ctlr->l); } - print("uhci port %#x frames %#p nintr %d ntdintr %d", + jehanne_print("uhci port %#x frames %#p nintr %d ntdintr %d", ctlr->port, ctlr->frames, ctlr->nintr, ctlr->ntdintr); - print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr); - print("cmd %#ux sts %#ux fl %#ulx ps1 %#ux ps2 %#ux frames[0] %#ulx\n", + jehanne_print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr); + jehanne_print("cmd %#ux sts %#ux fl %#ulx ps1 %#ux ps2 %#ux frames[0] %#ulx\n", INS(Cmd), INS(Status), INL(Flbaseadd), INS(PORT(0)), INS(PORT(1)), ctlr->frames[0]); @@ -558,11 +558,11 @@ xdump(Ctlr *ctlr, int doilock) for(qh = ctlr->qhs; qh != nil; qh = qh->next){ qhdump(qh, ""); if(i++ > 20){ - print("qhloop\n"); + jehanne_print("qhloop\n"); break; } } - print("\n"); + jehanne_print("\n"); if(doilock) iunlock(&ctlr->l); } @@ -583,7 +583,7 @@ tdalloc(void) lock(&tdpool.l); if(tdpool.free == nil){ ddprint("uhci: tdalloc %d Tds\n", Incr); - pool = mallocalign(Incr*ROUNDUP(sizeof(Td), Align), Align, 0, 0); + pool = jehanne_mallocalign(Incr*ROUNDUP(sizeof(Td), Align), Align, 0, 0); if(pool == nil) panic("tdalloc"); for(i=Incr; --i>=0;){ @@ -600,7 +600,7 @@ tdalloc(void) tdpool.nfree--; unlock(&tdpool.l); - memset(td, 0, sizeof(Td)); + jehanne_memset(td, 0, sizeof(Td)); td->link = Tdterm; assert(((uintptr_t)td & 0xF) == 0); return td; @@ -611,7 +611,7 @@ tdfree(Td *td) { if(td == nil) return; - free(td->buff); + jehanne_free(td->buff); td->buff = nil; lock(&tdpool.l); td->next = tdpool.free; @@ -664,7 +664,7 @@ qhalloc(Ctlr *ctlr, Qh *prev, Qio *io, char *tag) lock(&qhpool.l); if(qhpool.free == nil){ ddprint("uhci: qhalloc %d Qhs\n", Incr); - pool = mallocalign(Incr*ROUNDUP(sizeof(Qh), Align), Align, 0, 0); + pool = jehanne_mallocalign(Incr*ROUNDUP(sizeof(Qh), Align), Align, 0, 0); if(pool == nil) panic("qhalloc"); for(i=Incr; --i>=0;){ @@ -853,7 +853,7 @@ isointerrupt(Ctlr *ctlr, Isoio* iso) tdi->ndata = tdlen(tdi); if(tdi->next == iso->tdu || tdi->next->next == iso->tdu){ - memset(iso->tdu->data, 0, maxtdlen(iso->tdu)); + jehanne_memset(iso->tdu->data, 0, maxtdlen(iso->tdu)); tdisoinit(iso, iso->tdu, maxtdlen(iso->tdu)); iso->tdu = iso->tdu->next; iso->nleft = 0; @@ -999,7 +999,7 @@ putsamples(Ctlr *ctlr, Isoio *iso, uint8_t *b, int32_t count) if(n > maxtdlen(tdu) - left) n = maxtdlen(tdu) - left; iunlock(&ctlr->l); /* can pagefault here */ - memmove(tdu->data+left, b+tot, n); + jehanne_memmove(tdu->data+left, b+tot, n); ilock(&ctlr->l); if(tdu != iso->tdu) continue; @@ -1144,16 +1144,16 @@ episoread(Ep *ep, Isoio *iso, void *a, int count) if(tot + nr > count) nr = count - tot; if(nr == 0) - print("uhci: ep%d.%d: too many polls\n", + jehanne_print("uhci: ep%d.%d: too many polls\n", ep->dev->nb, ep->nb); else{ iunlock(&ctlr->l); /* We could page fault here */ - memmove(b+tot, tdu->data, nr); + jehanne_memmove(b+tot, tdu->data, nr); ilock(&ctlr->l); if(iso->tdu != tdu) continue; if(nr < tdu->ndata) - memmove(tdu->data, tdu->data+nr, tdu->ndata - nr); + jehanne_memmove(tdu->data, tdu->data+nr, tdu->ndata - nr); tdu->ndata -= nr; } if(tdu->ndata == 0){ @@ -1195,7 +1195,7 @@ epgettd(Ep *ep, Qio *io, int flags, void *a, int count) td->buffer = PCIWADDR32(td->data); td->ndata = count; if(a != nil && count > 0) - memmove(td->data, a, count); + jehanne_memmove(td->data, a, count); td->csw = Tderr2|Tderr1|flags; if(ep->dev->speed == Lowspeed) td->csw |= Tdlow; @@ -1303,7 +1303,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) ep->dev->nb, ep->nb, io, count, ctlr->load); if((debug > 1 || ep->debug > 1) && io->tok != Tdtokin){ seprintdata(buf, buf+sizeof(buf), a, count); - print("uchi epio: user data: %s\n", buf); + jehanne_print("uchi epio: user data: %s\n", buf); } if(mustlock){ qlock(&io->ql); @@ -1387,7 +1387,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) if((tot + n) > count) n = count - tot; if(c != nil && tdtok(td) == Tdtokin){ - memmove(c, td->data, n); + jehanne_memmove(c, td->data, n); c += n; } tot += n; @@ -1467,9 +1467,9 @@ epread(Ep *ep, void *a, int32_t count) if(count > cio->ndata) count = cio->ndata; if(count > 0) - memmove(a, cio->data, count); + jehanne_memmove(a, cio->data, count); /* BUG for big transfers */ - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; /* signal EOF next time */ } @@ -1477,7 +1477,7 @@ epread(Ep *ep, void *a, int32_t count) poperror(); if(debug>1 || ep->debug){ seprintdata(buf, buf+sizeof(buf), a, count); - print("epread: %s\n", buf); + jehanne_print("epread: %s\n", buf); } return count; case Tbulk: @@ -1526,12 +1526,12 @@ epctlio(Ep *ep, Ctlio *cio, void *a, int32_t count) if(count < Rsetuplen) error("short usb comand"); qlock(&cio->ql); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; if(waserror()){ qunlock(&cio->ql); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; nexterror(); @@ -1669,7 +1669,7 @@ isoopen(Ep *ep) ilock(&ctlr->l); if(ctlr->load + ep->load > 800) - print("usb: uhci: bandwidth may be exceeded\n"); + jehanne_print("usb: uhci: bandwidth may be exceeded\n"); ctlr->load += ep->load; ctlr->isoload += ep->load; dprint("uhci: load %uld isoload %uld\n", ctlr->load, ctlr->isoload); @@ -1697,9 +1697,9 @@ isoopen(Ep *ep) size *= ep->samplesz; left = (ep->hz+left) * ep->pollival % 1000; if(size > ep->maxpkt){ - print("uhci: ep%d.%d: size > maxpkt\n", + jehanne_print("uhci: ep%d.%d: size > maxpkt\n", ep->dev->nb, ep->nb); - print("size = %d max = %ld\n", size, ep->maxpkt); + jehanne_print("size = %d max = %ld\n", size, ep->maxpkt); size = ep->maxpkt; } } @@ -1758,12 +1758,12 @@ epopen(Ep *ep) if(ep->aux != nil) panic("uhci: epopen called with open ep"); if(waserror()){ - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; nexterror(); } if(ep->maxpkt > Tdmaxpkt){ - print("uhci: maxkpkt too large: using %d\n", Tdmaxpkt); + jehanne_print("uhci: maxkpkt too large: using %d\n", Tdmaxpkt); ep->maxpkt = Tdmaxpkt; } cqh = ctlr->qh[ep->ttype]; @@ -1906,7 +1906,7 @@ cancelisoio(Ctlr *ctlr, Isoio *iso, int pollival, uint32_t load) iso->tdps[frno] = nil; frno = TRUNC(frno+pollival, Nframes); } - free(iso->data); + jehanne_free(iso->data); iso->data = nil; } @@ -1927,7 +1927,7 @@ epclose(Ep *ep) case Tctl: cio = ep->aux; cancelio(ctlr, cio); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; break; case Tbulk: @@ -1953,7 +1953,7 @@ epclose(Ep *ep) panic("epclose: bad ttype %d", ep->ttype); } - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; } @@ -1976,7 +1976,7 @@ seprintep(char *s, char *e, Ep *ep) switch(ep->ttype){ case Tctl: cio = ep->aux; - s = seprint(s,e,"cio %#p qh %#p" + s = jehanne_seprint(s,e,"cio %#p qh %#p" " id %#x tog %#x tok %#x err %s\n", cio, cio->qh, cio->usbid, cio->toggle, cio->tok, cio->err); @@ -1985,17 +1985,17 @@ seprintep(char *s, char *e, Ep *ep) case Tintr: io = ep->aux; if(ep->mode != OWRITE) - s = seprint(s,e,"r: qh %#p id %#x tog %#x tok %#x err %s\n", + s = jehanne_seprint(s,e,"r: qh %#p id %#x tog %#x tok %#x err %s\n", io[OREAD].qh, io[OREAD].usbid, io[OREAD].toggle, io[OREAD].tok, io[OREAD].err); if(ep->mode != OREAD) - s = seprint(s,e,"w: qh %#p id %#x tog %#x tok %#x err %s\n", + s = jehanne_seprint(s,e,"w: qh %#p id %#x tog %#x tok %#x err %s\n", io[OWRITE].qh, io[OWRITE].usbid, io[OWRITE].toggle, io[OWRITE].tok, io[OWRITE].err); break; case Tiso: iso = ep->aux; - s = seprint(s,e,"iso %#p id %#x tok %#x tdu %#p tdi %#p err %s\n", + s = jehanne_seprint(s,e,"iso %#p id %#x tok %#x tdu %#p tdi %#p err %s\n", iso, iso->usbid, iso->tok, iso->tdu, iso->tdi, iso->err); break; } @@ -2135,22 +2135,22 @@ scanpci(void) continue; } if(io == 0){ - print("usbuhci: %#x %#x: failed to map registers\n", + jehanne_print("usbuhci: %#x %#x: failed to map registers\n", p->vid, p->did); continue; } if(ioalloc(io, p->mem[4].size, 0, "usbuhci") < 0){ - print("usbuhci: port %#ux in use\n", io); + jehanne_print("usbuhci: port %#ux in use\n", io); continue; } dprint("uhci: %#x %#x: port %#ux size %#x irq %d\n", p->vid, p->did, io, p->mem[4].size, p->intl); - ctlr = malloc(sizeof(Ctlr)); + ctlr = jehanne_malloc(sizeof(Ctlr)); if(ctlr == nil){ iofree(io); - print("usbuhci: no memory\n"); + jehanne_print("usbuhci: no memory\n"); continue; } ctlr->pcidev = p; @@ -2161,7 +2161,7 @@ scanpci(void) break; } if(i == Nhcis) - print("usbuhci: bug: no more controllers\n"); + jehanne_print("usbuhci: bug: no more controllers\n"); } } @@ -2191,7 +2191,7 @@ uhcimeminit(Ctlr *ctlr) qh->link = PCIWADDR32(ctlr->qhs); frsize = Nframes*sizeof(uint32_t); - ctlr->frames = mallocalign(frsize, frsize, 0, 0); + ctlr->frames = jehanne_mallocalign(frsize, frsize, 0, 0); if(ctlr->frames == nil) panic("uhci reset: no memory"); @@ -2263,7 +2263,7 @@ uhcireset(Ctlr *ctlr) delay(1); } if(i == 100) - print("uhci %#x controller reset timed out\n", ctlr->port); + jehanne_print("uhci %#x controller reset timed out\n", ctlr->port); OUTB(SOFmod, sof); iunlock(&ctlr->l); } diff --git a/sys/src/kern/amd64/vga.c b/sys/src/kern/amd64/vga.c index 76cdf26..276ebe0 100644 --- a/sys/src/kern/amd64/vga.c +++ b/sys/src/kern/amd64/vga.c @@ -174,13 +174,13 @@ vgascreenputs(char* s, int n) flushr = Rect(10000, 10000, -10000, -10000); while(n > 0){ - i = chartorune(&r, s); + i = jehanne_chartorune(&r, s); if(i == 0){ s++; --n; continue; } - memmove(buf, s, i); + jehanne_memmove(buf, s, i); buf[i] = 0; n -= i; s += i; @@ -210,14 +210,14 @@ vgascreenwin(VGAscr* scr) h = scr->memdefont->height; if (h == 0){ - print("vgascreenwin: height is 0"); + jehanne_print("vgascreenwin: height is 0"); error("vgascreenwin: height is 0"); } w = scr->memdefont->info[' '].width; if (w == 0){ error("vgascreenwin: width is 0"); - print("vgascreenwin: width is 0"); + jehanne_print("vgascreenwin: width is 0"); } window = insetrect(scr->gscreen->r, 48); diff --git a/sys/src/kern/amd64/vsvm.c b/sys/src/kern/amd64/vsvm.c index 0fd3499..cf438de 100644 --- a/sys/src/kern/amd64/vsvm.c +++ b/sys/src/kern/amd64/vsvm.c @@ -137,7 +137,7 @@ tssinit(uintptr_t sp) Tss *tss; tss = m->tss; - memset(tss, 0, sizeof(Tss)); + jehanne_memset(tss, 0, sizeof(Tss)); tssrsp0(sp); @@ -159,7 +159,7 @@ vsvminit(int size) idtinit(); m->gdt = m->vsvm; - memmove(m->gdt, gdt64, sizeof(gdt64)); + jehanne_memmove(m->gdt, gdt64, sizeof(gdt64)); m->tss = &m->vsvm[ROUNDUP(sizeof(gdt64), 16)]; sd = &((Sd*)m->gdt)[SiTSS]; diff --git a/sys/src/kern/boot/aux.c b/sys/src/kern/boot/aux.c index 0a19197..88220cd 100644 --- a/sys/src/kern/boot/aux.c +++ b/sys/src/kern/boot/aux.c @@ -16,7 +16,7 @@ sendmsg(int fd, char *msg) { int n; - n = strlen(msg); + n = jehanne_strlen(msg); if(write(fd, msg, n) != n) return -1; return 0; @@ -30,9 +30,9 @@ savelogsproc(void) out = open("/sys/log/kernel", OWRITE); if(out < 0){ - out = ocreate("/sys/log/kernel", OWRITE, 0600); + out = jehanne_ocreate("/sys/log/kernel", OWRITE, 0600); if(out < 0){ - fprint(2, "savelogs: cannot create /sys/log/kernel: %r\n"); + jehanne_fprint(2, "savelogs: cannot create /sys/log/kernel: %r\n"); return; } } @@ -41,7 +41,7 @@ savelogsproc(void) while((r = read(in, buf, sizeof buf)) > 0){ w = write(out, buf, r); if(w <= 0){ - fprint(2, "savelogs: error writing logs: %r\n"); + jehanne_fprint(2, "savelogs: error writing logs: %r\n"); return; } } @@ -51,13 +51,13 @@ savelogsproc(void) while((r = read(in, buf, sizeof buf)) > 0){ w = write(out, buf, r); if(w <= 0){ - fprint(2, "savelogs: error writing logs: %r\n"); + jehanne_fprint(2, "savelogs: error writing logs: %r\n"); return; } } close(in); - fprint(2, "savelogs: /dev/kprint closed: %r\n"); + jehanne_fprint(2, "savelogs: /dev/kprint closed: %r\n"); close(out); } @@ -65,14 +65,14 @@ savelogsproc(void) void savelogs(void) { - if(access("/sys/log/", AEXIST) < 0){ - fprint(2, "boot: cannot access /sys/log/kernel\n"); + if(jehanne_access("/sys/log/", AEXIST) < 0){ + jehanne_fprint(2, "boot: cannot access /sys/log/kernel\n"); return; } switch(rfork(RFPROC|RFNOWAIT|RFNOTEG|RFREND|RFFDG)){ case -1: - print("boot: savelogs: fork failed: %r\n"); + jehanne_print("boot: savelogs: fork failed: %r\n"); case 0: savelogsproc(); default: @@ -87,7 +87,7 @@ warning(char *s) buf[0] = '\0'; errstr(buf, sizeof buf); - fprint(2, "boot: %s: %s\n", s, buf); + jehanne_fprint(2, "boot: %s: %s\n", s, buf); } void @@ -97,8 +97,8 @@ fatal(char *s) buf[0] = '\0'; errstr(buf, sizeof buf); - fprint(2, "boot: %s: %s\n", s, buf); - exits(0); + jehanne_fprint(2, "boot: %s: %s\n", s, buf); + jehanne_exits(0); } int @@ -109,7 +109,7 @@ readfile(char *name, char *buf, int len) buf[0] = 0; f = open(name, OREAD); if(f < 0){ - fprint(2, "readfile: cannot open %s (%r)\n", name); + jehanne_fprint(2, "readfile: cannot open %s (%r)\n", name); return -1; } n = read(f, buf, len-1); @@ -138,13 +138,13 @@ setenv(char *name, char *val) int f; char ename[64]; - snprint(ename, sizeof ename, "#e/%s", name); - f = ocreate(ename, OWRITE, 0666); + jehanne_snprint(ename, sizeof ename, "#e/%s", name); + f = jehanne_ocreate(ename, OWRITE, 0666); if(f < 0){ - fprint(2, "create %s: %r\n", ename); + jehanne_fprint(2, "create %s: %r\n", ename); return; } - write(f, val, strlen(val)); + write(f, val, jehanne_strlen(val)); close(f); } @@ -155,18 +155,18 @@ srvcreate(char *name, int fd) int f; char buf[64]; - srvname = strrchr(name, '/'); + srvname = jehanne_strrchr(name, '/'); if(srvname) srvname++; else srvname = name; - snprint(buf, sizeof buf, "#s/%s", srvname); - f = ocreate(buf, OWRITE, 0600); + jehanne_snprint(buf, sizeof buf, "#s/%s", srvname); + f = jehanne_ocreate(buf, OWRITE, 0600); if(f < 0) fatal(buf); - sprint(buf, "%d", fd); - if(write(f, buf, strlen(buf)) != strlen(buf)) + jehanne_sprint(buf, "%d", fd); + if(write(f, buf, jehanne_strlen(buf)) != jehanne_strlen(buf)) fatal("write"); close(f); } @@ -175,7 +175,7 @@ void catchint(void *a, char *note) { USED(a); - if(strcmp(note, "alarm") == 0) + if(jehanne_strcmp(note, "alarm") == 0) noted(NCONT); noted(NDFLT); } @@ -193,8 +193,8 @@ outin(char *prompt, char *def, int len) notify(catchint); alarm(15*1000); } - print("%s[%s]: ", prompt, *def ? def : "no default"); - memset(buf, 0, sizeof buf); + jehanne_print("%s[%s]: ", prompt, *def ? def : "no default"); + jehanne_memset(buf, 0, sizeof buf); n = read(0, buf, len); if(cpuflag){ @@ -206,7 +206,7 @@ outin(char *prompt, char *def, int len) return 1; } if (n > 1) { - strncpy(def, buf, len); + jehanne_strncpy(def, buf, len); } return n; } @@ -217,18 +217,18 @@ void shell(char *c, char *d) argv[3] = c; argv[4] = d; - if(access(rcPath, AEXEC) < 0) + if(jehanne_access(rcPath, AEXEC) < 0) fatal("cannot find rc"); - switch(fork()){ + switch(jehanne_fork()){ case -1: - print("configrc: fork failed: %r\n"); + jehanne_print("configrc: fork failed: %r\n"); case 0: exec(rcPath, (const char**)argv); fatal("can't exec rc"); default: break; } - while(waitpid() != -1) + while(jehanne_waitpid() != -1) ; } diff --git a/sys/src/kern/boot/boot.c b/sys/src/kern/boot/boot.c index ab8f545..d8cc3c6 100644 --- a/sys/src/kern/boot/boot.c +++ b/sys/src/kern/boot/boot.c @@ -48,7 +48,7 @@ boot(int argc, char *argv[]) open("/dev/cons", OWRITE); open("/dev/cons", OWRITE); - fmtinstall('r', errfmt); + jehanne_fmtinstall('r', jehanne_errfmt); bindBoot(); @@ -56,7 +56,7 @@ boot(int argc, char *argv[]) * start /dev/cons */ if(readfile("#ec/console", buf, sizeof(cputype)) >= 0 - && strcmp("comconsole", buf) == 0){ + && jehanne_strcmp("comconsole", buf) == 0){ if(startcomconsole() < 0) fatal("no console found"); } else if(startconsole() < 0){ @@ -73,12 +73,12 @@ boot(int argc, char *argv[]) bind("#s", "/srv", MREPL|MCREATE); bind("#p", "/proc", MREPL|MCREATE); bind("#σ", "/shr", MREPL); - print("Diex vos sait! Je m'appelle Jehanne O:-)\n"); + jehanne_print("Diex vos sait! Je m'appelle Jehanne O:-)\n"); #ifdef DEBUG - print("argc=%d\n", argc); + jehanne_print("argc=%d\n", argc); for(fd = 0; fd < argc; fd++) - print("%#p %s ", argv[fd], argv[fd]); - print("\n"); + jehanne_print("%#p %s ", argv[fd], argv[fd]); + jehanne_print("\n"); #endif //DEBUG ARGBEGIN{ @@ -106,8 +106,8 @@ boot(int argc, char *argv[]) fatal("no boot methods"); mp = rootserver(argc ? *argv : 0); (*mp->config)(mp); - islocal = strcmp(mp->name, "local") == 0; - ishybrid = strcmp(mp->name, "hybrid") == 0; + islocal = jehanne_strcmp(mp->name, "local") == 0; + ishybrid = jehanne_strcmp(mp->name, "hybrid") == 0; /* * load keymap if it is there. @@ -119,7 +119,7 @@ boot(int argc, char *argv[]) */ authentication(cpuflag); -print("connect..."); +jehanne_print("connect..."); /* * connect to the root file system */ @@ -130,15 +130,15 @@ print("connect..."); if(cfs) fd = (*cfs)(fd); } -print("\n"); +jehanne_print("\n"); - print("version..."); + jehanne_print("version..."); buf[0] = '\0'; n = fversion(fd, 0, buf, sizeof buf); if(n < 0) fatal("can't init 9P"); - if(access("#s/boot", AEXIST) < 0) + if(jehanne_access("#s/boot", AEXIST) < 0) srvcreate("boot", fd); unbindBoot(); @@ -148,7 +148,7 @@ print("\n"); */ if(bind("/", "/", MREPL) < 0) fatal("bind /"); - rp = getenv("rootspec"); + rp = jehanne_getenv("rootspec"); if(rp == nil) rp = ""; @@ -156,25 +156,25 @@ print("\n"); if(afd >= 0){ ai = auth_proxy(afd, auth_getkey, "proto=p9any role=client"); if(ai == nil) - print("authentication failed (%r), trying mount anyways\n"); + jehanne_print("authentication failed (%r), trying mount anyways\n"); } if(mount(fd, afd, "/root", MREPL|MCREATE, rp, '9') < 0) fatal("mount /"); rsp = rp; - rp = getenv("rootdir"); + rp = jehanne_getenv("rootdir"); if(rp == nil) rp = rootdir; if(bind(rp, "/", MAFTER|MCREATE) < 0){ - if(strncmp(rp, "/root", 5) == 0){ - fprint(2, "boot: couldn't bind $rootdir=%s to root: %r\n", rp); + if(jehanne_strncmp(rp, "/root", 5) == 0){ + jehanne_fprint(2, "boot: couldn't bind $rootdir=%s to root: %r\n", rp); fatal("second bind /"); } - snprint(rootbuf, sizeof rootbuf, "/root/%s", rp); + jehanne_snprint(rootbuf, sizeof rootbuf, "/root/%s", rp); rp = rootbuf; if(bind(rp, "/", MAFTER|MCREATE) < 0){ - fprint(2, "boot: couldn't bind $rootdir=%s to root: %r\n", rp); - if(strcmp(rootbuf, "/root//plan9") == 0){ - fprint(2, "**** warning: remove rootdir=/plan9 entry from plan9.ini\n"); + jehanne_fprint(2, "boot: couldn't bind $rootdir=%s to root: %r\n", rp); + if(jehanne_strcmp(rootbuf, "/root//plan9") == 0){ + jehanne_fprint(2, "**** warning: remove rootdir=/plan9 entry from plan9.ini\n"); rp = "/root"; if(bind(rp, "/", MAFTER|MCREATE) < 0) fatal("second bind /"); @@ -191,17 +191,17 @@ print("\n"); if(afd > 0) close(afd); - cmd = getenv("init"); + cmd = jehanne_getenv("init"); if(cmd == nil){ - sprint(cmdbuf, "/arch/%s/cmd/init -%s%s", cputype, + jehanne_sprint(cmdbuf, "/arch/%s/cmd/init -%s%s", cputype, cpuflag ? "c" : "t", mflag ? "m" : ""); cmd = cmdbuf; } - iargc = tokenize(cmd, iargv, nelem(iargv)-1); + iargc = jehanne_tokenize(cmd, iargv, nelem(iargv)-1); cmd = iargv[0]; /* make iargv[0] basename(iargv[0]) */ - if(iargv[0] = strrchr(iargv[0], '/')) + if(iargv[0] = jehanne_strrchr(iargv[0], '/')) iargv[0]++; else iargv[0] = cmd; @@ -219,16 +219,16 @@ findmethod(char *a) int i, j; char *cp; - if((i = strlen(a)) == 0) + if((i = jehanne_strlen(a)) == 0) return nil; - cp = strchr(a, '!'); + cp = jehanne_strchr(a, '!'); if(cp) i = cp - a; for(mp = method; mp->name; mp++){ - j = strlen(mp->name); + j = jehanne_strlen(mp->name); if(j > i) j = i; - if(strncmp(a, mp->name, j) == 0) + if(jehanne_strncmp(a, mp->name, j) == 0) break; } if(mp->name) @@ -255,28 +255,28 @@ rootserver(char *arg) mp = findmethod(reply); if(mp) goto HaveMethod; - print("boot method %s not found\n", reply); + jehanne_print("boot method %s not found\n", reply); reply[0] = 0; } /* make list of methods */ mp = method; - n = sprint(prompt, "root is from (%s", mp->name); + n = jehanne_sprint(prompt, "root is from (%s", mp->name); for(mp++; mp->name; mp++) - n += sprint(prompt+n, ", %s", mp->name); - sprint(prompt+n, ")"); + n += jehanne_sprint(prompt+n, ", %s", mp->name); + jehanne_sprint(prompt+n, ")"); /* create default reply */ readfile("#ec/bootargs", reply, sizeof(reply)); if(reply[0] == 0 && arg != 0) - strcpy(reply, arg); + jehanne_strcpy(reply, arg); if(reply[0]){ mp = findmethod(reply); if(mp == 0) reply[0] = 0; } if(reply[0] == 0) - strcpy(reply, method->name); + jehanne_strcpy(reply, method->name); /* parse replies */ do{ @@ -285,11 +285,11 @@ rootserver(char *arg) }while(mp == nil); HaveMethod: - bargc = tokenize(reply, bargv, Nbarg-2); + bargc = jehanne_tokenize(reply, bargv, Nbarg-2); bargv[bargc] = nil; - cp = strchr(reply, '!'); + cp = jehanne_strchr(reply, '!'); if(cp) - strcpy(sys, cp+1); + jehanne_strcpy(sys, cp+1); return mp; } @@ -300,36 +300,36 @@ usbinit(void) static char *argv[] = {"usbrc", nil}; int pid; - if (access(usbrcPath, AEXIST) < 0) { - print("usbinit: no %s\n", usbrcPath); + if (jehanne_access(usbrcPath, AEXIST) < 0) { + jehanne_print("usbinit: no %s\n", usbrcPath); return; } - switch(pid = fork()){ + switch(pid = jehanne_fork()){ case -1: - print("usbinit: fork failed: %r\n"); + jehanne_print("usbinit: fork failed: %r\n"); case 0: exec(usbrcPath, (const char**)argv); fatal("can't exec usbd"); default: break; } - print("usbinit: waiting usbrc..."); + jehanne_print("usbinit: waiting usbrc..."); for(;;){ - w = wait(); + w = jehanne_wait(); if(w != nil && w->pid == pid){ if(w->msg[0] != 0) fatal(w->msg); - free(w); + jehanne_free(w); break; } else if(w == nil) { fatal("configuring usbinit"); } else if(w->msg[0] != 0){ - print("usbinit: wait: %d %s\n", w->pid, w->msg); + jehanne_print("usbinit: wait: %d %s\n", w->pid, w->msg); } - free(w); + jehanne_free(w); } - print("done\n"); + jehanne_print("done\n"); } static int @@ -338,8 +338,8 @@ startconsole(void) char *dbgfile, *argv[16], **av; int i; - if(access(screenconsolePath, AEXEC) < 0){ - print("cannot find screenconsole: %r\n"); + if(jehanne_access(screenconsolePath, AEXEC) < 0){ + jehanne_print("cannot find screenconsole: %r\n"); return -1; } @@ -347,12 +347,12 @@ startconsole(void) i = 0; av = argv; av[i++] = "screenconsole"; - if(dbgfile = getenv("debugconsole")){ + if(dbgfile = jehanne_getenv("debugconsole")){ av[i++] = "-d"; av[i++] = dbgfile; } av[i] = 0; - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("starting screenconsole"); case 0: @@ -363,8 +363,8 @@ startconsole(void) } /* wait for agent to really be there */ - while(access("#s/screenconsole", AEXIST) < 0){ - sleep(250); + while(jehanne_access("#s/screenconsole", AEXIST) < 0){ + jehanne_sleep(250); } /* replace 0, 1 and 2 */ if((i = open("#s/screenconsole", ORDWR)) < 0) @@ -373,16 +373,16 @@ startconsole(void) fatal("mount /dev"); if((i = open("/dev/cons", OREAD))<0) fatal("open /dev/cons, OREAD"); - if(dup(i, 0) != 0) - fatal("dup(i, 0)"); + if(jehanne_dup(i, 0) != 0) + fatal("jehanne_dup(i, 0)"); close(i); if((i = open("/dev/cons", OWRITE))<0) fatal("open /dev/cons, OWRITE"); - if(dup(i, 1) != 1) - fatal("dup(i, 1)"); + if(jehanne_dup(i, 1) != 1) + fatal("jehanne_dup(i, 1)"); close(i); - if(dup(1, 2) != 2) - fatal("dup(1, 2)"); + if(jehanne_dup(1, 2) != 2) + fatal("jehanne_dup(1, 2)"); return 0; } @@ -392,8 +392,8 @@ startcomconsole(void) char *dbgfile, *argv[16], **av; int i; - if(access(comconsolePath, AEXEC) < 0){ - print("cannot find comconsole: %r\n"); + if(jehanne_access(comconsolePath, AEXEC) < 0){ + jehanne_print("cannot find comconsole: %r\n"); return -1; } @@ -401,7 +401,7 @@ startcomconsole(void) i = 0; av = argv; av[i++] = "comconsole"; - if(dbgfile = getenv("debugconsole")){ + if(dbgfile = jehanne_getenv("debugconsole")){ av[i++] = "-d"; av[i++] = dbgfile; } @@ -409,7 +409,7 @@ startcomconsole(void) av[i++] = "comconsole"; av[i++] = "#t/eia0"; av[i] = 0; - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("starting comconsole"); case 0: @@ -420,8 +420,8 @@ startcomconsole(void) } /* wait for agent to really be there */ - while(access("#s/comconsole", AEXIST) < 0){ - sleep(250); + while(jehanne_access("#s/comconsole", AEXIST) < 0){ + jehanne_sleep(250); } /* replace 0, 1 and 2 */ if((i = open("#s/comconsole", ORDWR)) < 0) @@ -430,16 +430,16 @@ startcomconsole(void) fatal("mount /dev"); if((i = open("/dev/cons", OREAD))<0) fatal("open /dev/cons, OREAD"); - if(dup(i, 0) != 0) - fatal("dup(i, 0)"); + if(jehanne_dup(i, 0) != 0) + fatal("jehanne_dup(i, 0)"); close(i); if((i = open("/dev/cons", OWRITE))<0) fatal("open /dev/cons, OWRITE"); - if(dup(i, 1) != 1) - fatal("dup(i, 1)"); + if(jehanne_dup(i, 1) != 1) + fatal("jehanne_dup(i, 1)"); close(i); - if(dup(1, 2) != 2) - fatal("dup(1, 2)"); + if(jehanne_dup(1, 2) != 2) + fatal("jehanne_dup(1, 2)"); return 0; } @@ -478,7 +478,7 @@ kbmap(void) int n, in, out; char buf[1024]; - f = getenv("kbmap"); + f = jehanne_getenv("kbmap"); if(f == nil) return; if(bind("#κ", "/dev", MAFTER) < 0){ diff --git a/sys/src/kern/boot/boot.h b/sys/src/kern/boot/boot.h index cc58884..0cb8509 100644 --- a/sys/src/kern/boot/boot.h +++ b/sys/src/kern/boot/boot.h @@ -68,7 +68,7 @@ extern void key(int, Method*); extern int outin(char*, char*, int); extern int plumb(char*, char*, int*, char*); extern int readfile(char*, char*, int); -extern int32_t readn(int, void*, int32_t); +extern int32_t jehanne_readn(int, void*, int32_t); extern void run(char *file, ...); extern int sendmsg(int, char*); extern void setenv(char*, char*); diff --git a/sys/src/kern/boot/bootauth.c b/sys/src/kern/boot/bootauth.c index 94ad43b..64c3b61 100644 --- a/sys/src/kern/boot/bootauth.c +++ b/sys/src/kern/boot/bootauth.c @@ -22,7 +22,7 @@ authentication(int cpuflag) char *argv[16], **av; int ac; - if(access(factotumPath, AEXEC) < 0 || getenv("user") != nil){ + if(jehanne_access(factotumPath, AEXEC) < 0 || jehanne_getenv("user") != nil){ glenda(); return; } @@ -31,7 +31,7 @@ authentication(int cpuflag) ac = 0; av = argv; av[ac++] = "factotum"; - if(getenv("debugfactotum")) + if(jehanne_getenv("debugfactotum")) av[ac++] = "-p"; // av[ac++] = "-d"; /* debug traces */ // av[ac++] = "-D"; /* 9p messages */ @@ -45,7 +45,7 @@ authentication(int cpuflag) av[ac++] = authaddr; } av[ac] = 0; - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("starting factotum"); case 0: @@ -56,8 +56,8 @@ authentication(int cpuflag) } /* wait for agent to really be there */ - while(access("/mnt/factotum", AEXIST) < 0) - sleep(250); + while(jehanne_access("/mnt/factotum", AEXIST) < 0) + jehanne_sleep(250); if(cpuflag) return; @@ -69,15 +69,15 @@ glenda(void) int fd; char *s; - s = getenv("user"); + s = jehanne_getenv("user"); if(s == nil) s = "glenda"; fd = open("#c/hostowner", OWRITE); if(fd >= 0){ - if(write(fd, s, strlen(s)) != strlen(s)) - fprint(2, "setting #c/hostowner to %s: %r\n", s); + if(write(fd, s, jehanne_strlen(s)) != jehanne_strlen(s)) + jehanne_fprint(2, "setting #c/hostowner to %s: %r\n", s); close(fd); } - fprint(2, "Set hostowner to %s\n", s); + jehanne_fprint(2, "Set hostowner to %s\n", s); } diff --git a/sys/src/kern/boot/bootcache.c b/sys/src/kern/boot/bootcache.c index 5b01635..91c576a 100644 --- a/sys/src/kern/boot/bootcache.c +++ b/sys/src/kern/boot/bootcache.c @@ -19,7 +19,7 @@ cache(int fd) int argc, i, p[2]; char *argv[5], bd[32], buf[256], partition[64], *pp; - if(stat("/boot/cfs", statbuf, sizeof statbuf) < 0) + if(jehanne_stat("/boot/cfs", statbuf, sizeof statbuf) < 0) return fd; *partition = 0; @@ -27,12 +27,12 @@ cache(int fd) bind("#S", "/dev", MAFTER); readfile("#e/cfs", buf, sizeof(buf)); if(*buf){ - argc = tokenize(buf, argv, 4); + argc = jehanne_tokenize(buf, argv, 4); for(i = 0; i < argc; i++){ - if(strcmp(argv[i], "off") == 0) + if(jehanne_strcmp(argv[i], "off") == 0) return fd; - else if(stat(argv[i], statbuf, sizeof statbuf) >= 0){ - strncpy(partition, argv[i], sizeof(partition)-1); + else if(jehanne_stat(argv[i], statbuf, sizeof statbuf) >= 0){ + jehanne_strncpy(partition, argv[i], sizeof(partition)-1); partition[sizeof(partition)-1] = 0; } } @@ -41,45 +41,45 @@ cache(int fd) if(*partition == 0){ readfile("#e/bootdisk", bd, sizeof(bd)); if(*bd){ - if(pp = strchr(bd, ':')) + if(pp = jehanne_strchr(bd, ':')) *pp = 0; /* damned artificial intelligence */ - i = strlen(bd); - if(strcmp("disk", &bd[i-4]) == 0) + i = jehanne_strlen(bd); + if(jehanne_strcmp("disk", &bd[i-4]) == 0) bd[i-4] = 0; - else if(strcmp("fs", &bd[i-2]) == 0) + else if(jehanne_strcmp("fs", &bd[i-2]) == 0) bd[i-2] = 0; - else if(strcmp("fossil", &bd[i-6]) == 0) + else if(jehanne_strcmp("fossil", &bd[i-6]) == 0) bd[i-6] = 0; - sprint(partition, "%scache", bd); - if(stat(partition, statbuf, sizeof statbuf) < 0) + jehanne_sprint(partition, "%scache", bd); + if(jehanne_stat(partition, statbuf, sizeof statbuf) < 0) *bd = 0; } if(*bd == 0){ - sprint(partition, "%scache", bootdisk); - if(stat(partition, statbuf, sizeof statbuf) < 0) + jehanne_sprint(partition, "%scache", bootdisk); + if(jehanne_stat(partition, statbuf, sizeof statbuf) < 0) return fd; } } - print("cfs..."); - if(pipe(p)<0) + jehanne_print("cfs..."); + if(jehanne_pipe(p)<0) fatal("pipe"); - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("fork"); case 0: close(p[1]); - if(dup(fd, 0) != 0) - fatal("dup(fd, 0)"); + if(jehanne_dup(fd, 0) != 0) + fatal("jehanne_dup(fd, 0)"); close(fd); - if(dup(p[0], 1) != 1) - fatal("dup(p[0], 1)"); + if(jehanne_dup(p[0], 1) != 1) + fatal("jehanne_dup(p[0], 1)"); close(p[0]); if(fflag) - execl("/boot/cfs", "bootcfs", "-rs", "-f", partition, 0); + jehanne_execl("/boot/cfs", "bootcfs", "-rs", "-f", partition, 0); else - execl("/boot/cfs", "bootcfs", "-s", "-f", partition, 0); + jehanne_execl("/boot/cfs", "bootcfs", "-s", "-f", partition, 0); break; default: close(p[0]); diff --git a/sys/src/kern/boot/bootip.c b/sys/src/kern/boot/bootip.c index bf11b57..abfbe03 100644 --- a/sys/src/kern/boot/bootip.c +++ b/sys/src/kern/boot/bootip.c @@ -29,27 +29,27 @@ configip(int bargc, char **bargv, int needfs) int argc, pid; char **arg, **argv, buf[32], *p; - fmtinstall('I', eipfmt); - fmtinstall('M', eipfmt); - fmtinstall('E', eipfmt); + jehanne_fmtinstall('I', eipfmt); + jehanne_fmtinstall('M', eipfmt); + jehanne_fmtinstall('E', eipfmt); - arg = malloc((bargc+1) * sizeof(char*)); + arg = jehanne_malloc((bargc+1) * sizeof(char*)); if(arg == nil) fatal("malloc"); - memmove(arg, bargv, bargc * sizeof(char*)); + jehanne_memmove(arg, bargv, bargc * sizeof(char*)); arg[bargc] = 0; buf[0] = 0; /* no default for outin */ -print("ipconfig..."); +jehanne_print("ipconfig..."); argc = bargc; argv = arg; - strcpy(mpoint, "/net"); + jehanne_strcpy(mpoint, "/net"); ARGBEGIN { case 'x': p = ARGF(); if(p != nil) - snprint(mpoint, sizeof(mpoint), "/net%s", p); + jehanne_snprint(mpoint, sizeof(mpoint), "/net%s", p); break; case 'g': case 'b': @@ -63,21 +63,21 @@ print("ipconfig..."); /* bind in an ip interface */ if(bind("#I", mpoint, MAFTER) < 0) fatal("bind #I\n"); - if(access(ipconfigPath, AEXEC) < 0) + if(jehanne_access(ipconfigPath, AEXEC) < 0) fatal("cannot access ipconfig"); - if(access("#l0", AEXIST) == 0 && bind("#l0", mpoint, MAFTER) < 0) - print("bind #l0: %r\n"); - if(access("#l1", AEXIST) == 0 && bind("#l1", mpoint, MAFTER) < 0) - print("bind #l1: %r\n"); - if(access("#l2", AEXIST) == 0 && bind("#l2", mpoint, MAFTER) < 0) - print("bind #l2: %r\n"); - if(access("#l3", AEXIST) == 0 && bind("#l3", mpoint, MAFTER) < 0) - print("bind #l3: %r\n"); - werrstr(""); + if(jehanne_access("#l0", AEXIST) == 0 && bind("#l0", mpoint, MAFTER) < 0) + jehanne_print("bind #l0: %r\n"); + if(jehanne_access("#l1", AEXIST) == 0 && bind("#l1", mpoint, MAFTER) < 0) + jehanne_print("bind #l1: %r\n"); + if(jehanne_access("#l2", AEXIST) == 0 && bind("#l2", mpoint, MAFTER) < 0) + jehanne_print("bind #l2: %r\n"); + if(jehanne_access("#l3", AEXIST) == 0 && bind("#l3", mpoint, MAFTER) < 0) + jehanne_print("bind #l3: %r\n"); + jehanne_werrstr(""); /* let ipconfig configure the ip interface */ - switch(pid = fork()){ + switch(pid = jehanne_fork()){ case -1: fatal("fork configuring ip"); case 0: @@ -89,15 +89,15 @@ print("ipconfig..."); /* wait for ipconfig to finish */ for(;;){ - w = wait(); + w = jehanne_wait(); if(w != nil && w->pid == pid){ if(w->msg[0] != 0) fatal(w->msg); - free(w); + jehanne_free(w); break; } else if(w == nil) fatal("configuring ip"); - free(w); + jehanne_free(w); } if(!needfs) @@ -110,7 +110,7 @@ print("ipconfig..."); while(!isvalidip(fsip)){ outin("filesystem IP address", buf, sizeof(buf)); if (parseip(fsip, buf) == -1) - fprint(2, "configip: can't parse fs ip %s\n", buf); + jehanne_fprint(2, "configip: can't parse fs ip %s\n", buf); } netndb("auth", auip); @@ -119,9 +119,9 @@ print("ipconfig..."); while(!isvalidip(auip)){ outin("authentication server IP address", buf, sizeof(buf)); if (parseip(auip, buf) == -1) - fprint(2, "configip: can't parse auth ip %s\n", buf); + jehanne_fprint(2, "configip: can't parse auth ip %s\n", buf); } - free(arg); + jehanne_free(arg); } static void @@ -129,8 +129,8 @@ setauthaddr(char *proto, int port) { char buf[128]; - snprint(buf, sizeof buf, "%s!%I!%d", proto, auip, port); - authaddr = strdup(buf); + jehanne_snprint(buf, sizeof buf, "%s!%I!%d", proto, auip, port); + authaddr = jehanne_strdup(buf); } void @@ -146,10 +146,10 @@ connecttcp(void) int fd; char buf[64]; - snprint(buf, sizeof buf, "tcp!%I!5640", fsip); - fd = dial(buf, 0, 0, 0); + jehanne_snprint(buf, sizeof buf, "tcp!%I!5640", fsip); + fd = jehanne_dial(buf, 0, 0, 0); if (fd < 0) - werrstr("dial %s: %r", buf); + jehanne_werrstr("dial %s: %r", buf); return fd; } @@ -170,7 +170,7 @@ netenv(char *attr, uint8_t *ip) char buf[128]; ipmove(ip, IPnoaddr); - snprint(buf, sizeof(buf), "#ec/%s", attr); + jehanne_snprint(buf, sizeof(buf), "#ec/%s", attr); fd = open(buf, OREAD); if(fd < 0) return; @@ -179,7 +179,7 @@ netenv(char *attr, uint8_t *ip) if(n > 0){ buf[n] = 0; if (parseip(ip, buf) == -1) - fprint(2, "netenv: can't parse ip %s\n", buf); + jehanne_fprint(2, "netenv: can't parse ip %s\n", buf); } close(fd); } @@ -192,7 +192,7 @@ netndb(char *attr, uint8_t *ip) char *p; ipmove(ip, IPnoaddr); - snprint(buf, sizeof(buf), "%s/ndb", mpoint); + jehanne_snprint(buf, sizeof(buf), "%s/ndb", mpoint); fd = open(buf, OREAD); if(fd < 0) return; @@ -201,16 +201,16 @@ netndb(char *attr, uint8_t *ip) if(n <= 0) return; buf[n] = 0; - n = strlen(attr); + n = jehanne_strlen(attr); for(p = buf; ; p++){ - p = strstr(p, attr); + p = jehanne_strstr(p, attr); if(p == nil) break; c = *(p-1); if(*(p + n) == '=' && (p == buf || c == '\n' || c == ' ' || c == '\t')){ p += n+1; if (parseip(ip, p) == -1) - fprint(2, "netndb: can't parse ip %s\n", p); + jehanne_fprint(2, "netndb: can't parse ip %s\n", p); return; } } diff --git a/sys/src/kern/boot/bootrc.c b/sys/src/kern/boot/bootrc.c index 65fd0d2..0cb4049 100644 --- a/sys/src/kern/boot/bootrc.c +++ b/sys/src/kern/boot/bootrc.c @@ -20,31 +20,31 @@ configrc(Method* m) configloopback(); bind("#S", "/dev", MAFTER); char *argv[] = {"rc", "-m", rcmainPath, "-i", 0,}; - print("Step 1. Run an rc. Set things up.\n"); - switch(fork()){ + jehanne_print("Step 1. Run an rc. Set things up.\n"); + switch(jehanne_fork()){ case -1: - print("configrc: fork failed: %r\n"); + jehanne_print("configrc: fork failed: %r\n"); case 0: exec(rcPath, (const char**)argv); fatal("can't exec rc"); default: break; } - while(waitpid() != -1) + while(jehanne_waitpid() != -1) ; - print("Step 2. Run an rc. Verify that things are as you want them.\n"); - switch(fork()){ + jehanne_print("Step 2. Run an rc. Verify that things are as you want them.\n"); + switch(jehanne_fork()){ case -1: - print("configrc: fork failed: %r\n"); + jehanne_print("configrc: fork failed: %r\n"); case 0: exec(rcPath, (const char**)argv); fatal("can't exec rc"); default: break; } - while(waitpid() != -1) + while(jehanne_waitpid() != -1) ; - print("rc is done, continuing...\n"); + jehanne_print("rc is done, continuing...\n"); } int @@ -54,9 +54,9 @@ connectrc(void) char buf[64]; // Later, make this anything. - snprint(buf, sizeof buf, "/srv/fossil"); + jehanne_snprint(buf, sizeof buf, "/srv/fossil"); fd = open("#s/fossil", 2); if (fd < 0) - werrstr("dial %s: %r", buf); + jehanne_werrstr("dial %s: %r", buf); return fd; } diff --git a/sys/src/kern/boot/doauthenticate.c b/sys/src/kern/boot/doauthenticate.c index 8590a7e..e5f0404 100644 --- a/sys/src/kern/boot/doauthenticate.c +++ b/sys/src/kern/boot/doauthenticate.c @@ -42,26 +42,26 @@ fromauth(Method *mp, char *trbuf, char *tbuf) fatal("no method for accessing auth server"); afd = (*mp->auth)(); if(afd < 0) { - sprint(error, "%s: %r", ccmsg); + jehanne_sprint(error, "%s: %r", ccmsg); return error; } if(write(afd, trbuf, TICKREQLEN) < 0 || read(afd, &t, 1) != 1){ close(afd); - sprint(error, "%s: %r", pbmsg); + jehanne_sprint(error, "%s: %r", pbmsg); return error; } switch(t){ case AuthOK: msg = 0; - if(readn(afd, tbuf, 2*TICKETLEN) < 0) { - sprint(error, "%s: %r", pbmsg); + if(jehanne_readn(afd, tbuf, 2*TICKETLEN) < 0) { + jehanne_sprint(error, "%s: %r", pbmsg); msg = error; } break; case AuthErr: - if(readn(afd, error, ERRMAX) < 0) { - sprint(error, "%s: %r", pbmsg); + if(jehanne_readn(afd, error, ERRMAX) < 0) { + jehanne_sprint(error, "%s: %r", pbmsg); msg = error; } else { @@ -85,25 +85,25 @@ doauthenticate(int fd, Method *mp) char trbuf[TICKREQLEN]; char tbuf[2*TICKETLEN]; - print("session..."); + jehanne_print("session..."); if(fsession(fd, trbuf, sizeof trbuf) < 0) fatal("session command failed"); /* no authentication required? */ - memset(tbuf, 0, 2*TICKETLEN); + jehanne_memset(tbuf, 0, 2*TICKETLEN); if(trbuf[0] == 0) return; /* try getting to an auth server */ - print("getting ticket..."); + jehanne_print("getting ticket..."); msg = fromauth(mp, trbuf, tbuf); - print("authenticating..."); + jehanne_print("authenticating..."); if(msg == 0) if(fauth(fd, tbuf) >= 0) return; /* didn't work, go for the security hole */ - fprint(2, "no authentication server (%s), using your key as server key\n", msg); + jehanne_fprint(2, "no authentication server (%s), using your key as server key\n", msg); } char* @@ -115,21 +115,21 @@ checkkey(Method *mp, char *name, char *key) char trbuf[TICKREQLEN]; char tbuf[TICKETLEN]; - memset(&tr, 0, sizeof tr); + jehanne_memset(&tr, 0, sizeof tr); tr.type = AuthTreq; - strcpy(tr.authid, name); - strcpy(tr.hostid, name); - strcpy(tr.uid, name); + jehanne_strcpy(tr.authid, name); + jehanne_strcpy(tr.hostid, name); + jehanne_strcpy(tr.uid, name); convTR2M(&tr, trbuf); msg = fromauth(mp, trbuf, tbuf); if(msg == ccmsg){ - fprint(2, "boot: can't contact auth server, passwd unchecked\n"); + jehanne_fprint(2, "boot: can't contact auth server, passwd unchecked\n"); return 0; } if(msg) return msg; convM2T(tbuf, &t, key); - if(t.num == AuthTc && strcmp(name, t.cuid)==0) + if(t.num == AuthTc && jehanne_strcmp(name, t.cuid)==0) return 0; return "no match"; } diff --git a/sys/src/kern/boot/embed.c b/sys/src/kern/boot/embed.c index d2f2286..a37b806 100644 --- a/sys/src/kern/boot/embed.c +++ b/sys/src/kern/boot/embed.c @@ -37,30 +37,30 @@ connectembed(void) Dir *dir; char **arg, **argp; - dir = dirstat("/boot/paqfs"); + dir = jehanne_dirstat("/boot/paqfs"); if(dir == nil) return -1; - free(dir); + jehanne_free(dir); - dir = dirstat(paqfile); + dir = jehanne_dirstat(paqfile); if(dir == nil || dir->mode & DMDIR) return -1; - free(dir); + jehanne_free(dir); - print("paqfs..."); + jehanne_print("paqfs..."); if(bind("#0", "/dev", MREPL) < 0) fatal("bind #0"); if(bind("#c", "/dev", MAFTER) < 0) fatal("bind #c"); if(bind("#p", "/proc", MREPL) < 0) fatal("bind #p"); - if(pipe(p)<0) + if(jehanne_pipe(p)<0) fatal("pipe"); - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("fork"); case 0: - arg = malloc((bargc+5)*sizeof(char*)); + arg = jehanne_malloc((bargc+5)*sizeof(char*)); argp = arg; *argp++ = "/boot/paqfs"; *argp++ = "-iv"; @@ -69,10 +69,10 @@ connectembed(void) *argp++ = bargv[i]; *argp = 0; - if(dup(p[0], 0) != 0) - fatal("dup(p[0], 0)"); - if(dup(p[1], 1) != 1) - fatal("dup(p[1], 1)"); + if(jehanne_dup(p[0], 0) != 0) + fatal("jehanne_dup(p[0], 0)"); + if(jehanne_dup(p[1], 1) != 1) + fatal("jehanne_dup(p[1], 1)"); close(p[0]); close(p[1]); exec("/boot/paqfs", (const char**)arg); @@ -80,7 +80,7 @@ connectembed(void) default: break; } - waitpid(); + jehanne_waitpid(); close(p[1]); return p[0]; diff --git a/sys/src/kern/boot/getpasswd.c b/sys/src/kern/boot/getpasswd.c index 224a4c2..d7953b5 100644 --- a/sys/src/kern/boot/getpasswd.c +++ b/sys/src/kern/boot/getpasswd.c @@ -22,7 +22,7 @@ getpasswd(char *p, int len) fatal("can't open consctl; please reboot"); write(fd, "rawon", 5); Prompt: - print("password: "); + jehanne_print("password: "); n = 0; for(;;){ do{ @@ -34,14 +34,14 @@ getpasswd(char *p, int len) case '\n': p[n] = '\0'; close(fd); - print("\n"); + jehanne_print("\n"); return; case '\b': if(n > 0) n--; break; case 'u' - 'a' + 1: /* cntrl-u */ - print("\n"); + jehanne_print("\n"); goto Prompt; default: if(n < len - 1) diff --git a/sys/src/kern/boot/local.c b/sys/src/kern/boot/local.c index 60e3a85..ec721b4 100644 --- a/sys/src/kern/boot/local.c +++ b/sys/src/kern/boot/local.c @@ -40,43 +40,43 @@ configlocal(Method *mp) } else { disk = "#s/sdE0/"; } -print("configlocal: disk is %s\n", disk); +jehanne_print("configlocal: disk is %s\n", disk); /* if we've decided on one, pass it on to all programs */ if(disk) { setenv("bootdisk", disk); - setenv("nvram", smprint("%s/nvram", disk)); + setenv("nvram", jehanne_smprint("%s/nvram", disk)); } - if (access(disk, AEXIST) < 0){ - print("configlocal: cannot access %s\n", disk); + if (jehanne_access(disk, AEXIST) < 0){ + jehanne_print("configlocal: cannot access %s\n", disk); shell("-i", nil); } else { try = 0; - path = smprint("%s/plan9", disk); - cmd = smprint("%s -p '%s/data' >> '%s/ctl'", fdiskPath, disk, disk); - while(access(path, AEXIST) < 0){ + path = jehanne_smprint("%s/plan9", disk); + cmd = jehanne_smprint("%s -p '%s/data' >> '%s/ctl'", fdiskPath, disk, disk); + while(jehanne_access(path, AEXIST) < 0){ if(try++) - print("%s: try %d\n", cmd, try); + jehanne_print("%s: try %d\n", cmd, try); if(try > 4) shell("-i", nil); shell("-c", cmd); - sleep(250); + jehanne_sleep(250); } - free(cmd); - free(path); + jehanne_free(cmd); + jehanne_free(path); try = 0; - path = smprint("%s/fs", disk); - cmd = smprint("%s -p '%s/plan9' >> '%s/ctl'", prepPath, disk, disk); - while(access(path, AEXIST) < 0){ + path = jehanne_smprint("%s/fs", disk); + cmd = jehanne_smprint("%s -p '%s/plan9' >> '%s/ctl'", prepPath, disk, disk); + while(jehanne_access(path, AEXIST) < 0){ if(try++) - print("%s: try %d\n", cmd, try); + jehanne_print("%s: try %d\n", cmd, try); if(try > 4) shell("-i", nil); shell("-c", cmd); - sleep(250); + jehanne_sleep(250); } - free(cmd); - free(path); + jehanne_free(cmd); + jehanne_free(path); } } @@ -84,7 +84,7 @@ print("configlocal: disk is %s\n", disk); static int print1(int fd, char *s) { - return write(fd, s, strlen(s)); + return write(fd, s, jehanne_strlen(s)); } void @@ -110,20 +110,20 @@ connecthjfs(void) char partition[128]; char *dev; - if(access(hjfsPath, AEXEC) < 0){ + if(jehanne_access(hjfsPath, AEXEC) < 0){ return -1; } /* look for hjfs partition */ dev = disk ? disk : bootdisk; - snprint(partition, sizeof partition, "%s/fs", dev); + jehanne_snprint(partition, sizeof partition, "%s/fs", dev); /* start hjfs */ - print("hjfs(%s)...", partition); - shell("-c", smprint("%s -f '%s' -n 'boot'", hjfsPath, partition)); + jehanne_print("hjfs(%s)...", partition); + shell("-c", jehanne_smprint("%s -f '%s' -n 'boot'", hjfsPath, partition)); fd = open("#s/boot", ORDWR); if(fd < 0){ - print("open #s/boot: %r\n"); + jehanne_print("open #s/boot: %r\n"); return -1; } return fd; diff --git a/sys/src/kern/boot/nopsession.c b/sys/src/kern/boot/nopsession.c index 0a67495..f4207d8 100644 --- a/sys/src/kern/boot/nopsession.c +++ b/sys/src/kern/boot/nopsession.c @@ -27,7 +27,7 @@ rpc(int fd, int type) if(write(fd, buf, n) != n) fatal("write rpc"); - print("..."); + jehanne_print("..."); p = buf; l = 0; while(l < 3) { @@ -40,13 +40,13 @@ rpc(int fd, int type) l += n; } if(convM2S(buf, &hdr, n) == 0){ - print("%ux %ux %ux\n", buf[0], buf[1], buf[2]); + jehanne_print("%ux %ux %ux\n", buf[0], buf[1], buf[2]); fatal("rpc format"); } if(hdr.tag != NOTAG) fatal("rpc tag not NOTAG"); if(hdr.type == Rerror){ - print("error %s;", hdr.ename); + jehanne_print("error %s;", hdr.ename); fatal("remote error"); } if(hdr.type != type+1) @@ -56,6 +56,6 @@ rpc(int fd, int type) void nop(int fd) { - print("nop"); + jehanne_print("nop"); rpc(fd, Tnop); } diff --git a/sys/src/kern/boot/paq.c b/sys/src/kern/boot/paq.c index 7ac35bf..0d6723a 100644 --- a/sys/src/kern/boot/paq.c +++ b/sys/src/kern/boot/paq.c @@ -34,7 +34,7 @@ configpaq(Method* m) if(fd < 0) fatal("opening flashctl"); for(i = 0; i < nelem(fparts); i++) - if(fprint(fd, fparts[i]) < 0) + if(jehanne_fprint(fd, fparts[i]) < 0) fatal(fparts[i]); close(fd); } @@ -45,14 +45,14 @@ connectpaq(void) int p[2]; char **arg, **argp; - print("paq..."); - if(pipe(p)<0) + jehanne_print("paq..."); + if(jehanne_pipe(p)<0) fatal("pipe"); - switch(fork()){ + switch(jehanne_fork()){ case -1: fatal("fork"); case 0: - arg = malloc(10*sizeof(char*)); + arg = jehanne_malloc(10*sizeof(char*)); argp = arg; *argp++ = "paqfs"; *argp++ = "-v"; @@ -60,10 +60,10 @@ connectpaq(void) *argp++ = "/dev/flash/ramdisk"; *argp = 0; - if(dup(p[0], 0) != 0) - fatal("dup(p[0], 0)"); - if(dup(p[1], 1) != 1) - fatal("dup(p[1], 1)"); + if(jehanne_dup(p[0], 0) != 0) + fatal("jehanne_dup(p[0], 0)"); + if(jehanne_dup(p[1], 1) != 1) + fatal("jehanne_dup(p[1], 1)"); close(p[0]); close(p[1]); exec("/boot/paqfs", (const char**)arg); @@ -71,7 +71,7 @@ connectpaq(void) default: break; } - waitpid(); + jehanne_waitpid(); close(p[1]); return p[0]; diff --git a/sys/src/kern/boot/printstub.c b/sys/src/kern/boot/printstub.c index 1a8a9c1..c550856 100644 --- a/sys/src/kern/boot/printstub.c +++ b/sys/src/kern/boot/printstub.c @@ -15,13 +15,13 @@ static Lock fmtl; void _fmtlock(void) { - lock(&fmtl); + jehanne_lock(&fmtl); } void _fmtunlock(void) { - unlock(&fmtl); + jehanne_unlock(&fmtl); } int diff --git a/sys/src/kern/boot/sac.c b/sys/src/kern/boot/sac.c index 26d0c57..49dadf3 100644 --- a/sys/src/kern/boot/sac.c +++ b/sys/src/kern/boot/sac.c @@ -45,9 +45,9 @@ configsac(Method *mp) write(fd, "brick", 5); close(fd); - sprint(cmd, "/arch/%s/init", cputype); - print("starting %s\n", cmd); - execl(cmd, "init", "-c", 0); + jehanne_sprint(cmd, "/arch/%s/init", cputype); + jehanne_print("starting %s\n", cmd); + jehanne_execl(cmd, "init", "-c", 0); fatal(cmd); } diff --git a/sys/src/kern/boot/settime.c b/sys/src/kern/boot/settime.c index e36dac9..bcf4b9e 100644 --- a/sys/src/kern/boot/settime.c +++ b/sys/src/kern/boot/settime.c @@ -29,7 +29,7 @@ setlocaltime(char* timebuf, int s){ } close(f); }else do{ - strcpy(timebuf, "yymmddhhmm[ss]"); + jehanne_strcpy(timebuf, "yymmddhhmm[ss]"); outin("\ndate/time ", timebuf, s); }while((t=lusertime(timebuf)) <= 0); return t; @@ -44,7 +44,7 @@ settime(int islocal, int afd, char *rp) Dir dir[2]; char timebuf[64]; - print("time..."); + jehanne_print("time..."); timeset = 0; if(islocal){ /* @@ -66,22 +66,22 @@ settime(int islocal, int afd, char *rp) return; } else { close(f); - if(stat("/tmp", statbuf, sizeof statbuf) < 0) + if(jehanne_stat("/tmp", statbuf, sizeof statbuf) < 0) fatal("stat"); - convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); - sprint(timebuf, "%ld", dir[0].atime); + jehanne_convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); + jehanne_sprint(timebuf, "%ld", dir[0].atime); unmount(0, "/tmp"); } } - if((!islocal) && (strcmp(timebuf,"0")==0)) + if((!islocal) && (jehanne_strcmp(timebuf,"0")==0)) setlocaltime(timebuf, sizeof(timebuf)); f = open("#c/time", OWRITE); - if(write(f, timebuf, strlen(timebuf)) < 0) + if(write(f, timebuf, jehanne_strlen(timebuf)) < 0) warning("can't set #c/time"); close(f); - print("\n"); + jehanne_print("\n"); } #define SEC2MIN 60L @@ -135,7 +135,7 @@ lusertime(char *argbuf) int *d2m; buf = argbuf; - i = strlen(buf); + i = jehanne_strlen(buf); if(i != 10 && i != 12) return -1; secs = 0; @@ -167,6 +167,6 @@ lusertime(char *argbuf) if(*buf) secs += g2(&buf); - sprint(argbuf, "%ld", secs); + jehanne_sprint(argbuf, "%ld", secs); return secs; } diff --git a/sys/src/kern/ip/arp.c b/sys/src/kern/ip/arp.c index ccdca4c..d58c9a2 100644 --- a/sys/src/kern/ip/arp.c +++ b/sys/src/kern/ip/arp.c @@ -123,7 +123,7 @@ newarp6(Arp *arp, uint8_t *ip, Ipifc *ifc, int addrxt) a->hash = *l; *l = a; - memmove(a->ip, ip, sizeof(a->ip)); + jehanne_memmove(a->ip, ip, sizeof(a->ip)); a->utime = NOW; a->ctime = 0; a->type = ifc->medium; @@ -219,7 +219,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip, uint8_t *mac) hash = haship(ip); type = ifc->medium; for(a = arp->hash[hash]; a; a = a->hash){ - if(memcmp(ip, a->ip, sizeof(a->ip)) == 0) + if(jehanne_memcmp(ip, a->ip, sizeof(a->ip)) == 0) if(type == a->type) break; } @@ -241,7 +241,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip, uint8_t *mac) return a; /* return with arp qlocked */ } - memmove(mac, a->mac, a->type->maclen); + jehanne_memmove(mac, a->mac, a->type->maclen); /* remove old entries */ if(NOW - a->ctime > 15*60*1000) @@ -283,7 +283,7 @@ arpresolve(Arp *arp, Arpent *a, Medium *type, uint8_t *mac) } } - memmove(a->mac, mac, type->maclen); + jehanne_memmove(a->mac, mac, type->maclen); a->type = type; a->state = AOK; a->utime = NOW; @@ -308,7 +308,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh) arp = fs->arp; if(n != 6){ -// print("arp: len = %d\n", n); +// jehanne_print("arp: len = %d\n", n); return; } @@ -327,7 +327,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh) } if(r == nil){ -// print("arp: no route for entry\n"); +// jehanne_print("arp: no route for entry\n"); return; } @@ -341,7 +341,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh) if(ipcmp(a->ip, ip) == 0){ a->state = AOK; - memmove(a->mac, mac, type->maclen); + jehanne_memmove(a->mac, mac, type->maclen); if(version == V6){ /* take out of re-transmit chain */ @@ -392,7 +392,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh) a->state = AOK; a->type = type; a->ctime = NOW; - memmove(a->mac, mac, type->maclen); + jehanne_memmove(a->mac, mac, type->maclen); } qunlock(arp); @@ -416,17 +416,17 @@ arpwrite(Fs *fs, char *s, int len) error(Ebadarp); if(len >= sizeof(buf)) len = sizeof(buf)-1; - strncpy(buf, s, len); + jehanne_strncpy(buf, s, len); buf[len] = 0; if(len > 0 && buf[len-1] == '\n') buf[len-1] = 0; - n = getfields(buf, f, 4, 1, " "); - if(strcmp(f[0], "flush") == 0){ + n = jehanne_getfields(buf, f, 4, 1, " "); + if(jehanne_strcmp(f[0], "flush") == 0){ qlock(arp); for(a = arp->cache; a < &arp->cache[NCACHE]; a++){ - memset(a->ip, 0, sizeof(a->ip)); - memset(a->mac, 0, sizeof(a->mac)); + jehanne_memset(a->ip, 0, sizeof(a->ip)); + jehanne_memset(a->mac, 0, sizeof(a->mac)); a->hash = nil; a->state = 0; a->utime = 0; @@ -436,13 +436,13 @@ arpwrite(Fs *fs, char *s, int len) a->hold = bp; } } - memset(arp->hash, 0, sizeof(arp->hash)); + jehanne_memset(arp->hash, 0, sizeof(arp->hash)); /* clear all pkts on these lists (rxmt, dropf/l) */ arp->rxmt = nil; arp->dropf = nil; arp->dropl = nil; qunlock(arp); - } else if(strcmp(f[0], "add") == 0){ + } else if(jehanne_strcmp(f[0], "add") == 0){ switch(n){ default: error(Ebadarg); @@ -472,7 +472,7 @@ arpwrite(Fs *fs, char *s, int len) error(Ebadarp); type->ares(fs, V6, ip, mac, n, 0); - } else if(strcmp(f[0], "del") == 0){ + } else if(jehanne_strcmp(f[0], "del") == 0){ if(n != 2) error(Ebadarg); @@ -482,7 +482,7 @@ arpwrite(Fs *fs, char *s, int len) l = &arp->hash[haship(ip)]; for(a = *l; a; a = a->hash){ - if(memcmp(ip, a->ip, sizeof(a->ip)) == 0){ + if(jehanne_memcmp(ip, a->ip, sizeof(a->ip)) == 0){ *l = a->hash; break; } @@ -505,8 +505,8 @@ arpwrite(Fs *fs, char *s, int len) a->hold = nil; a->last = nil; a->ifc = nil; - memset(a->ip, 0, sizeof(a->ip)); - memset(a->mac, 0, sizeof(a->mac)); + jehanne_memset(a->ip, 0, sizeof(a->ip)); + jehanne_memset(a->mac, 0, sizeof(a->mac)); } qunlock(arp); } else @@ -526,7 +526,7 @@ static void convmac(char *p, uint8_t *mac, int n) { while(n-- > 0) - p += sprint(p, "%2.2ux", *mac++); + p += jehanne_sprint(p, "%2.2ux", *mac++); } int @@ -553,7 +553,7 @@ arpread(Arp *arp, char *p, uint32_t offset, int len) len--; qlock(arp); convmac(mac, a->mac, a->type->maclen); - n += sprint(p+n, aformat, a->type->name, arpstate[a->state], a->ip, mac); + n += jehanne_sprint(p+n, aformat, a->type->name, arpstate[a->state], a->ip, mac); qunlock(arp); } @@ -669,7 +669,7 @@ rxmitproc(void *v) long wakeupat; arp->rxmitp = up; - //print("arp rxmitproc started\n"); + //jehanne_print("arp rxmitproc started\n"); if(waserror()){ arp->rxmitp = 0; pexit("hangup", 1); diff --git a/sys/src/kern/ip/chandial.c b/sys/src/kern/ip/chandial.c index ed89248..d67073e 100644 --- a/sys/src/kern/ip/chandial.c +++ b/sys/src/kern/ip/chandial.c @@ -44,7 +44,7 @@ chandial(char *dest, char *local, char *dir, Chan **ctlp) ds.netdir = "/net"; /* no connection server, don't translate */ - snprint(clone, sizeof(clone), "%s/%s/clone", ds.netdir, ds.proto); + jehanne_snprint(clone, sizeof(clone), "%s/%s/clone", ds.netdir, ds.proto); return call(clone, ds.rem, &ds); } @@ -66,19 +66,19 @@ call(char *clone, char *dest, DS *ds) name[n] = 0; for(p = name; *p == ' '; p++) ; - sprint(name, "%lud", strtoul(p, 0, 0)); - p = strrchr(clone, '/'); + jehanne_sprint(name, "%lud", jehanne_strtoul(p, 0, 0)); + p = jehanne_strrchr(clone, '/'); *p = 0; if(ds->dir) - snprint(ds->dir, Maxpath, "%s/%s", clone, name); - snprint(data, sizeof(data), "%s/%s/data", clone, name); + jehanne_snprint(ds->dir, Maxpath, "%s/%s", clone, name); + jehanne_snprint(data, sizeof(data), "%s/%s/data", clone, name); /* connect */ if(ds->local) - snprint(name, sizeof(name), "connect %s %s", dest, ds->local); + jehanne_snprint(name, sizeof(name), "connect %s %s", dest, ds->local); else - snprint(name, sizeof(name), "connect %s", dest); - cchan->dev->write(cchan, name, strlen(name), 0); + jehanne_snprint(name, sizeof(name), "connect %s", dest); + cchan->dev->write(cchan, name, jehanne_strlen(name), 0); /* open data connection */ dchan = namec(data, Aopen, ORDWR, 0); @@ -99,10 +99,10 @@ _dial_string_parse(char *str, DS *ds) { char *p, *p2; - strncpy(ds->buf, str, Maxstring); + jehanne_strncpy(ds->buf, str, Maxstring); ds->buf[Maxstring-1] = 0; - p = strchr(ds->buf, '!'); + p = jehanne_strchr(ds->buf, '!'); if(p == 0) { ds->netdir = 0; ds->proto = "net"; diff --git a/sys/src/kern/ip/devip.c b/sys/src/kern/ip/devip.c index 6a1e83e..c1d6c62 100644 --- a/sys/src/kern/ip/devip.c +++ b/sys/src/kern/ip/devip.c @@ -92,7 +92,7 @@ ip3gen(Chan *c, int i, Dir *dp) p = "remote"; break; case Qsnoop: - if(strcmp(cv->p->name, "ipifc") != 0) + if(jehanne_strcmp(cv->p->name, "ipifc") != 0) return -1; devdir(c, q, "snoop", qlen(cv->sq), cv->owner, 0400, dp); return 1; @@ -145,7 +145,7 @@ ip1gen(Chan *c, int i, Dir *dp) break; case Qndb: p = "ndb"; - len = strlen(f->ndb); + len = jehanne_strlen(f->ndb); q.vers = f->ndbvers; break; case Qiproute: @@ -179,7 +179,7 @@ ipgen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) case Qtopdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); - snprint(up->genbuf, sizeof up->genbuf, "#I%ud", c->devno); + jehanne_snprint(up->genbuf, sizeof up->genbuf, "#I%ud", c->devno); devdir(c, q, up->genbuf, 0, network, 0555, dp); return 1; } @@ -201,13 +201,13 @@ ipgen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) case Qprotodir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, Qtopdir), 0, QTDIR); - snprint(up->genbuf, sizeof up->genbuf, "#I%ud", c->devno); + jehanne_snprint(up->genbuf, sizeof up->genbuf, "#I%ud", c->devno); devdir(c, q, up->genbuf, 0, network, 0555, dp); return 1; } if(s < f->p[PROTO(c->qid)]->ac) { cv = f->p[PROTO(c->qid)]->conv[s]; - snprint(up->genbuf, sizeof up->genbuf, "%d", s); + jehanne_snprint(up->genbuf, sizeof up->genbuf, "%d", s); mkqid(&q, QID(PROTO(c->qid), s, Qconvdir), 0, QTDIR); devdir(c, q, up->genbuf, 0, cv->owner, 0555, dp); return 1; @@ -244,11 +244,11 @@ ipreset(void) nullmediumlink(); pktmediumlink(); - fmtinstall('i', eipfmt); - fmtinstall('I', eipfmt); - fmtinstall('E', eipfmt); - fmtinstall('V', eipfmt); - fmtinstall('M', eipfmt); + jehanne_fmtinstall('i', eipfmt); + jehanne_fmtinstall('I', eipfmt); + jehanne_fmtinstall('E', eipfmt); + jehanne_fmtinstall('V', eipfmt); + jehanne_fmtinstall('M', eipfmt); } static Fs* @@ -285,11 +285,11 @@ newipaux(char *owner, char *tag) a = smalloc(sizeof(*a)); kstrdup(&a->owner, owner); - memset(a->tag, ' ', sizeof(a->tag)); - n = strlen(tag); + jehanne_memset(a->tag, ' ', sizeof(a->tag)); + n = jehanne_strlen(tag); if(n > sizeof(a->tag)) n = sizeof(a->tag); - memmove(a->tag, tag, n); + jehanne_memmove(a->tag, tag, n); return a; } @@ -300,7 +300,7 @@ ipattach(Chan *c, Chan *ac, char *spec, int flags) { int devno; - devno = atoi(spec); + devno = jehanne_atoi(spec); if(devno >= Nfs) error("bad specification"); @@ -393,7 +393,7 @@ ipopen(Chan* c, unsigned long omode) error(Eperm); p = f->p[PROTO(c->qid)]; cv = p->conv[CONV(c->qid)]; - if(strcmp(ATTACHER(c), cv->owner) != 0 && !isevegroup()) + if(jehanne_strcmp(ATTACHER(c), cv->owner) != 0 && !isevegroup()) error(Eperm); incref(&cv->snoopers); break; @@ -426,7 +426,7 @@ ipopen(Chan* c, unsigned long omode) nexterror(); } if((perm & (cv->perm>>6)) != perm) { - if(strcmp(ATTACHER(c), cv->owner) != 0) + if(jehanne_strcmp(ATTACHER(c), cv->owner) != 0) error(Eperm); if((perm & cv->perm) != perm) error(Eperm); @@ -444,7 +444,7 @@ ipopen(Chan* c, unsigned long omode) case Qlisten: cv = f->p[PROTO(c->qid)]->conv[CONV(c->qid)]; if((perm & (cv->perm>>6)) != perm) { - if(strcmp(ATTACHER(c), cv->owner) != 0) + if(jehanne_strcmp(ATTACHER(c), cv->owner) != 0) error(Eperm); if((perm & cv->perm) != perm) error(Eperm); @@ -531,11 +531,11 @@ ipwstat(Chan *c, uint8_t *dp, long n) break; } - n = convM2D(dp, n, &d, nil); + n = jehanne_convM2D(dp, n, &d, nil); if(n > 0){ p = f->p[PROTO(c->qid)]; cv = p->conv[CONV(c->qid)]; - if(!iseve() && strcmp(ATTACHER(c), cv->owner) != 0) + if(!iseve() && jehanne_strcmp(ATTACHER(c), cv->owner) != 0) error(Eperm); if(d.uid[0]) kstrdup(&cv->owner, d.uid); @@ -604,8 +604,8 @@ ipclose(Chan* c) decref(&f->p[PROTO(c->qid)]->conv[CONV(c->qid)]->snoopers); break; } - free(((IPaux*)c->aux)->owner); - free(c->aux); + jehanne_free(((IPaux*)c->aux)->owner); + jehanne_free(c->aux); } enum @@ -645,33 +645,33 @@ ipread(Chan *ch, void *a, long n, int64_t off) return netlogread(f, a, offset, n); case Qctl: buf = smalloc(16); - snprint(buf, 16, "%lud", CONV(ch->qid)); + jehanne_snprint(buf, 16, "%lud", CONV(ch->qid)); rv = readstr(offset, p, n, buf); - free(buf); + jehanne_free(buf); return rv; case Qremote: buf = smalloc(Statelen); x = f->p[PROTO(ch->qid)]; c = x->conv[CONV(ch->qid)]; if(x->remote == nil) { - snprint(buf, Statelen, "%I!%d\n", c->raddr, c->rport); + jehanne_snprint(buf, Statelen, "%I!%d\n", c->raddr, c->rport); } else { (*x->remote)(c, buf, Statelen-2); } rv = readstr(offset, p, n, buf); - free(buf); + jehanne_free(buf); return rv; case Qlocal: buf = smalloc(Statelen); x = f->p[PROTO(ch->qid)]; c = x->conv[CONV(ch->qid)]; if(x->local == nil) { - snprint(buf, Statelen, "%I!%d\n", c->laddr, c->lport); + jehanne_snprint(buf, Statelen, "%I!%d\n", c->laddr, c->lport); } else { (*x->local)(c, buf, Statelen-2); } rv = readstr(offset, p, n, buf); - free(buf); + jehanne_free(buf); return rv; case Qstatus: buf = smalloc(Statelen); @@ -679,7 +679,7 @@ ipread(Chan *ch, void *a, long n, int64_t off) c = x->conv[CONV(ch->qid)]; (*x->state)(c, buf, Statelen-2); rv = readstr(offset, p, n, buf); - free(buf); + jehanne_free(buf); return rv; case Qdata: c = f->p[PROTO(ch->qid)]->conv[CONV(ch->qid)]; @@ -697,7 +697,7 @@ ipread(Chan *ch, void *a, long n, int64_t off) buf = smalloc(Statelen); (*x->stats)(x, buf, Statelen); rv = readstr(offset, p, n, buf); - free(buf); + jehanne_free(buf); return rv; } } @@ -819,7 +819,7 @@ setlport(Conv* c) * if we do (and we're a cpu server), we might as well restart * since we're now unable to service new connections. */ - print("setlport: %s: %s: %I!%ud -> %I out of ports\n", + jehanne_print("setlport: %s: %s: %I!%ud -> %I out of ports\n", p->name, c->restricted? "restrict": "", c->raddr, c->rport, c->laddr); return "no ports available"; @@ -845,10 +845,10 @@ setladdrport(Conv* c, char* str, int announcing) * ignore restricted part if it exists. it's * meaningless on local ports. */ - p = strchr(str, '!'); + p = jehanne_strchr(str, '!'); if(p != nil){ *p++ = 0; - if(strcmp(p, "r") == 0) + if(jehanne_strcmp(p, "r") == 0) p = nil; } @@ -860,7 +860,7 @@ setladdrport(Conv* c, char* str, int announcing) setladdr(c); p = str; } else { - if(strcmp(str, "*") == 0) + if(jehanne_strcmp(str, "*") == 0) ipmove(c->laddr, IPnoaddr); else { if(parseip(addr, str) == -1) @@ -873,13 +873,13 @@ setladdrport(Conv* c, char* str, int announcing) } /* one process can get all connections */ - if(announcing && strcmp(p, "*") == 0){ + if(announcing && jehanne_strcmp(p, "*") == 0){ if(!iseve()) error(Eperm); return setluniqueport(c, 0); } - lport = atoi(p); + lport = jehanne_atoi(p); if(lport <= 0) rv = setlport(c); else @@ -892,16 +892,16 @@ setraddrport(Conv* c, char* str) { char *p; - p = strchr(str, '!'); + p = jehanne_strchr(str, '!'); if(p == nil) return "malformed address"; *p++ = 0; if (parseip(c->raddr, str) == -1) return Ebadip; - c->rport = atoi(p); - p = strchr(p, '!'); + c->rport = jehanne_atoi(p); + p = jehanne_strchr(p, '!'); if(p){ - if(strstr(p, "!r") != nil) + if(jehanne_strstr(p, "!r") != nil) c->restricted = 1; } return nil; @@ -936,8 +936,8 @@ Fsstdconnect(Conv *c, char *argv[], int argc) return p; } - if( (memcmp(c->raddr, v4prefix, IPv4off) == 0 && - memcmp(c->laddr, v4prefix, IPv4off) == 0) + if( (jehanne_memcmp(c->raddr, v4prefix, IPv4off) == 0 && + jehanne_memcmp(c->laddr, v4prefix, IPv4off) == 0) || ipcmp(c->raddr, IPnoaddr) == 0) c->ipversion = V4; else @@ -987,7 +987,7 @@ connectctlmsg(Proto *x, Conv *c, Cmdbuf *cb) char* Fsstdannounce(Conv* c, char* argv[], int argc) { - memset(c->raddr, 0, sizeof(c->raddr)); + jehanne_memset(c->raddr, 0, sizeof(c->raddr)); c->rport = 0; switch(argc){ default: @@ -1068,7 +1068,7 @@ tosctlmsg(Conv *c, Cmdbuf *cb) if(cb->nf < 2) c->tos = 0; else - c->tos = atoi(cb->f[1]); + c->tos = jehanne_atoi(cb->f[1]); } static void @@ -1077,7 +1077,7 @@ ttlctlmsg(Conv *c, Cmdbuf *cb) if(cb->nf < 2) c->ttl = MAXTTL; else - c->ttl = atoi(cb->f[1]); + c->ttl = jehanne_atoi(cb->f[1]); } static long @@ -1125,24 +1125,24 @@ ipwrite(Chan* ch, void *v, long n, int64_t off) qlock(c); if(waserror()) { qunlock(c); - free(cb); + jehanne_free(cb); nexterror(); } if(cb->nf < 1) error("short control request"); - if(strcmp(cb->f[0], "connect") == 0) + if(jehanne_strcmp(cb->f[0], "connect") == 0) connectctlmsg(x, c, cb); - else if(strcmp(cb->f[0], "announce") == 0) + else if(jehanne_strcmp(cb->f[0], "announce") == 0) announcectlmsg(x, c, cb); - else if(strcmp(cb->f[0], "bind") == 0) + else if(jehanne_strcmp(cb->f[0], "bind") == 0) bindctlmsg(x, c, cb); - else if(strcmp(cb->f[0], "ttl") == 0) + else if(jehanne_strcmp(cb->f[0], "ttl") == 0) ttlctlmsg(c, cb); - else if(strcmp(cb->f[0], "tos") == 0) + else if(jehanne_strcmp(cb->f[0], "tos") == 0) tosctlmsg(c, cb); - else if(strcmp(cb->f[0], "ignoreadvice") == 0) + else if(jehanne_strcmp(cb->f[0], "ignoreadvice") == 0) c->ignoreadvice = 1; - else if(strcmp(cb->f[0], "addmulti") == 0){ + else if(jehanne_strcmp(cb->f[0], "addmulti") == 0){ if(cb->nf < 2) error("addmulti needs interface address"); if(cb->nf == 2){ @@ -1159,7 +1159,7 @@ ipwrite(Chan* ch, void *v, long n, int64_t off) error("addmulti for a non multicast address"); ipifcaddmulti(c, ma, ia); } - } else if(strcmp(cb->f[0], "remmulti") == 0){ + } else if(jehanne_strcmp(cb->f[0], "remmulti") == 0){ if(cb->nf < 2) error("remmulti needs interface address"); if(!ipismulticast(c->raddr)) @@ -1167,11 +1167,11 @@ ipwrite(Chan* ch, void *v, long n, int64_t off) if (parseip(ia, cb->f[1]) == -1) error(Ebadip); ipifcremmulti(c, c->raddr, ia); - } else if(strcmp(cb->f[0], "maxfragsize") == 0){ + } else if(jehanne_strcmp(cb->f[0], "maxfragsize") == 0){ if(cb->nf < 2) error("maxfragsize needs size"); - c->maxfragsize = (int)strtol(cb->f[1], nil, 0); + c->maxfragsize = (int)jehanne_strtol(cb->f[1], nil, 0); } else if(x->ctl != nil) { p = x->ctl(c, cb->f, cb->nf); @@ -1180,7 +1180,7 @@ ipwrite(Chan* ch, void *v, long n, int64_t off) } else error("unknown control request"); qunlock(c); - free(cb); + jehanne_free(cb); poperror(); } return n; @@ -1250,7 +1250,7 @@ Fsproto(Fs *f, Proto *p) p->qid.type = QTDIR; p->qid.path = QID(f->np, 0, Qprotodir); - p->conv = malloc(sizeof(Conv*)*(p->nc+1)); + p->conv = jehanne_malloc(sizeof(Conv*)*(p->nc+1)); if(p->conv == nil) panic("Fsproto"); @@ -1285,16 +1285,16 @@ retry: for(pp = p->conv; pp < ep; pp++) { c = *pp; if(c == nil){ - c = malloc(sizeof(Conv)); + c = jehanne_malloc(sizeof(Conv)); if(c == nil) error(Enomem); qlock(c); c->p = p; c->x = pp - p->conv; if(p->ptclsize != 0){ - c->ptcl = malloc(p->ptclsize); + c->ptcl = jehanne_malloc(p->ptclsize); if(c->ptcl == nil) { - free(c); + jehanne_free(c); error(Enomem); } } @@ -1317,11 +1317,11 @@ retry: } if(pp >= ep) { if(p->gc) - print("Fsprotoclone: garbage collecting Convs\n"); + jehanne_print("Fsprotoclone: garbage collecting Convs\n"); if(p->gc != nil && (*p->gc)(p)) goto retry; /* debugging: do we ever get here? */ - print("Fsprotoclone: %s: all conversations in use: %s\n", p->name, user); + jehanne_print("Fsprotoclone: %s: all conversations in use: %s\n", p->name, user); return nil; } @@ -1350,7 +1350,7 @@ int Fsconnected(Conv* c, char* msg) { if(msg != nil && *msg != '\0') - strncpy(c->cerr, msg, ERRMAX-1); + jehanne_strncpy(c->cerr, msg, ERRMAX-1); switch(c->state){ @@ -1426,11 +1426,11 @@ Fsnewcall(Conv *c, uint8_t *raddr, uint16_t rport, uint8_t *laddr, uint16_t lpor long ndbwrite(Fs *f, char *a, uint32_t off, int n) { - if(off > strlen(f->ndb)) + if(off > jehanne_strlen(f->ndb)) error(Eio); if(off+n >= sizeof(f->ndb)) error(Eio); - memmove(f->ndb+off, a, n); + jehanne_memmove(f->ndb+off, a, n); f->ndb[off+n] = 0; f->ndbvers++; f->ndbmtime = seconds(); diff --git a/sys/src/kern/ip/esp.c b/sys/src/kern/ip/esp.c index 0439b03..57e641c 100644 --- a/sys/src/kern/ip/esp.c +++ b/sys/src/kern/ip/esp.c @@ -289,7 +289,7 @@ espconnect(Conv *c, char **argv, int argc) e = "bad args to connect"; break; case 2: - p = strchr(argv[1], '!'); + p = jehanne_strchr(argv[1], '!'); if(p == nil){ e = "malformed address"; break; @@ -302,7 +302,7 @@ espconnect(Conv *c, char **argv, int argc) findlocalip(c->p->f, c->laddr, c->raddr); ecb->incoming = 0; ecb->seq = 0; - if(strcmp(p, "*") == 0) { + if(jehanne_strcmp(p, "*") == 0) { qlock(c->p); for(;;) { spi = nrand(1<<16) + 256; @@ -314,7 +314,7 @@ espconnect(Conv *c, char **argv, int argc) ecb->incoming = 1; qhangup(c->wq, nil); } else { - spi = strtoul(p, &pp, 10); + spi = jehanne_strtoul(p, &pp, 10); if(pp == p) { e = "malformed address"; break; @@ -334,7 +334,7 @@ espconnect(Conv *c, char **argv, int argc) static int espstate(Conv *c, char *state, int n) { - return snprint(state, n, "%s", c->inuse?"Open\n":"Closed\n"); + return jehanne_snprint(state, n, "%s", c->inuse?"Open\n":"Closed\n"); } static void @@ -356,16 +356,16 @@ espclose(Conv *c) ipmove(c->raddr, IPnoaddr); ecb = (Espcb*)c->ptcl; - free(ecb->espstate); - free(ecb->ahstate); - memset(ecb, 0, sizeof(Espcb)); + jehanne_free(ecb->espstate); + jehanne_free(ecb->ahstate); + jehanne_memset(ecb, 0, sizeof(Espcb)); } static int convipvers(Conv *c) { - if((memcmp(c->raddr, v4prefix, IPv4off) == 0 && - memcmp(c->laddr, v4prefix, IPv4off) == 0) || + if((jehanne_memcmp(c->raddr, v4prefix, IPv4off) == 0 && + jehanne_memcmp(c->laddr, v4prefix, IPv4off) == 0) || ipcmp(c->raddr, IPnoaddr) == 0) return V4; else @@ -530,7 +530,7 @@ espkick(void *x) payload + pad + Esptaillen, auth); qunlock(c); - /* print("esp: pass down: %lud\n", BLEN(bp)); */ + /* jehanne_print("esp: pass down: %lud\n", BLEN(bp)); */ if (vers.version == V4) ipoput4(c->p->f, bp, 0, c->ttl, c->tos, c); else @@ -613,7 +613,7 @@ espiput(Proto *esp, Ipifc*, Block *bp) unsigned len = BLEN(bp), l, b = 128; once = 1; - fmtinstall('[', encodefmt); + jehanne_fmtinstall('[', encodefmt); netlog(f, Logesp, "len %ud\n", len); for (l = 0; l < len; l += b) { netlog(f, Logesp, "%.*[\n", @@ -641,7 +641,7 @@ espiput(Proto *esp, Ipifc*, Block *bp) unsigned len = BLEN(bp), l, b = 128; once = 1; - fmtinstall('[', encodefmt); + jehanne_fmtinstall('[', encodefmt); netlog(f, Logesp, "len %ud\n", len); for (l = 0; l < len; l += b) { netlog(f, Logesp, "%.*[\n", @@ -691,7 +691,7 @@ espiput(Proto *esp, Ipifc*, Block *bp) /* assume Userhdrlen < Esp4hdrlen < Esp6hdrlen */ bp->rp -= Userhdrlen; uh = (Userhdr*)bp->rp; - memset(uh, 0, Userhdrlen); + jehanne_memset(uh, 0, Userhdrlen); uh->nexthdr = nexthdr; } @@ -703,7 +703,7 @@ espiput(Proto *esp, Ipifc*, Block *bp) /* vers.laddr, vers.spi); */ freeblist(bp); }else { -// print("esp: pass up: %lud\n", BLEN(bp)); +// jehanne_print("esp: pass up: %lud\n", BLEN(bp)); espstat(esp, InUserOctets, BLEN(bp)); espstat(esp, InPackets, 1); if(qpass(c->rq, bp) == -1) @@ -719,14 +719,14 @@ espctl(Conv *c, char **f, int n) Espcb *ecb = c->ptcl; char *e = nil; - if(strcmp(f[0], "esp") == 0) { + if(jehanne_strcmp(f[0], "esp") == 0) { qsetlimit(c->rq, 3*1024*1024); // 2M had qfull drops e = setalg(ecb, f, n, espalg); - } else if(strcmp(f[0], "ah") == 0) + } else if(jehanne_strcmp(f[0], "ah") == 0) e = setalg(ecb, f, n, ahalg); - else if(strcmp(f[0], "header") == 0) + else if(jehanne_strcmp(f[0], "header") == 0) ecb->header = 1; - else if(strcmp(f[0], "noheader") == 0) + else if(jehanne_strcmp(f[0], "noheader") == 0) ecb->header = 0; else e = "unknown control request"; @@ -766,7 +766,7 @@ espstats(Proto *esp, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nstats; i++) - p = seprint(p, e, "%s: %llud\n", statnames[i], u[i]); + p = jehanne_seprint(p, e, "%s: %llud\n", statnames[i], u[i]); return p - buf; } @@ -778,9 +778,9 @@ esplocal(Conv *c, char *buf, int len) qlock(c); if(ecb->incoming) - n = snprint(buf, len, "%I!%lud\n", c->laddr, ecb->spi); + n = jehanne_snprint(buf, len, "%I!%lud\n", c->laddr, ecb->spi); else - n = snprint(buf, len, "%I\n", c->laddr); + n = jehanne_snprint(buf, len, "%I\n", c->laddr); qunlock(c); return n; } @@ -793,9 +793,9 @@ espremote(Conv *c, char *buf, int len) qlock(c); if(ecb->incoming) - n = snprint(buf, len, "%I\n", c->raddr); + n = jehanne_snprint(buf, len, "%I\n", c->raddr); else - n = snprint(buf, len, "%I!%lud\n", c->raddr, ecb->spi); + n = jehanne_snprint(buf, len, "%I!%lud\n", c->raddr, ecb->spi); qunlock(c); return n; } @@ -827,7 +827,7 @@ setalg(Espcb *ecb, char **f, int n, Algorithm *alg) for(;; alg++) if(alg->name == nil) return "unknown algorithm"; - else if(strcmp(f[1], alg->name) == 0) + else if(jehanne_strcmp(f[1], alg->name) == 0) break; nbyte = (alg->keylen + 7) >> 3; @@ -836,9 +836,9 @@ setalg(Espcb *ecb, char **f, int n, Algorithm *alg) if(n != 3) return "bad format"; p = f[2]; - nchar = strlen(p); + nchar = jehanne_strlen(p); if(nchar != nbyte*2){ - print("nchar %d nbyte %d: [%s]\n", nchar, nbyte, p); + jehanne_print("nchar %d nbyte %d: [%s]\n", nchar, nbyte, p); return "bad keylength"; } key = smalloc(nbyte); @@ -851,17 +851,17 @@ setalg(Espcb *ecb, char **f, int n, Algorithm *alg) else if(c >= 'A' && c <= 'F') c -= 'A' - 10; else{ - free(key); + jehanne_free(key); return "bad character in key"; } key[i>>1] |= c<<4*(i&1); } - /* fmtinstall('[', encodefmt); */ + /* jehanne_fmtinstall('[', encodefmt); */ /* netlog(esp->f, Logesp, "%s key is %.*[\n", */ /* alg->name, nbyte, key); */ } alg->init(ecb, alg->name, key, alg->keylen); - free(key); + jehanne_free(key); return nil; } @@ -912,8 +912,8 @@ seanq_hmac_sha1(uint8_t hash[SHA1dlen], uint8_t *t, long tlen, uint8_t *key, lon uint8_t ipad[Hmacblksz+1], opad[Hmacblksz+1], innerhash[SHA1dlen]; DigestState *digest; - memset(ipad, 0x36, Hmacblksz); - memset(opad, 0x5c, Hmacblksz); + jehanne_memset(ipad, 0x36, Hmacblksz); + jehanne_memset(opad, 0x5c, Hmacblksz); ipad[Hmacblksz] = opad[Hmacblksz] = 0; for(i = 0; i < klen; i++){ ipad[i] ^= key[i]; @@ -931,10 +931,10 @@ shaauth(Espcb *ecb, uint8_t *t, int tlen, uint8_t *auth) int r; uint8_t hash[SHA1dlen]; - memset(hash, 0, SHA1dlen); + jehanne_memset(hash, 0, SHA1dlen); seanq_hmac_sha1(hash, t, tlen, (uint8_t*)ecb->ahstate, BITS2BYTES(128)); - r = memcmp(auth, hash, ecb->ahlen) == 0; - memmove(auth, hash, ecb->ahlen); + r = jehanne_memcmp(auth, hash, ecb->ahlen) == 0; + jehanne_memmove(auth, hash, ecb->ahlen); return r; } @@ -950,7 +950,7 @@ shaahinit(Espcb *ecb, char *name, uint8_t *key, unsigned klen) ecb->ahlen = BITS2BYTES(96); ecb->auth = shaauth; ecb->ahstate = smalloc(klen); - memmove(ecb->ahstate, key, klen); + jehanne_memmove(ecb->ahstate, key, klen); } @@ -965,11 +965,11 @@ aesahauth(Espcb *ecb, uint8_t *t, int tlen, uint8_t *auth) int r; uint8_t hash[AESdlen]; - memset(hash, 0, AESdlen); + jehanne_memset(hash, 0, AESdlen); ecb->ds = hmac_aes(t, tlen, (uint8_t*)ecb->ahstate, BITS2BYTES(96), hash, ecb->ds); - r = memcmp(auth, hash, ecb->ahlen) == 0; - memmove(auth, hash, ecb->ahlen); + r = jehanne_memcmp(auth, hash, ecb->ahlen) == 0; + jehanne_memmove(auth, hash, ecb->ahlen); return r; } @@ -985,7 +985,7 @@ aesahinit(Espcb *ecb, char *name, uint8_t *key, unsigned klen) ecb->ahlen = BITS2BYTES(96); ecb->auth = aesahauth; ecb->ahstate = smalloc(klen); - memmove(ecb->ahstate, key, klen); + jehanne_memmove(ecb->ahstate, key, klen); } static int @@ -997,12 +997,12 @@ aescbccipher(Espcb *ecb, uint8_t *p, int n) /* 128-bit blocks */ ep = p + n; if(ecb->incoming) { - memmove(ds->ivec, p, AESbsize); + jehanne_memmove(ds->ivec, p, AESbsize); p += AESbsize; while(p < ep){ - memmove(tmp, p, AESbsize); + jehanne_memmove(tmp, p, AESbsize); aes_decrypt(ds->dkey, ds->rounds, p, q); - memmove(p, q, AESbsize); + jehanne_memmove(p, q, AESbsize); tp = tmp; ip = ds->ivec; for(eip = ip + AESbsize; ip < eip; ){ @@ -1011,15 +1011,15 @@ aescbccipher(Espcb *ecb, uint8_t *p, int n) /* 128-bit blocks */ } } } else { - memmove(p, ds->ivec, AESbsize); + jehanne_memmove(p, ds->ivec, AESbsize); for(p += AESbsize; p < ep; p += AESbsize){ pp = p; ip = ds->ivec; for(eip = ip + AESbsize; ip < eip; ) *pp++ ^= *ip++; aes_encrypt(ds->ekey, ds->rounds, p, q); - memmove(ds->ivec, q, AESbsize); - memmove(p, q, AESbsize); + jehanne_memmove(ds->ivec, q, AESbsize); + jehanne_memmove(p, q, AESbsize); } } return 1; @@ -1034,8 +1034,8 @@ aescbcespinit(Espcb *ecb, char *name, uint8_t *k, unsigned n) n = BITS2BYTES(n); if(n > Aeskeysz) n = Aeskeysz; - memset(key, 0, sizeof(key)); - memmove(key, k, n); + jehanne_memset(key, 0, sizeof(key)); + jehanne_memmove(key, k, n); for(i = 0; i < Aeskeysz; i++) ivec[i] = nrand(256); ecb->espalg = name; @@ -1055,12 +1055,12 @@ aesctrcipher(Espcb *ecb, uint8_t *p, int n) /* 128-bit blocks */ ep = p + n; if(ecb->incoming) { - memmove(ds->ivec, p, AESbsize); + jehanne_memmove(ds->ivec, p, AESbsize); p += AESbsize; while(p < ep){ - memmove(tmp, p, AESbsize); + jehanne_memmove(tmp, p, AESbsize); aes_decrypt(ds->dkey, ds->rounds, p, q); - memmove(p, q, AESbsize); + jehanne_memmove(p, q, AESbsize); tp = tmp; ip = ds->ivec; for(eip = ip + AESbsize; ip < eip; ){ @@ -1069,15 +1069,15 @@ aesctrcipher(Espcb *ecb, uint8_t *p, int n) /* 128-bit blocks */ } } } else { - memmove(p, ds->ivec, AESbsize); + jehanne_memmove(p, ds->ivec, AESbsize); for(p += AESbsize; p < ep; p += AESbsize){ pp = p; ip = ds->ivec; for(eip = ip + AESbsize; ip < eip; ) *pp++ ^= *ip++; aes_encrypt(ds->ekey, ds->rounds, p, q); - memmove(ds->ivec, q, AESbsize); - memmove(p, q, AESbsize); + jehanne_memmove(ds->ivec, q, AESbsize); + jehanne_memmove(p, q, AESbsize); } } return 1; @@ -1092,8 +1092,8 @@ aesctrespinit(Espcb *ecb, char *name, uint8_t *k, unsigned n) n = BITS2BYTES(n); if(n > Aeskeysz) n = Aeskeysz; - memset(key, 0, sizeof(key)); - memmove(key, k, n); + jehanne_memset(key, 0, sizeof(key)); + jehanne_memmove(key, k, n); for(i = 0; i < Aesblk; i++) ivec[i] = nrand(256); ecb->espalg = name; @@ -1116,8 +1116,8 @@ seanq_hmac_md5(uint8_t hash[MD5dlen], uint8_t *t, long tlen, uint8_t *key, long uint8_t ipad[Hmacblksz+1], opad[Hmacblksz+1], innerhash[MD5dlen]; DigestState *digest; - memset(ipad, 0x36, Hmacblksz); - memset(opad, 0x5c, Hmacblksz); + jehanne_memset(ipad, 0x36, Hmacblksz); + jehanne_memset(opad, 0x5c, Hmacblksz); ipad[Hmacblksz] = opad[Hmacblksz] = 0; for(i = 0; i < klen; i++){ ipad[i] ^= key[i]; @@ -1135,10 +1135,10 @@ md5auth(Espcb *ecb, uint8_t *t, int tlen, uint8_t *auth) uint8_t hash[MD5dlen]; int r; - memset(hash, 0, MD5dlen); + jehanne_memset(hash, 0, MD5dlen); seanq_hmac_md5(hash, t, tlen, (uint8_t*)ecb->ahstate, BITS2BYTES(128)); - r = memcmp(auth, hash, ecb->ahlen) == 0; - memmove(auth, hash, ecb->ahlen); + r = jehanne_memcmp(auth, hash, ecb->ahlen) == 0; + jehanne_memmove(auth, hash, ecb->ahlen); return r; } @@ -1153,7 +1153,7 @@ md5ahinit(Espcb *ecb, char *name, uint8_t *key, unsigned klen) ecb->ahlen = BITS2BYTES(96); ecb->auth = md5auth; ecb->ahstate = smalloc(klen); - memmove(ecb->ahstate, key, klen); + jehanne_memmove(ecb->ahstate, key, klen); } @@ -1167,10 +1167,10 @@ descipher(Espcb *ecb, uint8_t *p, int n) DESstate *ds = ecb->espstate; if(ecb->incoming) { - memmove(ds->ivec, p, Desblk); + jehanne_memmove(ds->ivec, p, Desblk); desCBCdecrypt(p + Desblk, n - Desblk, ds); } else { - memmove(p, ds->ivec, Desblk); + jehanne_memmove(p, ds->ivec, Desblk); desCBCencrypt(p + Desblk, n - Desblk, ds); } return 1; @@ -1182,10 +1182,10 @@ des3cipher(Espcb *ecb, uint8_t *p, int n) DES3state *ds = ecb->espstate; if(ecb->incoming) { - memmove(ds->ivec, p, Desblk); + jehanne_memmove(ds->ivec, p, Desblk); des3CBCdecrypt(p + Desblk, n - Desblk, ds); } else { - memmove(p, ds->ivec, Desblk); + jehanne_memmove(p, ds->ivec, Desblk); des3CBCencrypt(p + Desblk, n - Desblk, ds); } return 1; @@ -1200,8 +1200,8 @@ desespinit(Espcb *ecb, char *name, uint8_t *k, unsigned n) n = BITS2BYTES(n); if(n > Desblk) n = Desblk; - memset(key, 0, sizeof(key)); - memmove(key, k, n); + jehanne_memset(key, 0, sizeof(key)); + jehanne_memmove(key, k, n); for(i = 0; i < Desblk; i++) ivec[i] = nrand(256); ecb->espalg = name; @@ -1222,8 +1222,8 @@ des3espinit(Espcb *ecb, char *name, uint8_t *k, unsigned n) n = BITS2BYTES(n); if(n > Des3keysz) n = Des3keysz; - memset(key, 0, sizeof(key)); - memmove(key, k, n); + jehanne_memset(key, 0, sizeof(key)); + jehanne_memmove(key, k, n); for(i = 0; i < Desblk; i++) ivec[i] = nrand(256); ecb->espalg = name; diff --git a/sys/src/kern/ip/ethermedium.c b/sys/src/kern/ip/ethermedium.c index 19d0087..dff4e83 100644 --- a/sys/src/kern/ip/ethermedium.c +++ b/sys/src/kern/ip/ethermedium.c @@ -152,7 +152,7 @@ etherbind(Ipifc *ifc, int argc, char **argv) if(cchan6 != nil) cclose(cchan6); if(buf != nil) - free(buf); + jehanne_free(buf); nexterror(); } @@ -162,18 +162,18 @@ etherbind(Ipifc *ifc, int argc, char **argv) * the dial will fail if the type is already open on * this device. */ - snprint(addr, sizeof(addr), "%s!0x800", argv[2]); /* ETIP4 */ + jehanne_snprint(addr, sizeof(addr), "%s!0x800", argv[2]); /* ETIP4 */ mchan4 = chandial(addr, nil, dir, &cchan4); /* * make it non-blocking */ - cchan4->dev->write(cchan4, nbmsg, strlen(nbmsg), 0); + cchan4->dev->write(cchan4, nbmsg, jehanne_strlen(nbmsg), 0); /* * get mac address and speed */ - snprint(addr, sizeof(addr), "%s/stats", argv[2]); + jehanne_snprint(addr, sizeof(addr), "%s/stats", argv[2]); buf = smalloc(512); schan = namec(addr, Aopen, OREAD, 0); if(waserror()){ @@ -185,23 +185,23 @@ etherbind(Ipifc *ifc, int argc, char **argv) poperror(); buf[n] = 0; - ptr = strstr(buf, "addr: "); + ptr = jehanne_strstr(buf, "addr: "); if(!ptr) error(Eio); ptr += 6; parsemac(ifc->mac, ptr, 6); - ptr = strstr(buf, "mbps: "); + ptr = jehanne_strstr(buf, "mbps: "); if(ptr){ ptr += 6; - ifc->mbps = atoi(ptr); + ifc->mbps = jehanne_atoi(ptr); } else ifc->mbps = 100; /* * open arp conversation */ - snprint(addr, sizeof(addr), "%s!0x806", argv[2]); /* ETARP */ + jehanne_snprint(addr, sizeof(addr), "%s!0x806", argv[2]); /* ETARP */ achan = chandial(addr, nil, nil, nil); /* @@ -210,13 +210,13 @@ etherbind(Ipifc *ifc, int argc, char **argv) * the dial will fail if the type is already open on * this device. */ - snprint(addr, sizeof(addr), "%s!0x86DD", argv[2]); /* ETIP6 */ + jehanne_snprint(addr, sizeof(addr), "%s!0x86DD", argv[2]); /* ETIP6 */ mchan6 = chandial(addr, nil, dir, &cchan6); /* * make it non-blocking */ - cchan6->dev->write(cchan6, nbmsg, strlen(nbmsg), 0); + cchan6->dev->write(cchan6, nbmsg, jehanne_strlen(nbmsg), 0); er = smalloc(sizeof(*er)); er->mchan4 = mchan4; @@ -227,7 +227,7 @@ etherbind(Ipifc *ifc, int argc, char **argv) er->f = ifc->conv->p->f; ifc->arg = er; - free(buf); + jehanne_free(buf); poperror(); kproc("etherread4", etherread4, ifc); @@ -265,7 +265,7 @@ etherunbind(Ipifc *ifc) if(er->cchan6 != nil) cclose(er->cchan6); - free(er); + jehanne_free(er); } /* @@ -308,8 +308,8 @@ etherbwrite(Ipifc *ifc, Block *bp, int version, uint8_t *ip) eh = (Etherhdr*)bp->rp; /* copy in mac addresses and ether type */ - memmove(eh->s, ifc->mac, sizeof(eh->s)); - memmove(eh->d, mac, sizeof(eh->d)); + jehanne_memmove(eh->s, ifc->mac, sizeof(eh->s)); + jehanne_memmove(eh->d, mac, sizeof(eh->d)); switch(version){ case V4: @@ -417,13 +417,13 @@ etheraddmulti(Ipifc *ifc, uint8_t *a, uint8_t * _1) int version; version = multicastea(mac, a); - sprint(buf, "addmulti %E", mac); + jehanne_sprint(buf, "addmulti %E", mac); switch(version){ case V4: - er->cchan4->dev->write(er->cchan4, buf, strlen(buf), 0); + er->cchan4->dev->write(er->cchan4, buf, jehanne_strlen(buf), 0); break; case V6: - er->cchan6->dev->write(er->cchan6, buf, strlen(buf), 0); + er->cchan6->dev->write(er->cchan6, buf, jehanne_strlen(buf), 0); break; default: panic("etheraddmulti: version %d", version); @@ -439,13 +439,13 @@ etherremmulti(Ipifc *ifc, uint8_t *a, uint8_t * _1) int version; version = multicastea(mac, a); - sprint(buf, "remmulti %E", mac); + jehanne_sprint(buf, "remmulti %E", mac); switch(version){ case V4: - er->cchan4->dev->write(er->cchan4, buf, strlen(buf), 0); + er->cchan4->dev->write(er->cchan4, buf, jehanne_strlen(buf), 0); break; case V6: - er->cchan6->dev->write(er->cchan6, buf, strlen(buf), 0); + er->cchan6->dev->write(er->cchan6, buf, jehanne_strlen(buf), 0); break; default: panic("etherremmulti: version %d", version); @@ -486,13 +486,13 @@ sendarp(Ipifc *ifc, Arpent *a) if(n < a->type->mintu) n = a->type->mintu; bp = allocb(n); - memset(bp->rp, 0, n); + jehanne_memset(bp->rp, 0, n); e = (Etherarp*)bp->rp; - memmove(e->tpa, a->ip+IPv4off, sizeof(e->tpa)); + jehanne_memmove(e->tpa, a->ip+IPv4off, sizeof(e->tpa)); ipv4local(ifc, e->spa); - memmove(e->sha, ifc->mac, sizeof(e->sha)); - memset(e->d, 0xff, sizeof(e->d)); /* ethernet broadcast */ - memmove(e->s, ifc->mac, sizeof(e->s)); + jehanne_memmove(e->sha, ifc->mac, sizeof(e->sha)); + jehanne_memset(e->d, 0xff, sizeof(e->d)); /* ethernet broadcast */ + jehanne_memmove(e->s, ifc->mac, sizeof(e->s)); hnputs(e->type, ETARP); hnputs(e->hrd, 1); @@ -561,13 +561,13 @@ sendgarp(Ipifc *ifc, uint8_t *ip) if(n < ifc->medium->mintu) n = ifc->medium->mintu; bp = allocb(n); - memset(bp->rp, 0, n); + jehanne_memset(bp->rp, 0, n); e = (Etherarp*)bp->rp; - memmove(e->tpa, ip+IPv4off, sizeof(e->tpa)); - memmove(e->spa, ip+IPv4off, sizeof(e->spa)); - memmove(e->sha, ifc->mac, sizeof(e->sha)); - memset(e->d, 0xff, sizeof(e->d)); /* ethernet broadcast */ - memmove(e->s, ifc->mac, sizeof(e->s)); + jehanne_memmove(e->tpa, ip+IPv4off, sizeof(e->tpa)); + jehanne_memmove(e->spa, ip+IPv4off, sizeof(e->spa)); + jehanne_memmove(e->sha, ifc->mac, sizeof(e->sha)); + jehanne_memset(e->d, 0xff, sizeof(e->d)); /* ethernet broadcast */ + jehanne_memmove(e->s, ifc->mac, sizeof(e->s)); hnputs(e->type, ETARP); hnputs(e->hrd, 1); @@ -603,8 +603,8 @@ recvarp(Ipifc *ifc) /* check for machine using my ip address */ v4tov6(ip, e->spa); if(iplocalonifc(ifc, ip) || ipproxyifc(er->f, ifc, ip)){ - if(memcmp(e->sha, ifc->mac, sizeof(e->sha)) != 0){ - print("arprep: 0x%E/0x%E also has ip addr %V\n", + if(jehanne_memcmp(e->sha, ifc->mac, sizeof(e->sha)) != 0){ + jehanne_print("arprep: 0x%E/0x%E also has ip addr %V\n", e->s, e->sha, e->spa); break; } @@ -612,8 +612,8 @@ recvarp(Ipifc *ifc) /* make sure we're not entering broadcast addresses */ if(ipcmp(ip, ipbroadcast) == 0 || - !memcmp(e->sha, etherbroadcast, sizeof(e->sha))){ - print("arprep: 0x%E/0x%E cannot register broadcast address %I\n", + !jehanne_memcmp(e->sha, etherbroadcast, sizeof(e->sha))){ + jehanne_print("arprep: 0x%E/0x%E cannot register broadcast address %I\n", e->s, e->sha, e->spa); break; } @@ -629,18 +629,18 @@ recvarp(Ipifc *ifc) /* check for machine using my ip or ether address */ v4tov6(ip, e->spa); if(iplocalonifc(ifc, ip) || ipproxyifc(er->f, ifc, ip)){ - if(memcmp(e->sha, ifc->mac, sizeof(e->sha)) != 0){ - if (memcmp(eprinted, e->spa, sizeof(e->spa))){ + if(jehanne_memcmp(e->sha, ifc->mac, sizeof(e->sha)) != 0){ + if (jehanne_memcmp(eprinted, e->spa, sizeof(e->spa))){ /* print only once */ - print("arpreq: 0x%E also has ip addr %V\n", e->sha, e->spa); - memmove(eprinted, e->spa, sizeof(e->spa)); + jehanne_print("arpreq: 0x%E also has ip addr %V\n", e->sha, e->spa); + jehanne_memmove(eprinted, e->spa, sizeof(e->spa)); } } } else { - if(memcmp(e->sha, ifc->mac, sizeof(e->sha)) == 0){ + if(jehanne_memcmp(e->sha, ifc->mac, sizeof(e->sha)) == 0){ /* Ignore ARP probes from ourself. */ - if(memcmp(e->spa, nullspa, sizeof(e->spa)) != 0) - print("arpreq: %V also has ether addr %E\n", e->spa, e->sha); + if(jehanne_memcmp(e->spa, nullspa, sizeof(e->spa)) != 0) + jehanne_print("arpreq: %V also has ether addr %E\n", e->spa, e->sha); break; } } @@ -659,19 +659,19 @@ recvarp(Ipifc *ifc) n = ifc->mintu; rbp = allocb(n); r = (Etherarp*)rbp->rp; - memset(r, 0, sizeof(Etherarp)); + jehanne_memset(r, 0, sizeof(Etherarp)); hnputs(r->type, ETARP); hnputs(r->hrd, 1); hnputs(r->pro, ETIP4); r->hln = sizeof(r->sha); r->pln = sizeof(r->spa); hnputs(r->op, ARPREPLY); - memmove(r->tha, e->sha, sizeof(r->tha)); - memmove(r->tpa, e->spa, sizeof(r->tpa)); - memmove(r->sha, ifc->mac, sizeof(r->sha)); - memmove(r->spa, e->tpa, sizeof(r->spa)); - memmove(r->d, e->sha, sizeof(r->d)); - memmove(r->s, ifc->mac, sizeof(r->s)); + jehanne_memmove(r->tha, e->sha, sizeof(r->tha)); + jehanne_memmove(r->tpa, e->spa, sizeof(r->tpa)); + jehanne_memmove(r->sha, ifc->mac, sizeof(r->sha)); + jehanne_memmove(r->spa, e->tpa, sizeof(r->spa)); + jehanne_memmove(r->d, e->sha, sizeof(r->d)); + jehanne_memmove(r->s, ifc->mac, sizeof(r->s)); rbp->wp += n; er->achan->dev->bwrite(er->achan, rbp, 0); @@ -733,7 +733,7 @@ multicastarp(Fs *f, Arpent *a, Medium *medium, uint8_t *mac) case Runi: return nil; case Rbcast: - memset(mac, 0xff, 6); + jehanne_memset(mac, 0xff, 6); return arpresolve(f->arp, a, medium, mac); default: break; diff --git a/sys/src/kern/ip/gre.c b/sys/src/kern/ip/gre.c index cf1109b..c38316d 100644 --- a/sys/src/kern/ip/gre.c +++ b/sys/src/kern/ip/gre.c @@ -221,7 +221,7 @@ grestate(Conv *c, char *state, int n) grec = c->ptcl; p = state; ep = p + n; - p = seprint(p, ep, "%s%s%s%shoa %V north %V south %V seq %ulx " + p = jehanne_seprint(p, ep, "%s%s%s%shoa %V north %V south %V seq %ulx " "pending %uld %uld buffered dl %uld %uld ul %uld %uld ulkey %.8ulx\n", c->inuse? "Open ": "Closed ", grec->raw? "raw ": "", @@ -250,9 +250,9 @@ greclose(Conv *c) grec = c->ptcl; /* Make sure we don't forward any more packets */ - memset(grec->hoa, 0, sizeof grec->hoa); - memset(grec->north, 0, sizeof grec->north); - memset(grec->south, 0, sizeof grec->south); + jehanne_memset(grec->hoa, 0, sizeof grec->hoa); + jehanne_memset(grec->north, 0, sizeof grec->north); + jehanne_memset(grec->south, 0, sizeof grec->south); qlock(&grec->lock); while((bp = getring(&grec->dlpending)) != nil) @@ -311,13 +311,13 @@ grekick(void *x, Block *bp) if(grec->raw == 0){ v4tov6(raddr, gre->dst); if(ipcmp(raddr, v4prefix) == 0) - memmove(gre->dst, c->raddr + IPv4off, IPv4addrlen); + jehanne_memmove(gre->dst, c->raddr + IPv4off, IPv4addrlen); v4tov6(laddr, gre->src); if(ipcmp(laddr, v4prefix) == 0){ if(ipcmp(c->laddr, IPnoaddr) == 0) /* pick interface closest to dest */ findlocalip(c->p->f, c->laddr, raddr); - memmove(gre->src, c->laddr + IPv4off, sizeof gre->src); + jehanne_memmove(gre->src, c->laddr + IPv4off, sizeof gre->src); } hnputs(gre->eproto, c->rport); } @@ -357,7 +357,7 @@ gredownlink(Conv *c, Block *bp) if(flags & GRE_cksum) hdrlen += 2; if(flags & GRE_routing){ - print("%V routing info present. Discarding packet", gre->src); + jehanne_print("%V routing info present. Discarding packet", gre->src); freeb(bp); return; } @@ -375,11 +375,11 @@ gredownlink(Conv *c, Block *bp) if(hdrlen != sizeof(uint32_t)){ extra = hdrlen - sizeof(uint32_t); if(extra < 0 && bp->rp - bp->base < -extra){ - print("gredownlink: cannot add sequence number\n"); + jehanne_print("gredownlink: cannot add sequence number\n"); freeb(bp); return; } - memmove(bp->rp + extra, bp->rp, sizeof(GREhdr)); + jehanne_memmove(bp->rp + extra, bp->rp, sizeof(GREhdr)); bp->rp += extra; assert(BLEN(bp) >= sizeof(GREhdr) + sizeof(uint32_t)); gre = (GREhdr *)bp->rp; @@ -434,8 +434,8 @@ restart: * When we get here, we're not suspended. Proceed to send the * packet. */ - memmove(gre->src, grec->coa, sizeof gre->dst); - memmove(gre->dst, grec->south, sizeof gre->dst); + jehanne_memmove(gre->src, grec->coa, sizeof gre->dst); + jehanne_memmove(gre->dst, grec->south, sizeof gre->dst); /* * Make sure the packet does not go away. @@ -470,8 +470,8 @@ greuplink(Conv *c, Block *bp) return; grec = c->ptcl; - memmove(gre->src, grec->coa, sizeof gre->src); - memmove(gre->dst, grec->north, sizeof gre->dst); + jehanne_memmove(gre->src, grec->coa, sizeof gre->src); + jehanne_memmove(gre->dst, grec->north, sizeof gre->dst); /* * Add a key, if needed. @@ -479,7 +479,7 @@ greuplink(Conv *c, Block *bp) if(grec->ulkey){ flags = nhgets(gre->flags); if(flags & (GRE_cksum|GRE_routing)){ - print("%V routing info present. Discarding packet\n", + jehanne_print("%V routing info present. Discarding packet\n", gre->src); freeb(bp); return; @@ -488,13 +488,13 @@ greuplink(Conv *c, Block *bp) if((flags & GRE_key) == 0){ /* Make room for the key */ if(bp->rp - bp->base < sizeof(uint32_t)){ - print("%V can't add key\n", gre->src); + jehanne_print("%V can't add key\n", gre->src); freeb(bp); return; } bp->rp -= 4; - memmove(bp->rp, bp->rp + 4, sizeof(GREhdr)); + jehanne_memmove(bp->rp, bp->rp + 4, sizeof(GREhdr)); gre = (GREhdr *)bp->rp; hnputs(gre->flags, flags | GRE_key); @@ -556,7 +556,7 @@ greiput(Proto *proto, Ipifc * _1, Block *bp) if(flags & GRE_cksum) hdrlen += 2; if(flags & GRE_routing){ - print("%I routing info present. Discarding packet\n", raddr); + jehanne_print("%I routing info present. Discarding packet\n", raddr); freeb(bp); return; } @@ -568,7 +568,7 @@ greiput(Proto *proto, Ipifc * _1, Block *bp) hdrlen += 4; if(BLEN(bp) - hdrlen < sizeof(Ip4hdr)){ - print("greretunnel: packet too short (s=%V d=%V)\n", + jehanne_print("greretunnel: packet too short (s=%V d=%V)\n", gre->src, gre->dst); freeb(bp); return; @@ -591,7 +591,7 @@ greiput(Proto *proto, Ipifc * _1, Block *bp) * implies that etherread is blocked. */ grec = c->ptcl; - if(memcmp(ip->dst, grec->hoa, sizeof ip->dst) == 0){ + if(jehanne_memcmp(ip->dst, grec->hoa, sizeof ip->dst) == 0){ grepdin++; grebdin += BLEN(bp); gredownlink(c, bp); @@ -599,7 +599,7 @@ greiput(Proto *proto, Ipifc * _1, Block *bp) return; } - if(memcmp(ip->src, grec->hoa, sizeof ip->src) == 0){ + if(jehanne_memcmp(ip->src, grec->hoa, sizeof ip->src) == 0){ grepuin++; grebuin += BLEN(bp); greuplink(c, bp); @@ -670,7 +670,7 @@ grestats(Proto *gre, char *buf, int len) GREpriv *gpriv; gpriv = gre->priv; - return snprint(buf, len, + return jehanne_snprint(buf, len, "gre: %llud %llud %llud %llud %llud %llud %llud %llud, lenerrs %llud\n", grepdin, grepdout, grepuin, grepuout, grebdin, grebdout, grebuin, grebuout, gpriv->lenerr); @@ -703,19 +703,19 @@ grectlretunnel(Conv *c, int _1, char **argv) uint8_t ipaddr[4]; grec = c->ptcl; - if(memcmp(grec->hoa, nulladdr, sizeof grec->hoa)) + if(jehanne_memcmp(grec->hoa, nulladdr, sizeof grec->hoa)) return "tunnel already set up"; v4parseip(ipaddr, argv[1]); - if(memcmp(ipaddr, nulladdr, sizeof ipaddr) == 0) + if(jehanne_memcmp(ipaddr, nulladdr, sizeof ipaddr) == 0) return "bad hoa"; - memmove(grec->hoa, ipaddr, sizeof grec->hoa); + jehanne_memmove(grec->hoa, ipaddr, sizeof grec->hoa); v4parseip(ipaddr, argv[2]); - memmove(grec->north, ipaddr, sizeof grec->north); + jehanne_memmove(grec->north, ipaddr, sizeof grec->north); v4parseip(ipaddr, argv[3]); - memmove(grec->south, ipaddr, sizeof grec->south); + jehanne_memmove(grec->south, ipaddr, sizeof grec->south); v4parseip(ipaddr, argv[4]); - memmove(grec->coa, ipaddr, sizeof grec->coa); + jehanne_memmove(grec->coa, ipaddr, sizeof grec->coa); grec->ulsusp = 1; grec->dlsusp = 0; @@ -732,7 +732,7 @@ grectlreport(Conv *c, int _1, char **argv) Metablock *m; grec = c->ptcl; - seq = strtoul(argv[1], nil, 0); + seq = jehanne_strtoul(argv[1], nil, 0); qlock(&grec->lock); r = &grec->dlpending; @@ -841,7 +841,7 @@ grectlforward(Conv *c, int _1, char **argv) grec = c->ptcl; v4parseip(grec->south, argv[1]); - memmove(grec->north, grec->south, sizeof grec->north); + jehanne_memmove(grec->north, grec->south, sizeof grec->north); qlock(&grec->lock); if(!grec->dlsusp){ @@ -860,8 +860,8 @@ grectlforward(Conv *c, int _1, char **argv) bp->rp = m->rp; gre = (GREhdr *)bp->rp; - memmove(gre->src, grec->coa, sizeof gre->dst); - memmove(gre->dst, grec->south, sizeof gre->dst); + jehanne_memmove(gre->src, grec->coa, sizeof gre->dst); + jehanne_memmove(gre->dst, grec->south, sizeof gre->dst); qunlock(&grec->lock); ipoput4(c->p->f, bp, 0, gre->ttl - 1, gre->tos, nil); @@ -870,8 +870,8 @@ grectlforward(Conv *c, int _1, char **argv) while((bp = getring(&grec->dlbuffered)) != nil){ gre = (GREhdr *)bp->rp; - memmove(gre->src, grec->coa, sizeof gre->dst); - memmove(gre->dst, grec->south, sizeof gre->dst); + jehanne_memmove(gre->src, grec->coa, sizeof gre->dst); + jehanne_memmove(gre->dst, grec->south, sizeof gre->dst); qunlock(&grec->lock); ipoput4(c->p->f, bp, 0, gre->ttl - 1, gre->tos, nil); @@ -881,8 +881,8 @@ grectlforward(Conv *c, int _1, char **argv) while((bp = getring(&grec->ulbuffered)) != nil){ gre = (GREhdr *)bp->rp; - memmove(gre->src, grec->coa, sizeof gre->dst); - memmove(gre->dst, grec->south, sizeof gre->dst); + jehanne_memmove(gre->src, grec->coa, sizeof gre->dst); + jehanne_memmove(gre->dst, grec->south, sizeof gre->dst); qunlock(&grec->lock); ipoput4(c->p->f, bp, 0, gre->ttl - 1, gre->tos, nil); @@ -898,7 +898,7 @@ grectlulkey(Conv *c, int _1, char **argv) GREconv *grec; grec = c->ptcl; - grec->ulkey = strtoul(argv[1], nil, 0); + grec->ulkey = jehanne_strtoul(argv[1], nil, 0); return nil; } @@ -911,7 +911,7 @@ grectl(Conv *c, char **f, int n) return "too few arguments"; for(i = 0; i < Ncmds; i++) - if(strcmp(f[0], grectls[i].cmd) == 0) + if(jehanne_strcmp(f[0], grectls[i].cmd) == 0) break; if(i == Ncmds) diff --git a/sys/src/kern/ip/icmp.c b/sys/src/kern/ip/icmp.c index a39b0e8..46e611a 100644 --- a/sys/src/kern/ip/icmp.c +++ b/sys/src/kern/ip/icmp.c @@ -130,7 +130,7 @@ extern int icmpstate(Conv *c, char *state, int n) { USED(c); - return snprint(state, n, "%s qin %d qout %d\n", + return jehanne_snprint(state, n, "%s qin %d qout %d\n", "Datagram", c->rq ? qlen(c->rq) : 0, c->wq ? qlen(c->wq) : 0 @@ -184,7 +184,7 @@ icmpkick(void *x, Block *bp) v6tov4(p->src, c->laddr); p->proto = IP_ICMPPROTO; hnputs(p->icmpid, c->lport); - memset(p->cksum, 0, sizeof(p->cksum)); + jehanne_memset(p->cksum, 0, sizeof(p->cksum)); hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE)); ipriv->stats[OutMsgs]++; ipoput4(c->p->f, bp, 0, c->ttl, c->tos, nil); @@ -229,15 +229,15 @@ icmpttlexceeded(Fs *f, uint8_t *ia, Block *bp) nbp->wp += ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8; np = (Icmp *)nbp->rp; np->vihl = IP_VER4; - memmove(np->dst, p->src, sizeof(np->dst)); + jehanne_memmove(np->dst, p->src, sizeof(np->dst)); v6tov4(np->src, ia); - memmove(np->data, bp->rp, ICMP_IPSIZE + 8); + jehanne_memmove(np->data, bp->rp, ICMP_IPSIZE + 8); np->type = TimeExceed; np->code = 0; np->proto = IP_ICMPPROTO; hnputs(np->icmpid, 0); hnputs(np->seq, 0); - memset(np->cksum, 0, sizeof(np->cksum)); + jehanne_memset(np->cksum, 0, sizeof(np->cksum)); hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE)); ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil); } @@ -257,15 +257,15 @@ icmpunreachable(Fs *f, Block *bp, int code, int seq) nbp->wp += ICMP_IPSIZE + ICMP_HDRSIZE + ICMP_IPSIZE + 8; np = (Icmp *)nbp->rp; np->vihl = IP_VER4; - memmove(np->dst, p->src, sizeof(np->dst)); - memmove(np->src, p->dst, sizeof(np->src)); - memmove(np->data, bp->rp, ICMP_IPSIZE + 8); + jehanne_memmove(np->dst, p->src, sizeof(np->dst)); + jehanne_memmove(np->src, p->dst, sizeof(np->src)); + jehanne_memmove(np->data, bp->rp, ICMP_IPSIZE + 8); np->type = Unreachable; np->code = code; np->proto = IP_ICMPPROTO; hnputs(np->icmpid, 0); hnputs(np->seq, seq); - memset(np->cksum, 0, sizeof(np->cksum)); + jehanne_memset(np->cksum, 0, sizeof(np->cksum)); hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE)); ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil); } @@ -315,11 +315,11 @@ mkechoreply(Block *bp, Fs *f) if(!ip4me(f, q->dst) || !ip4reply(f, q->src)) return nil; q->vihl = IP_VER4; - memmove(ip, q->src, sizeof(q->dst)); - memmove(q->src, q->dst, sizeof(q->src)); - memmove(q->dst, ip, sizeof(q->dst)); + jehanne_memmove(ip, q->src, sizeof(q->dst)); + jehanne_memmove(q->src, q->dst, sizeof(q->src)); + jehanne_memmove(q->dst, ip, sizeof(q->dst)); q->type = EchoReply; - memset(q->cksum, 0, sizeof(q->cksum)); + jehanne_memset(q->cksum, 0, sizeof(q->cksum)); hnputs(q->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE)); return bp; @@ -403,7 +403,7 @@ icmpiput(Proto *icmp, Ipifc* _1, Block *bp) break; case Unreachable: if(p->code >= nelem(unreachcode)) { - snprint(m2, sizeof m2, "unreachable %V->%V code %d", + jehanne_snprint(m2, sizeof m2, "unreachable %V->%V code %d", p->src, p->dst, p->code); msg = m2; } else @@ -426,7 +426,7 @@ icmpiput(Proto *icmp, Ipifc* _1, Block *bp) break; case TimeExceed: if(p->code == 0){ - snprint(m2, sizeof m2, "ttl exceeded at %V", p->src); + jehanne_snprint(m2, sizeof m2, "ttl exceeded at %V", p->src); bp->rp += ICMP_IPSIZE+ICMP_HDRSIZE; if(blocklen(bp) < MinAdvise){ @@ -491,12 +491,12 @@ icmpstats(Proto *icmp, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nstats; i++) - p = seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]); + p = jehanne_seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]); for(i = 0; i <= Maxtype; i++){ if(icmpnames[i]) - p = seprint(p, e, "%s: %lud %lud\n", icmpnames[i], priv->in[i], priv->out[i]); + p = jehanne_seprint(p, e, "%s: %lud %lud\n", icmpnames[i], priv->in[i], priv->out[i]); else - p = seprint(p, e, "%d: %lud %lud\n", i, priv->in[i], priv->out[i]); + p = jehanne_seprint(p, e, "%d: %lud %lud\n", i, priv->in[i], priv->out[i]); } return p - buf; } diff --git a/sys/src/kern/ip/icmp6.c b/sys/src/kern/ip/icmp6.c index c02e0e3..aaedcee 100644 --- a/sys/src/kern/ip/icmp6.c +++ b/sys/src/kern/ip/icmp6.c @@ -207,7 +207,7 @@ newIPICMP(int packetlen) nbp = allocb(packetlen); nbp->wp += packetlen; - memset(nbp->rp, 0, packetlen); + jehanne_memset(nbp->rp, 0, packetlen); return nbp; } @@ -286,7 +286,7 @@ icmpctl6(Conv *c, char **argv, int argc) Icmpcb6 *icb; icb = (Icmpcb6*) c->ptcl; - if(argc==1 && strcmp(argv[0], "headers")==0) { + if(argc==1 && jehanne_strcmp(argv[0], "headers")==0) { icb->headers = 6; return nil; } @@ -357,22 +357,22 @@ icmpns(Fs *f, uint8_t* src, int suni, uint8_t* targ, int tuni, uint8_t* mac) np = (Ndpkt*) nbp->rp; if(suni == SRC_UNSPEC) - memmove(np->src, v6Unspecified, IPaddrlen); + jehanne_memmove(np->src, v6Unspecified, IPaddrlen); else - memmove(np->src, src, IPaddrlen); + jehanne_memmove(np->src, src, IPaddrlen); if(tuni == TARG_UNI) - memmove(np->dst, targ, IPaddrlen); + jehanne_memmove(np->dst, targ, IPaddrlen); else ipv62smcast(np->dst, targ); np->type = NbrSolicit; np->code = 0; - memmove(np->target, targ, IPaddrlen); + jehanne_memmove(np->target, targ, IPaddrlen); if(suni != SRC_UNSPEC) { np->otype = SRC_LLADDR; np->olen = 1; /* 1+1+6 = 8 = 1 8-octet */ - memmove(np->lnaddr, mac, sizeof(np->lnaddr)); + jehanne_memmove(np->lnaddr, mac, sizeof(np->lnaddr)); } else nbp->wp -= NDPKTSZ - NDISCSZ; @@ -399,17 +399,17 @@ icmpna(Fs *f, uint8_t* src, uint8_t* dst, uint8_t* targ, uint8_t* mac, uint8_t f nbp = newIPICMP(NDPKTSZ); np = (Ndpkt*)nbp->rp; - memmove(np->src, src, IPaddrlen); - memmove(np->dst, dst, IPaddrlen); + jehanne_memmove(np->src, src, IPaddrlen); + jehanne_memmove(np->dst, dst, IPaddrlen); np->type = NbrAdvert; np->code = 0; np->icmpid[0] = flags; - memmove(np->target, targ, IPaddrlen); + jehanne_memmove(np->target, targ, IPaddrlen); np->otype = TARGET_LLADDR; np->olen = 1; - memmove(np->lnaddr, mac, sizeof(np->lnaddr)); + jehanne_memmove(np->lnaddr, mac, sizeof(np->lnaddr)); set_cksum(nbp); np = (Ndpkt*) nbp->rp; @@ -449,10 +449,10 @@ icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free) goto freebl; } - memmove(np->dst, p->src, IPaddrlen); + jehanne_memmove(np->dst, p->src, IPaddrlen); np->type = UnreachableV6; np->code = code; - memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); + jehanne_memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); set_cksum(nbp); np->ttl = HOP_LIMIT; np->vcf[0] = 0x06 << 4; @@ -496,10 +496,10 @@ icmpttlexceeded6(Fs *f, Ipifc *ifc, Block *bp) return; } - memmove(np->dst, p->src, IPaddrlen); + jehanne_memmove(np->dst, p->src, IPaddrlen); np->type = TimeExceedV6; np->code = 0; - memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); + jehanne_memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); set_cksum(nbp); np->ttl = HOP_LIMIT; np->vcf[0] = 0x06 << 4; @@ -535,11 +535,11 @@ icmppkttoobig6(Fs *f, Ipifc *ifc, Block *bp) return; } - memmove(np->dst, p->src, IPaddrlen); + jehanne_memmove(np->dst, p->src, IPaddrlen); np->type = PacketTooBigV6; np->code = 0; hnputl(np->icmpid, ifc->maxtu - ifc->medium->hsize); - memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); + jehanne_memmove(nbp->rp + IPICMPSZ, bp->rp, sz - IPICMPSZ); set_cksum(nbp); np->ttl = HOP_LIMIT; np->vcf[0] = 0x06 << 4; @@ -580,7 +580,7 @@ valid(Proto *icmp, Ipifc *ifc, Block *bp, Icmppriv6 *ipriv) netlog(icmp->f, Logicmp, "icmp error: extension header\n"); goto err; } - memset(packet, 0, 4); + jehanne_memset(packet, 0, 4); ttl = p->ttl; p->ttl = p->proto; p->proto = 0; @@ -763,7 +763,7 @@ icmpiput6(Proto *icmp, Ipifc *ipifc, Block *bp) case TimeExceedV6: if(p->code == 0){ - sprint(m2, "ttl exceeded at %I", p->src); + jehanne_sprint(m2, "ttl exceeded at %I", p->src); bp->rp += IPICMPSZ; if(blocklen(bp) < 8){ @@ -786,9 +786,9 @@ icmpiput6(Proto *icmp, Ipifc *ipifc, Block *bp) case RouterSolicit: /* using lsrc as a temp, munge hdr for goticmp6 */ if (0) { - memmove(lsrc, p->src, IPaddrlen); - memmove(p->src, p->dst, IPaddrlen); - memmove(p->dst, lsrc, IPaddrlen); + jehanne_memmove(lsrc, p->src, IPaddrlen); + jehanne_memmove(p->src, p->dst, IPaddrlen); + jehanne_memmove(p->dst, lsrc, IPaddrlen); } goticmpkt6(icmp, bp, p->type); break; @@ -863,10 +863,10 @@ icmpstats6(Proto *icmp6, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nstats6; i++) - p = seprint(p, e, "%s: %lud\n", statnames6[i], priv->stats[i]); + p = jehanne_seprint(p, e, "%s: %lud\n", statnames6[i], priv->stats[i]); for(i = 0; i <= Maxtype6; i++) if(icmpnames6[i]) - p = seprint(p, e, "%s: %lud %lud\n", icmpnames6[i], + p = jehanne_seprint(p, e, "%s: %lud %lud\n", icmpnames6[i], priv->in[i], priv->out[i]); return p - buf; } diff --git a/sys/src/kern/ip/il.c b/sys/src/kern/ip/il.c index ab5d1b2..1ca162f 100644 --- a/sys/src/kern/ip/il.c +++ b/sys/src/kern/ip/il.c @@ -241,7 +241,7 @@ ilconnect(Conv *c, char **argv, int argc) /* huge hack to quickly try an il connection */ fast = 0; if(argc > 1){ - p = strstr(argv[1], "!fasttimeout"); + p = jehanne_strstr(argv[1], "!fasttimeout"); if(p != nil){ *p = 0; fast = 1; @@ -260,7 +260,7 @@ ilstate(Conv *c, char *state, int n) Ilcb *ic; ic = (Ilcb*)(c->ptcl); - return snprint(state, n, "%s qin %d qout %d del %5.5d Br %5.5d md %5.5d una %5.5lud rex %5.5d rxq %5.5d max %5.5d\n", + return jehanne_snprint(state, n, "%s qin %d qout %d del %5.5d Br %5.5d md %5.5d una %5.5lud rex %5.5d rxq %5.5d max %5.5d\n", ilstates[ic->state], c->rq ? qlen(c->rq) : 0, c->wq ? qlen(c->wq) : 0, @@ -434,7 +434,7 @@ ilxstats(Proto *il, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nstats; i++) - p = seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]); + p = jehanne_seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]); return p - buf; } @@ -494,7 +494,7 @@ ilrttcalc(Ilcb *ic, Block *bp) /* mdev */ pt = ic->rttlen/(rate>>LogAGain) + (delay>>LogAGain); - ic->mdev += abs(rtt-pt) - (ic->mdev>>LogDGain); + ic->mdev += jehanne_abs(rtt-pt) - (ic->mdev>>LogDGain); if(rtt > ic->maxrtt) ic->maxrtt = rtt; @@ -1125,12 +1125,12 @@ later(uint32_t t1, uint32_t t2, char *x) dt = t1 - t2; if(dt > 0) { if(x != nil && dt > Tfuture) - print("%s: way future %d\n", x, dt); + jehanne_print("%s: way future %d\n", x, dt); return 1; } if(dt < -Tfuture) { if(x != nil) - print("%s: way past %d\n", x, -dt); + jehanne_print("%s: way past %d\n", x, -dt); return 1; } return 0; @@ -1247,7 +1247,7 @@ ilstart(Conv *c, int type, int fasttimeout) if(ipriv->ackprocstarted == 0){ qlock(&ipriv->apl); if(ipriv->ackprocstarted == 0){ - sprint(kpname, "#I%dilack", c->p->f->dev); + jehanne_sprint(kpname, "#I%dilack", c->p->f->dev); kproc(kpname, ilackproc, c->p); ipriv->ackprocstarted = 1; } diff --git a/sys/src/kern/ip/ip.c b/sys/src/kern/ip/ip.c index 566fff7..26ae6d2 100644 --- a/sys/src/kern/ip/ip.c +++ b/sys/src/kern/ip/ip.c @@ -74,7 +74,7 @@ initfrag(IP *ip, int size) Fragment4 *fq4, *eq4; Fragment6 *fq6, *eq6; - ip->fragfree4 = (Fragment4*)malloc(sizeof(Fragment4) * size); + ip->fragfree4 = (Fragment4*)jehanne_malloc(sizeof(Fragment4) * size); if(ip->fragfree4 == nil) panic("initfrag"); @@ -84,7 +84,7 @@ initfrag(IP *ip, int size) ip->fragfree4[size-1].next = nil; - ip->fragfree6 = (Fragment6*)malloc(sizeof(Fragment6) * size); + ip->fragfree6 = (Fragment6*)jehanne_malloc(sizeof(Fragment6) * size); if(ip->fragfree6 == nil) panic("initfrag"); @@ -215,7 +215,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) return 0; } -if((eh->frag[0] & (IP_DF>>8)) && !gating) print("%V: DF set\n", eh->dst); +if((eh->frag[0] & (IP_DF>>8)) && !gating) jehanne_print("%V: DF set\n", eh->dst); if(eh->frag[0] & (IP_DF>>8)){ ip->stats[FragFails]++; @@ -256,7 +256,7 @@ if((eh->frag[0] & (IP_DF>>8)) && !gating) print("%V: DF set\n", eh->dst); nb = allocb(IP4HDR+seglen); feh = (Ip4hdr*)(nb->rp); - memmove(nb->wp, eh, IP4HDR); + jehanne_memmove(nb->wp, eh, IP4HDR); nb->wp += IP4HDR; if((fragoff + seglen) >= dlen) { @@ -282,7 +282,7 @@ if((eh->frag[0] & (IP_DF>>8)) && !gating) print("%V: DF set\n", eh->dst); blklen = chunk; if(BLEN(xp) < chunk) blklen = BLEN(xp); - memmove(nb->wp, xp->rp, blklen); + jehanne_memmove(nb->wp, xp->rp, blklen); nb->wp += blklen; xp->rp += blklen; chunk -= blklen; @@ -368,7 +368,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) if(notforme == 0) { olen = nhgets(h->length); dp = bp->rp + (hl - (IP_HLEN4<<2)); - memmove(dp, h, IP_HLEN4<<2); + jehanne_memmove(dp, h, IP_HLEN4<<2); bp->rp = dp; h = (Ip4hdr*)(bp->rp); h->vihl = (IP_VER4|IP_HLEN4); @@ -384,7 +384,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) } /* don't forward to source's network */ - memset(&conv, 0, sizeof conv); + jehanne_memset(&conv, 0, sizeof conv); r = v4lookup(f, h->dst, &conv); if(r == nil || r->ifc == ifc){ ip->stats[OutDiscards]++; @@ -463,7 +463,7 @@ ipstats(Fs *f, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nipstats; i++) - p = seprint(p, e, "%s: %llud\n", statnames[i], ip->stats[i]); + p = jehanne_seprint(p, e, "%s: %llud\n", statnames[i], ip->stats[i]); return p - buf; } @@ -582,7 +582,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih) BKFG(*l)->flen -= ovlap; BKFG(*l)->foff += ovlap; /* move up ih hdrs */ - memmove((*l)->rp + ovlap, (*l)->rp, IP4HDR); + jehanne_memmove((*l)->rp + ovlap, (*l)->rp, IP4HDR); (*l)->rp += ovlap; break; } diff --git a/sys/src/kern/ip/ip.h b/sys/src/kern/ip/ip.h index 9d02064..9f54620 100644 --- a/sys/src/kern/ip/ip.h +++ b/sys/src/kern/ip/ip.h @@ -659,8 +659,8 @@ extern void v4tov6(uint8_t *v6, uint8_t *v4); extern int v6tov4(uint8_t *v4, uint8_t *v6); extern int eipfmt(Fmt*); -#define ipmove(x, y) memmove(x, y, IPaddrlen) -#define ipcmp(x, y) ( (x)[IPaddrlen-1] != (y)[IPaddrlen-1] || memcmp(x, y, IPaddrlen) ) +#define ipmove(x, y) jehanne_memmove(x, y, IPaddrlen) +#define ipcmp(x, y) ( (x)[IPaddrlen-1] != (y)[IPaddrlen-1] || jehanne_memcmp(x, y, IPaddrlen) ) extern uint8_t IPv4bcast[IPaddrlen]; extern uint8_t IPv4bcastobs[IPaddrlen]; diff --git a/sys/src/kern/ip/ipaux.c b/sys/src/kern/ip/ipaux.c index 17655fa..441b70d 100644 --- a/sys/src/kern/ip/ipaux.c +++ b/sys/src/kern/ip/ipaux.c @@ -197,7 +197,7 @@ void ipv62smcast(uint8_t *smcast, uint8_t *a) { assert(IPaddrlen == 16); - memmove(smcast, v6solicitednode, IPaddrlen); + jehanne_memmove(smcast, v6solicitednode, IPaddrlen); smcast[13] = a[13]; smcast[14] = a[14]; smcast[15] = a[15]; @@ -215,7 +215,7 @@ parsemac(uint8_t *to, char *from, int len) int i; p = from; - memset(to, 0, len); + jehanne_memset(to, 0, len); for(i = 0; i < len; i++){ if(p[0] == '\0' || p[1] == '\0') break; @@ -225,7 +225,7 @@ parsemac(uint8_t *to, char *from, int len) nip[2] = '\0'; p += 2; - to[i] = strtoul(nip, 0, 16); + to[i] = jehanne_strtoul(nip, 0, 16); if(*p == ':') p++; } @@ -284,7 +284,7 @@ iphtrem(Ipht *ht, Conv *c) if((*l)->c == c){ h = *l; (*l) = h->next; - free(h); + jehanne_free(h); break; } unlock(ht); diff --git a/sys/src/kern/ip/ipifc.c b/sys/src/kern/ip/ipifc.c index ad4e1c8..7d0a1fc 100644 --- a/sys/src/kern/ip/ipifc.c +++ b/sys/src/kern/ip/ipifc.c @@ -90,7 +90,7 @@ ipfindmedium(char *name) Medium **mp; for(mp = media; *mp != nil; mp++) - if(strcmp((*mp)->name, name) == 0) + if(jehanne_strcmp((*mp)->name, name) == 0) break; return *mp; } @@ -130,9 +130,9 @@ ipifcbind(Conv *c, char **argv, int argc) /* set the bound device name */ if(argc > 2) - strncpy(ifc->dev, argv[2], sizeof(ifc->dev)); + jehanne_strncpy(ifc->dev, argv[2], sizeof(ifc->dev)); else - snprint(ifc->dev, sizeof ifc->dev, "%s%d", medium->name, c->x); + jehanne_snprint(ifc->dev, sizeof ifc->dev, "%s%d", medium->name, c->x); ifc->dev[sizeof(ifc->dev)-1] = 0; /* set up parameters */ @@ -199,7 +199,7 @@ ipifcunbind(Ipifc *ifc) /* disassociate device */ if(ifc->medium && ifc->medium->unbind) (*ifc->medium->unbind)(ifc); - memset(ifc->dev, 0, sizeof(ifc->dev)); + jehanne_memset(ifc->dev, 0, sizeof(ifc->dev)); ifc->arg = nil; ifc->reassemble = 0; @@ -230,7 +230,7 @@ ipifcstate(Conv *c, char *state, int n) ifc = (Ipifc*)c->ptcl; s = state; e = s+n; - s = seprint(s, e, sfixedformat, + s = jehanne_seprint(s, e, sfixedformat, ifc->dev, ifc->maxtu, ifc->sendra6, ifc->recvra6, ifc->rp.mflag, ifc->rp.oflag, ifc->rp.maxraint, ifc->rp.minraint, ifc->rp.linkmtu, ifc->rp.reachtime, @@ -239,10 +239,10 @@ ipifcstate(Conv *c, char *state, int n) rlock(ifc); for(lifc = ifc->lifc; lifc && s < e; lifc = lifc->next) - s = seprint(s, e, slineformat, lifc->local, + s = jehanne_seprint(s, e, slineformat, lifc->local, lifc->mask, lifc->remote, lifc->validlt, lifc->preflt); if(ifc->lifc == nil) - s = seprint(s, e, "\n"); + s = jehanne_seprint(s, e, "\n"); runlock(ifc); return s - state; } @@ -261,10 +261,10 @@ ipifclocal(Conv *c, char *state, int n) rlock(ifc); for(lifc = ifc->lifc; lifc && s < e; lifc = lifc->next){ - s = seprint(s, e, "%-40.40I ->", lifc->local); + s = jehanne_seprint(s, e, "%-40.40I ->", lifc->local); for(link = lifc->link; link; link = link->lifclink) - s = seprint(s, e, " %-40.40I", link->self->a); - s = seprint(s, e, "\n"); + s = jehanne_seprint(s, e, " %-40.40I", link->self->a); + s = jehanne_seprint(s, e, "\n"); } runlock(ifc); return s - state; @@ -354,7 +354,7 @@ ipifcsetmtu(Ipifc *ifc, char **argv, int argc) if(argc < 2 || ifc->medium == nil) return Ebadarg; - mtu = strtoul(argv[1], 0, 0); + mtu = jehanne_strtoul(argv[1], 0, 0); if(mtu < ifc->medium->mintu || mtu > ifc->medium->maxtu) return Ebadarg; ifc->maxtu = mtu; @@ -379,16 +379,16 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) f = ifc->conv->p->f; type = Rifc; - memset(ip, 0, IPaddrlen); - memset(mask, 0, IPaddrlen); - memset(rem, 0, IPaddrlen); + jehanne_memset(ip, 0, IPaddrlen); + jehanne_memset(mask, 0, IPaddrlen); + jehanne_memset(rem, 0, IPaddrlen); switch(argc){ case 6: - if(strcmp(argv[5], "proxy") == 0) + if(jehanne_strcmp(argv[5], "proxy") == 0) type |= Rproxy; /* fall through */ case 5: - mtu = strtoul(argv[4], 0, 0); + mtu = jehanne_strtoul(argv[4], 0, 0); if(mtu >= ifc->medium->mintu && mtu <= ifc->medium->maxtu) ifc->maxtu = mtu; /* fall through */ @@ -408,7 +408,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) case 2: if (parseip(ip, argv[1]) == -1) return Ebadip; - memmove(mask, defmask(ip), IPaddrlen); + jehanne_memmove(mask, defmask(ip), IPaddrlen); maskip(ip, mask, rem); maskip(rem, mask, net); break; @@ -489,13 +489,13 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) addselfcache(f, ifc, lifc, bcast, Rbcast); /* add network directed broadcast address to the self cache */ - memmove(mask, defmask(ip), IPaddrlen); + jehanne_memmove(mask, defmask(ip), IPaddrlen); for(i = 0; i < IPaddrlen; i++) bcast[i] = (ip[i] & mask[i]) | ~mask[i]; addselfcache(f, ifc, lifc, bcast, Rbcast); /* add network directed network address to the self cache */ - memmove(mask, defmask(ip), IPaddrlen); + jehanne_memmove(mask, defmask(ip), IPaddrlen); for(i = 0; i < IPaddrlen; i++) bcast[i] = (ip[i] & mask[i]) & mask[i]; addselfcache(f, ifc, lifc, bcast, Rbcast); @@ -572,12 +572,12 @@ ipifcremlifc(Ipifc *ifc, Iplifc *lifc) if(ipcmp(lifc->local, v6loopback) == 0) /* remove route for all node multicast */ v6delroute(f, v6allnodesN, v6allnodesNmask, 1); - else if(memcmp(lifc->local, v6linklocal, v6llpreflen) == 0) + else if(jehanne_memcmp(lifc->local, v6linklocal, v6llpreflen) == 0) /* remove route for all link multicast */ v6delroute(f, v6allnodesL, v6allnodesLmask, 1); } - free(lifc); + jehanne_free(lifc); return nil; } @@ -612,9 +612,9 @@ ipifcrem(Ipifc *ifc, char **argv, int argc) * addresss to remove. */ for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next) { - if (memcmp(ip, lifc->local, IPaddrlen) == 0 - && memcmp(mask, lifc->mask, IPaddrlen) == 0 - && memcmp(rem, lifc->remote, IPaddrlen) == 0) + if (jehanne_memcmp(ip, lifc->local, IPaddrlen) == 0 + && jehanne_memcmp(mask, lifc->mask, IPaddrlen) == 0 + && jehanne_memcmp(rem, lifc->remote, IPaddrlen) == 0) break; } @@ -712,28 +712,28 @@ ipifcra6(Ipifc *ifc, char **argv, int argc) return Ebadarg; while (argsleft > 1) { - if(strcmp(argv[i], "recvra") == 0) - ifc->recvra6 = (atoi(argv[i+1]) != 0); - else if(strcmp(argv[i], "sendra") == 0) - ifc->sendra6 = (atoi(argv[i+1]) != 0); - else if(strcmp(argv[i], "mflag") == 0) - ifc->rp.mflag = (atoi(argv[i+1]) != 0); - else if(strcmp(argv[i], "oflag") == 0) - ifc->rp.oflag = (atoi(argv[i+1]) != 0); - else if(strcmp(argv[i], "maxraint") == 0) - ifc->rp.maxraint = atoi(argv[i+1]); - else if(strcmp(argv[i], "minraint") == 0) - ifc->rp.minraint = atoi(argv[i+1]); - else if(strcmp(argv[i], "linkmtu") == 0) - ifc->rp.linkmtu = atoi(argv[i+1]); - else if(strcmp(argv[i], "reachtime") == 0) - ifc->rp.reachtime = atoi(argv[i+1]); - else if(strcmp(argv[i], "rxmitra") == 0) - ifc->rp.rxmitra = atoi(argv[i+1]); - else if(strcmp(argv[i], "ttl") == 0) - ifc->rp.ttl = atoi(argv[i+1]); - else if(strcmp(argv[i], "routerlt") == 0) - ifc->rp.routerlt = atoi(argv[i+1]); + if(jehanne_strcmp(argv[i], "recvra") == 0) + ifc->recvra6 = (jehanne_atoi(argv[i+1]) != 0); + else if(jehanne_strcmp(argv[i], "sendra") == 0) + ifc->sendra6 = (jehanne_atoi(argv[i+1]) != 0); + else if(jehanne_strcmp(argv[i], "mflag") == 0) + ifc->rp.mflag = (jehanne_atoi(argv[i+1]) != 0); + else if(jehanne_strcmp(argv[i], "oflag") == 0) + ifc->rp.oflag = (jehanne_atoi(argv[i+1]) != 0); + else if(jehanne_strcmp(argv[i], "maxraint") == 0) + ifc->rp.maxraint = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "minraint") == 0) + ifc->rp.minraint = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "linkmtu") == 0) + ifc->rp.linkmtu = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "reachtime") == 0) + ifc->rp.reachtime = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "rxmitra") == 0) + ifc->rp.rxmitra = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "ttl") == 0) + ifc->rp.ttl = jehanne_atoi(argv[i+1]); + else if(jehanne_strcmp(argv[i], "routerlt") == 0) + ifc->rp.routerlt = jehanne_atoi(argv[i+1]); else return Ebadarg; @@ -761,34 +761,34 @@ ipifcctl(Conv* c, char**argv, int argc) int i; ifc = (Ipifc*)c->ptcl; - if(strcmp(argv[0], "add") == 0) + if(jehanne_strcmp(argv[0], "add") == 0) return ipifcadd(ifc, argv, argc, 0, nil); - else if(strcmp(argv[0], "try") == 0) + else if(jehanne_strcmp(argv[0], "try") == 0) return ipifcadd(ifc, argv, argc, 1, nil); - else if(strcmp(argv[0], "remove") == 0) + else if(jehanne_strcmp(argv[0], "remove") == 0) return ipifcrem(ifc, argv, argc); - else if(strcmp(argv[0], "unbind") == 0) + else if(jehanne_strcmp(argv[0], "unbind") == 0) return ipifcunbind(ifc); - else if(strcmp(argv[0], "joinmulti") == 0) + else if(jehanne_strcmp(argv[0], "joinmulti") == 0) return ipifcjoinmulti(ifc, argv, argc); - else if(strcmp(argv[0], "leavemulti") == 0) + else if(jehanne_strcmp(argv[0], "leavemulti") == 0) return ipifcleavemulti(ifc, argv, argc); - else if(strcmp(argv[0], "mtu") == 0) + else if(jehanne_strcmp(argv[0], "mtu") == 0) return ipifcsetmtu(ifc, argv, argc); - else if(strcmp(argv[0], "reassemble") == 0){ + else if(jehanne_strcmp(argv[0], "reassemble") == 0){ ifc->reassemble = 1; return nil; } - else if(strcmp(argv[0], "iprouting") == 0){ + else if(jehanne_strcmp(argv[0], "iprouting") == 0){ i = 1; if(argc > 1) - i = atoi(argv[1]); + i = jehanne_atoi(argv[1]); iprouting(c->p->f, i); return nil; } - else if(strcmp(argv[0], "add6") == 0) + else if(jehanne_strcmp(argv[0], "add6") == 0) return ipifcadd6(ifc, argv, argc); - else if(strcmp(argv[0], "ra6") == 0) + else if(jehanne_strcmp(argv[0], "ra6") == 0) return ipifcra6(ifc, argv, argc); return "unsupported ctl"; } @@ -844,7 +844,7 @@ addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a, int type) /* see if the address already exists */ h = hashipa(a); for(p = f->self->hash[h]; p; p = p->next) - if(memcmp(a, p->a, IPaddrlen) == 0) + if(jehanne_memcmp(a, p->a, IPaddrlen) == 0) break; /* allocate a local address and add to hash chain */ @@ -910,7 +910,7 @@ iplinkfree(Iplink *p) for(np = *l; np; np = *l){ if(np->expire > now){ *l = np->next; - free(np); + jehanne_free(np); continue; } l = &np->next; @@ -930,7 +930,7 @@ ipselffree(Ipself *p) for(np = *l; np; np = *l){ if(np->expire > now){ *l = np->next; - free(np); + jehanne_free(np); continue; } l = &np->next; @@ -1048,7 +1048,7 @@ ipselftabread(Fs *f, char *cp, uint32_t offset, int n) for(link = p->link; link; link = link->selflink) nifc++; routetype(p->type, state); - s = seprint(s, e, stformat, p->a, nifc, state); + s = jehanne_seprint(s, e, stformat, p->a, nifc, state); if(off > 0){ off -= s - cp; s = cp; @@ -1109,7 +1109,7 @@ findipifc(Fs *f, uint8_t *remote, int type) uint8_t gnet[IPaddrlen], xmask[IPaddrlen]; x = nil; - memset(xmask, 0, IPaddrlen); + jehanne_memset(xmask, 0, IPaddrlen); /* find most specific match */ e = &f->ipifc->conv[f->ipifc->nc]; @@ -1239,7 +1239,7 @@ findlocalip(Fs *f, uint8_t *local, uint8_t *remote) USED(atypel); qlock(f->ipifc); r = v6lookup(f, remote, nil); - version = (memcmp(remote, v4prefix, IPv4off) == 0)? V4: V6; + version = (jehanne_memcmp(remote, v4prefix, IPv4off) == 0)? V4: V6; if(r != nil){ ifc = r->ifc; @@ -1317,7 +1317,7 @@ ipv4local(Ipifc *ifc, uint8_t *addr) for(lifc = ifc->lifc; lifc; lifc = lifc->next){ if(isv4(lifc->local)){ - memmove(addr, lifc->local+IPv4off, IPv4addrlen); + jehanne_memmove(addr, lifc->local+IPv4off, IPv4addrlen); return 1; } } @@ -1505,7 +1505,7 @@ ipifcremmulti(Conv *c, uint8_t *ma, uint8_t *ia) poperror(); } - free(multi); + jehanne_free(multi); } /* @@ -1595,7 +1595,7 @@ adddefroute6(Fs *f, uint8_t *gate, int force) * route entries generated by all other means take precedence * over router announcements. */ - if (r && !force && strcmp(r->tag, "ra") != 0) + if (r && !force && jehanne_strcmp(r->tag, "ra") != 0) return; v6delroute(f, v6Unspecified, v6Unspecified, 1); @@ -1620,19 +1620,19 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc) switch(argc) { case 7: - preflt = atoi(argv[6]); + preflt = jehanne_atoi(argv[6]); /* fall through */ case 6: - validlt = atoi(argv[5]); + validlt = jehanne_atoi(argv[5]); /* fall through */ case 5: - autoflag = atoi(argv[4]); + autoflag = jehanne_atoi(argv[4]); /* fall through */ case 4: - onlink = atoi(argv[3]); + onlink = jehanne_atoi(argv[3]); /* fall through */ case 3: - plen = atoi(argv[2]); + plen = jehanne_atoi(argv[2]); /* fall through */ case 2: break; @@ -1655,8 +1655,8 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc) if(!ifc->medium->pref2addr) return Ebadarg; ifc->medium->pref2addr(prefix, ifc->mac); /* mac → v6 link-local addr */ - sprint(addr, "%I", prefix); - sprint(preflen, "/%d", plen); + jehanne_sprint(addr, "%I", prefix); + jehanne_sprint(preflen, "/%d", plen); params[0] = "add"; params[1] = addr; params[2] = preflen; diff --git a/sys/src/kern/ip/iproute.c b/sys/src/kern/ip/iproute.c index 80bdbd2..3de82d9 100644 --- a/sys/src/kern/ip/iproute.c +++ b/sys/src/kern/ip/iproute.c @@ -51,11 +51,11 @@ allocroute(int type) if(r != nil){ *l = r->mid; } else { - r = malloc(n); + r = jehanne_malloc(n); if(r == nil) panic("out of routing nodes"); } - memset(r, 0, n); + jehanne_memset(r, 0, n); r->type = type; r->ifc = nil; r->ref = 1; @@ -147,9 +147,9 @@ static void copygate(Route *old, Route *new) { if(new->type & Rv4) - memmove(old->v4.gate, new->v4.gate, IPv4addrlen); + jehanne_memmove(old->v4.gate, new->v4.gate, IPv4addrlen); else - memmove(old->v6.gate, new->v6.gate, IPaddrlen); + jehanne_memmove(old->v6.gate, new->v6.gate, IPaddrlen); } /* @@ -305,8 +305,8 @@ v4addroute(Fs *f, char *tag, uint8_t *a, uint8_t *mask, uint8_t *gate, int type) p = allocroute(Rv4 | type); p->v4.address = sa; p->v4.endaddress = ea; - memmove(p->v4.gate, gate, sizeof(p->v4.gate)); - memmove(p->tag, tag, sizeof(p->tag)); + jehanne_memmove(p->v4.gate, gate, sizeof(p->v4.gate)); + jehanne_memmove(p->tag, tag, sizeof(p->tag)); wlock(&routelock); addnode(f, &f->v4root[h], p); @@ -323,7 +323,7 @@ v4addroute(Fs *f, char *tag, uint8_t *a, uint8_t *mask, uint8_t *gate, int type) } #define V6H(a) (((a)[IPllen-1] & 0x07ffffff)>>(32-Lroot-5)) -#define ISDFLT(a, mask, tag) ((ipcmp((a),v6Unspecified)==0) && (ipcmp((mask),v6Unspecified)==0) && (strcmp((tag), "ra")!=0)) +#define ISDFLT(a, mask, tag) ((ipcmp((a),v6Unspecified)==0) && (ipcmp((mask),v6Unspecified)==0) && (jehanne_strcmp((tag), "ra")!=0)) void v6addroute(Fs *f, char *tag, uint8_t *a, uint8_t *mask, uint8_t *gate, int type) @@ -349,10 +349,10 @@ v6addroute(Fs *f, char *tag, uint8_t *a, uint8_t *mask, uint8_t *gate, int type) eh = V6H(ea); for(h = V6H(sa); h <= eh; h++) { p = allocroute(type); - memmove(p->v6.address, sa, IPaddrlen); - memmove(p->v6.endaddress, ea, IPaddrlen); - memmove(p->v6.gate, gate, IPaddrlen); - memmove(p->tag, tag, sizeof(p->tag)); + jehanne_memmove(p->v6.address, sa, IPaddrlen); + jehanne_memmove(p->v6.endaddress, ea, IPaddrlen); + jehanne_memmove(p->v6.gate, gate, IPaddrlen); + jehanne_memmove(p->tag, tag, sizeof(p->tag)); wlock(&routelock); addnode(f, &f->v6root[h], p); @@ -507,7 +507,7 @@ v4lookup(Fs *f, uint8_t *a, Conv *c) if(q && (q->ifc == nil || q->ifcid != q->ifc->ifcid)){ if(q->type & Rifc) { hnputl(gate+IPv4off, q->v4.address); - memmove(gate, v4prefix, IPv4off); + jehanne_memmove(gate, v4prefix, IPv4off); } else v4tov6(gate, q->v4.gate); ifc = findipifc(f, gate, q->type); @@ -535,7 +535,7 @@ v6lookup(Fs *f, uint8_t *a, Conv *c) uint8_t gate[IPaddrlen]; Ipifc *ifc; - if(memcmp(a, v4prefix, IPv4off) == 0){ + if(jehanne_memcmp(a, v4prefix, IPv4off) == 0){ q = v4lookup(f, a+IPv4off, c); if(q != nil) return q; @@ -599,7 +599,7 @@ next: ; void routetype(int type, char *p) { - memset(p, ' ', 4); + jehanne_memset(p, ' ', 4); p[4] = 0; if(type & Rv4) *p++ = '4'; @@ -625,18 +625,18 @@ convroute(Route *r, uint8_t *addr, uint8_t *mask, uint8_t *gate, char *t, int *n int i; if(r->type & Rv4){ - memmove(addr, v4prefix, IPv4off); + jehanne_memmove(addr, v4prefix, IPv4off); hnputl(addr+IPv4off, r->v4.address); - memset(mask, 0xff, IPv4off); + jehanne_memset(mask, 0xff, IPv4off); hnputl(mask+IPv4off, ~(r->v4.endaddress ^ r->v4.address)); - memmove(gate, v4prefix, IPv4off); - memmove(gate+IPv4off, r->v4.gate, IPv4addrlen); + jehanne_memmove(gate, v4prefix, IPv4off); + jehanne_memmove(gate+IPv4off, r->v4.gate, IPv4addrlen); } else { for(i = 0; i < IPllen; i++){ hnputl(addr + 4*i, r->v6.address[i]); hnputl(mask + 4*i, ~(r->v6.endaddress[i] ^ r->v6.address[i])); } - memmove(gate, r->v6.gate, IPaddrlen); + jehanne_memmove(gate, r->v6.gate, IPaddrlen); } routetype(r->type, t); @@ -662,13 +662,13 @@ sprintroute(Route *r, Routewalk *rw) iname = "-"; if(nifc != -1) { iname = ifbuf; - snprint(ifbuf, sizeof ifbuf, "%d", nifc); + jehanne_snprint(ifbuf, sizeof ifbuf, "%d", nifc); } - p = seprint(rw->p, rw->e, rformat, addr, mask, gate, t, r->tag, iname); + p = jehanne_seprint(rw->p, rw->e, rformat, addr, mask, gate, t, r->tag, iname); if(rw->o < 0){ n = p - rw->p; if(n > -rw->o){ - memmove(rw->p, rw->p-rw->o, n+rw->o); + jehanne_memmove(rw->p, rw->p-rw->o, n+rw->o); rw->p = p + rw->o; } rw->o += n; @@ -773,7 +773,7 @@ routeflush(Fs *f, Route *r, char *tag) if(routeflush(f, r->right, tag)) return 1; if((r->type & Rifc) == 0){ - if(tag == nil || strncmp(tag, r->tag, sizeof(r->tag)) == 0){ + if(tag == nil || jehanne_strncmp(tag, r->tag, sizeof(r->tag)) == 0){ delroute(f, r, 0); return 1; } @@ -801,9 +801,9 @@ printroute(Route *r) iname = "-"; if(nifc != -1) { iname = ifbuf; - snprint(ifbuf, sizeof ifbuf, "%d", nifc); + jehanne_snprint(ifbuf, sizeof ifbuf, "%d", nifc); } - print(rformat, addr, mask, gate, t, r->tag, iname); + jehanne_print(rformat, addr, mask, gate, t, r->tag, iname); } long @@ -820,11 +820,11 @@ routewrite(Fs *f, Chan *c, char *p, int n) cb = parsecmd(p, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } - if(strcmp(cb->f[0], "flush") == 0){ + if(jehanne_strcmp(cb->f[0], "flush") == 0){ tag = cb->f[1]; for(h = 0; h < nelem(f->v4root); h++) for(changed = 1; changed;){ @@ -838,17 +838,17 @@ routewrite(Fs *f, Chan *c, char *p, int n) changed = routeflush(f, f->v6root[h], tag); wunlock(&routelock); } - } else if(strcmp(cb->f[0], "remove") == 0){ + } else if(jehanne_strcmp(cb->f[0], "remove") == 0){ if(cb->nf < 3) error(Ebadarg); if (parseip(addr, cb->f[1]) == -1) error(Ebadip); parseipmask(mask, cb->f[2]); - if(memcmp(addr, v4prefix, IPv4off) == 0) + if(jehanne_memcmp(addr, v4prefix, IPv4off) == 0) v4delroute(f, addr+IPv4off, mask+IPv4off, 1); else v6delroute(f, addr, mask, 1); - } else if(strcmp(cb->f[0], "add") == 0){ + } else if(jehanne_strcmp(cb->f[0], "add") == 0){ if(cb->nf < 4) error(Ebadarg); if(parseip(addr, cb->f[1]) == -1 || @@ -860,33 +860,33 @@ routewrite(Fs *f, Chan *c, char *p, int n) a = c->aux; tag = a->tag; } - if(memcmp(addr, v4prefix, IPv4off) == 0) + if(jehanne_memcmp(addr, v4prefix, IPv4off) == 0) v4addroute(f, tag, addr+IPv4off, mask+IPv4off, gate+IPv4off, 0); else v6addroute(f, tag, addr, mask, gate, 0); - } else if(strcmp(cb->f[0], "tag") == 0) { + } else if(jehanne_strcmp(cb->f[0], "tag") == 0) { if(cb->nf < 2) error(Ebadarg); a = c->aux; na = newipaux(a->owner, cb->f[1]); c->aux = na; - free(a); - } else if(strcmp(cb->f[0], "route") == 0) { + jehanne_free(a); + } else if(jehanne_strcmp(cb->f[0], "route") == 0) { if(cb->nf < 2) error(Ebadarg); if (parseip(addr, cb->f[1]) == -1) error(Ebadip); q = iproute(f, addr); - print("%I: ", addr); + jehanne_print("%I: ", addr); if(q == nil) - print("no route\n"); + jehanne_print("no route\n"); else printroute(q); } poperror(); - free(cb); + jehanne_free(cb); return n; } diff --git a/sys/src/kern/ip/ipv6.c b/sys/src/kern/ip/ipv6.c index b99eb2f..389ee05 100644 --- a/sys/src/kern/ip/ipv6.c +++ b/sys/src/kern/ip/ipv6.c @@ -76,7 +76,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) r = v6lookup(f, eh->dst, c); if(r == nil){ -// print("no route for %I, src %I free\n", eh->dst, eh->src); +// jehanne_print("no route for %I, src %I free\n", eh->dst, eh->src); ip->stats[OutNoRoutes]++; netlog(f, Logip, "no interface %I\n", eh->dst); rv = -1; @@ -179,12 +179,12 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) } hnputs(eh->ploadlen, seglen+IP6FHDR); - memmove(nb->wp, eh, uflen); + jehanne_memmove(nb->wp, eh, uflen); nb->wp += uflen; hnputs(fraghdr.offsetRM, fragoff); /* last 3 bits must be 0 */ fraghdr.offsetRM[1] |= morefrags; - memmove(nb->wp, &fraghdr, IP6FHDR); + jehanne_memmove(nb->wp, &fraghdr, IP6FHDR); nb->wp += IP6FHDR; /* Copy data */ @@ -200,7 +200,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) blklen = chunk; if(BLEN(xp) < chunk) blklen = BLEN(xp); - memmove(nb->wp, xp->rp, blklen); + jehanne_memmove(nb->wp, xp->rp, blklen); nb->wp += blklen; xp->rp += blklen; @@ -254,12 +254,12 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp) h = (Ip6hdr *)bp->rp; - memmove(&v6dst[0], &h->dst[0], IPaddrlen); + jehanne_memmove(&v6dst[0], &h->dst[0], IPaddrlen); notforme = ipforme(f, v6dst) == 0; tentative = iptentative(f, v6dst); if(tentative && h->proto != ICMPv6) { - print("tentative addr, drop\n"); + jehanne_print("tentative addr, drop\n"); freeblist(bp); return; } @@ -349,7 +349,7 @@ ipfragfree6(IP *ip, Fragment6 *frag) if(frag->blist) freeblist(frag->blist); - memset(frag->src, 0, IPaddrlen); + jehanne_memset(frag->src, 0, IPaddrlen); frag->id = 0; frag->blist = nil; @@ -461,8 +461,8 @@ ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih) Fragment6 *f, *fnext; fraghdr = (Fraghdr6 *)(bp->rp + uflen); - memmove(src, ih->src, IPaddrlen); - memmove(dst, ih->dst, IPaddrlen); + jehanne_memmove(src, ih->src, IPaddrlen); + jehanne_memmove(dst, ih->dst, IPaddrlen); id = nhgetl(fraghdr->id); offset = nhgets(fraghdr->offsetRM) & ~7; @@ -515,8 +515,8 @@ ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih) if(f == nil) { f = ipfragallo6(ip); f->id = id; - memmove(f->src, src, IPaddrlen); - memmove(f->dst, dst, IPaddrlen); + jehanne_memmove(f->src, src, IPaddrlen); + jehanne_memmove(f->dst, dst, IPaddrlen); f->blist = bp; @@ -568,7 +568,7 @@ ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih) BKFG(*l)->flen -= ovlap; BKFG(*l)->foff += ovlap; /* move up ih hdrs */ - memmove((*l)->rp + ovlap, (*l)->rp, uflen); + jehanne_memmove((*l)->rp + ovlap, (*l)->rp, uflen); (*l)->rp += ovlap; break; } @@ -590,7 +590,7 @@ ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih) bl = f->blist; /* get rid of frag header in first fragment */ - memmove(bl->rp + IP6FHDR, bl->rp, uflen); + jehanne_memmove(bl->rp + IP6FHDR, bl->rp, uflen); bl->rp += IP6FHDR; len = nhgets(((Ip6hdr*)bl->rp)->ploadlen) - IP6FHDR; bl->wp = bl->rp + len + IP6HDR; diff --git a/sys/src/kern/ip/ipv6.h b/sys/src/kern/ip/ipv6.h index 114bdd8..e1ef718 100644 --- a/sys/src/kern/ip/ipv6.h +++ b/sys/src/kern/ip/ipv6.h @@ -18,7 +18,7 @@ #define islinklocal(addr) ((addr)[0] == 0xfe && ((addr)[1] & 0xc0) == 0x80) #define optexsts(np) (nhgets((np)->ploadlen) > 24) -#define issmcast(addr) (memcmp((addr), v6solicitednode, 13) == 0) +#define issmcast(addr) (jehanne_memcmp((addr), v6solicitednode, 13) == 0) #ifndef MIN #define MIN(a, b) ((a) <= (b)? (a): (b)) diff --git a/sys/src/kern/ip/loopbackmedium.c b/sys/src/kern/ip/loopbackmedium.c index d37bd18..3e85bed 100644 --- a/sys/src/kern/ip/loopbackmedium.c +++ b/sys/src/kern/ip/loopbackmedium.c @@ -51,7 +51,7 @@ loopbackunbind(Ipifc *ifc) /* clean up */ qfree(lb->q); - free(lb); + jehanne_free(lb); } static void diff --git a/sys/src/kern/ip/netdevmedium.c b/sys/src/kern/ip/netdevmedium.c index ed8c8e0..8b9efd1 100644 --- a/sys/src/kern/ip/netdevmedium.c +++ b/sys/src/kern/ip/netdevmedium.c @@ -75,7 +75,7 @@ netdevunbind(Ipifc *ifc) if(er->mchan != nil) cclose(er->mchan); - free(er); + jehanne_free(er); } /* diff --git a/sys/src/kern/ip/netlog.c b/sys/src/kern/ip/netlog.c index 4f7f106..769ac30 100644 --- a/sys/src/kern/ip/netlog.c +++ b/sys/src/kern/ip/netlog.c @@ -86,7 +86,7 @@ netlogopen(Fs *f) } if(f->alog->opens == 0){ if(f->alog->buf == nil){ - f->alog->buf = malloc(Nlog); + f->alog->buf = jehanne_malloc(Nlog); if(f->alog->buf == nil) error(Enomem); } @@ -104,7 +104,7 @@ netlogclose(Fs *f) lock(&f->alog->l); f->alog->opens--; if(f->alog->opens == 0){ - free(f->alog->buf); + jehanne_free(f->alog->buf); f->alog->buf = nil; } unlock(&f->alog->l); @@ -147,8 +147,8 @@ netlogread(Fs *f, void *a, uint32_t _1, long n) i = n-d; p = a; - memmove(p, rptr, i); - memmove(p+i, f->alog->buf, d); + jehanne_memmove(p, rptr, i); + jehanne_memmove(p+i, f->alog->buf, d); break; } else @@ -173,7 +173,7 @@ netlogctl(Fs *f, char* s, int n) cb = parsecmd(s, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } @@ -197,7 +197,7 @@ netlogctl(Fs *f, char* s, int n) else f->alog->iponlyset = 1; poperror(); - free(cb); + jehanne_free(cb); return; default: @@ -207,7 +207,7 @@ netlogctl(Fs *f, char* s, int n) for(i = 1; i < cb->nf; i++){ for(fp = flags; fp->name; fp++) - if(strcmp(fp->name, cb->f[i]) == 0) + if(jehanne_strcmp(fp->name, cb->f[i]) == 0) break; if(fp->name == nil) continue; @@ -218,7 +218,7 @@ netlogctl(Fs *f, char* s, int n) } poperror(); - free(cb); + jehanne_free(cb); } void @@ -235,7 +235,7 @@ netlog(Fs *f, int mask, char *fmt, ...) return; va_start(arg, fmt); - n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); lock(&f->alog->l); diff --git a/sys/src/kern/ip/tcp.c b/sys/src/kern/ip/tcp.c index 34a52e1..df6f762 100644 --- a/sys/src/kern/ip/tcp.c +++ b/sys/src/kern/ip/tcp.c @@ -406,7 +406,7 @@ tcpsetstate(Conv *s, uint8_t newstate) tpriv->stats[CurrEstab]++; /** - print( "%d/%d %s->%s CurrEstab=%d\n", s->lport, s->rport, + jehanne_print( "%d/%d %s->%s CurrEstab=%d\n", s->lport, s->rport, tcpstates[oldstate], tcpstates[newstate], tpriv->tstats.tcpCurrEstab ); **/ @@ -453,7 +453,7 @@ tcpstate(Conv *c, char *state, int n) s = (Tcpctl*)(c->ptcl); - return snprint(state, n, + return jehanne_snprint(state, n, "%s qin %d qout %d srtt %d mdev %d cwin %lud swin %lud>>%d rwin %lud>>%d timer.start %d timer.count %d rerecv %d katimer.start %d katimer.count %d\n", tcpstates[s->state], c->rq ? qlen(c->rq) : 0, @@ -745,7 +745,7 @@ localclose(Conv *s, char *reason) /* called with tcb locked */ for(rp = tcb->reseq; rp != nil; rp = rp1) { rp1 = rp->next; freeblist(rp->bp); - free(rp); + jehanne_free(rp); } tcb->reseq = nil; @@ -807,7 +807,7 @@ inittcpctl(Conv *s, int mode) tcb = (Tcpctl*)s->ptcl; - memset(tcb, 0, sizeof(Tcpctl)); + jehanne_memset(tcb, 0, sizeof(Tcpctl)); tcb->ssthresh = 65535; tcb->srtt = tcp_irtt<ipversion){ case V4: h4 = &tcb->protohdr.tcp4hdr; - memset(h4, 0, sizeof(*h4)); + jehanne_memset(h4, 0, sizeof(*h4)); h4->proto = IP_TCPPROTO; hnputs(h4->tcpsport, s->lport); hnputs(h4->tcpdport, s->rport); @@ -844,7 +844,7 @@ inittcpctl(Conv *s, int mode) break; case V6: h6 = &tcb->protohdr.tcp6hdr; - memset(h6, 0, sizeof(*h6)); + jehanne_memset(h6, 0, sizeof(*h6)); h6->proto = IP_TCPPROTO; hnputs(h6->tcpsport, s->lport); hnputs(h6->tcpdport, s->rport); @@ -884,7 +884,7 @@ tcpstart(Conv *s, int mode) if(tpriv->ackprocstarted == 0){ qlock(&tpriv->apl); if(tpriv->ackprocstarted == 0){ - sprint(kpname, "#I%dtcpack", s->p->f->dev); + jehanne_sprint(kpname, "#I%dtcpack", s->p->f->dev); kproc(kpname, tcpackproc, s->p); tpriv->ackprocstarted = 1; } @@ -919,19 +919,19 @@ tcpflag(uint16_t flag) { static char buf[128]; - sprint(buf, "%d", flag>>10); /* Head len */ + jehanne_sprint(buf, "%d", flag>>10); /* Head len */ if(flag & URG) - strcat(buf, " URG"); + jehanne_strcat(buf, " URG"); if(flag & ACK) - strcat(buf, " ACK"); + jehanne_strcat(buf, " ACK"); if(flag & PSH) - strcat(buf, " PSH"); + jehanne_strcat(buf, " PSH"); if(flag & RST) - strcat(buf, " RST"); + jehanne_strcat(buf, " RST"); if(flag & SYN) - strcat(buf, " SYN"); + jehanne_strcat(buf, " SYN"); if(flag & FIN) - strcat(buf, " FIN"); + jehanne_strcat(buf, " FIN"); return buf; } @@ -974,7 +974,7 @@ htontcp6(Tcp *tcph, Block *data, Tcp6hdr *ph, Tcpctl *tcb) /* copy in pseudo ip header plus port numbers */ h = (Tcp6hdr *)(data->rp); - memmove(h, ph, TCP6_TCBPHDRSZ); + jehanne_memmove(h, ph, TCP6_TCBPHDRSZ); /* compose pseudo tcp header, do cksum calculation */ hnputl(h->vcf, hdrlen + dlen); @@ -994,7 +994,7 @@ htontcp6(Tcp *tcph, Block *data, Tcp6hdr *ph, Tcpctl *tcb) *opt++ = MSSOPT; *opt++ = MSS_LENGTH; hnputs(opt, tcph->mss); -// print("our outgoing mss %d\n", tcph->mss); +// jehanne_print("our outgoing mss %d\n", tcph->mss); opt += 2; } if(tcph->ws != 0){ @@ -1014,7 +1014,7 @@ htontcp6(Tcp *tcph, Block *data, Tcp6hdr *ph, Tcpctl *tcb) } /* move from pseudo header back to normal ip header */ - memset(h->vcf, 0, 4); + jehanne_memset(h->vcf, 0, 4); h->vcf[0] = IP_VER6; hnputs(h->ploadlen, hdrlen+dlen); h->proto = ph->proto; @@ -1059,7 +1059,7 @@ htontcp4(Tcp *tcph, Block *data, Tcp4hdr *ph, Tcpctl *tcb) /* copy in pseudo ip header plus port numbers */ h = (Tcp4hdr *)(data->rp); - memmove(h, ph, TCP4_TCBPHDRSZ); + jehanne_memmove(h, ph, TCP4_TCBPHDRSZ); /* copy in variable bits */ hnputs(h->tcplen, hdrlen + dlen); @@ -1209,7 +1209,7 @@ ntohtcp4(Tcp *tcph, Block **bpp) case MSSOPT: if(optlen == MSS_LENGTH) { tcph->mss = nhgets(optr+2); -// print("new incoming mss %d\n", tcph->mss); +// jehanne_print("new incoming mss %d\n", tcph->mss); } break; case WSOPT: @@ -1267,7 +1267,7 @@ sndrst(Proto *tcp, uint8_t *source, uint8_t *dest, uint16_t length, Tcp *seg, ui /* make pseudo header */ switch(version) { case V4: - memset(&ph4, 0, sizeof(ph4)); + jehanne_memset(&ph4, 0, sizeof(ph4)); ph4.vihl = IP_VER4; v6tov4(ph4.tcpsrc, dest); v6tov4(ph4.tcpdst, source); @@ -1277,7 +1277,7 @@ sndrst(Proto *tcp, uint8_t *source, uint8_t *dest, uint16_t length, Tcp *seg, ui hnputs(ph4.tcpdport, seg->source); break; case V6: - memset(&ph6, 0, sizeof(ph6)); + jehanne_memset(&ph6, 0, sizeof(ph6)); ph6.vcf[0] = IP_VER6; ipmove(ph6.tcpsrc, dest); ipmove(ph6.tcpdst, source); @@ -1347,7 +1347,7 @@ tcphangup(Conv *s) return up->errstr; if(ipcmp(s->raddr, IPnoaddr) != 0) { if(!waserror()){ - memset(&seg, 0, sizeof seg); + jehanne_memset(&seg, 0, sizeof seg); seg.flags = RST | ACK; seg.ack = tcb->rcv.nxt; tcb->rcv.una = 0; @@ -1393,7 +1393,7 @@ sndsynack(Proto *tcp, Limbo *lp) /* make pseudo header */ switch(lp->version) { case V4: - memset(&ph4, 0, sizeof(ph4)); + jehanne_memset(&ph4, 0, sizeof(ph4)); ph4.vihl = IP_VER4; v6tov4(ph4.tcpsrc, lp->laddr); v6tov4(ph4.tcpdst, lp->raddr); @@ -1403,7 +1403,7 @@ sndsynack(Proto *tcp, Limbo *lp) hnputs(ph4.tcpdport, lp->rport); break; case V6: - memset(&ph6, 0, sizeof(ph6)); + jehanne_memset(&ph6, 0, sizeof(ph6)); ph6.vcf[0] = IP_VER6; ipmove(ph6.tcpsrc, lp->laddr); ipmove(ph6.tcpdst, lp->raddr); @@ -1416,7 +1416,7 @@ sndsynack(Proto *tcp, Limbo *lp) panic("sndrst: version %d", lp->version); } - memset(&seg, 0, sizeof seg); + jehanne_memset(&seg, 0, sizeof seg); seg.seq = lp->iss; seg.ack = lp->irs+1; seg.flags = SYN|ACK; @@ -1492,7 +1492,7 @@ limbo(Conv *s, uint8_t *source, uint8_t *dest, Tcp *seg, int version) tpriv->lht[h] = lp->next; lp->next = nil; } else { - lp = malloc(sizeof(*lp)); + lp = jehanne_malloc(sizeof(*lp)); if(lp == nil) return; tpriv->nlimbo++; @@ -1512,7 +1512,7 @@ limbo(Conv *s, uint8_t *source, uint8_t *dest, Tcp *seg, int version) if(sndsynack(s->p, lp) < 0){ *l = lp->next; tpriv->nlimbo--; - free(lp); + jehanne_free(lp); } } @@ -1545,7 +1545,7 @@ limborexmit(Proto *tcp) if(++(lp->rexmits) > 5){ tpriv->nlimbo--; *l = lp->next; - free(lp); + jehanne_free(lp); continue; } @@ -1556,7 +1556,7 @@ limborexmit(Proto *tcp) if(sndsynack(tcp, lp) < 0){ tpriv->nlimbo--; *l = lp->next; - free(lp); + jehanne_free(lp); continue; } @@ -1595,7 +1595,7 @@ limborst(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version) if(segp->seq == lp->irs+1){ tpriv->nlimbo--; *l = lp->next; - free(lp); + jehanne_free(lp); } break; } @@ -1658,7 +1658,7 @@ tcpincoming(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version) if(new == nil) return nil; - memmove(new->ptcl, s->ptcl, sizeof(Tcpctl)); + jehanne_memmove(new->ptcl, s->ptcl, sizeof(Tcpctl)); tcb = (Tcpctl*)new->ptcl; tcb->flags &= ~CLONE; tcb->timer.arg = new; @@ -1702,13 +1702,13 @@ tcpincoming(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version) tcb->sndsyntime = lp->lastsend+lp->rexmits*SYNACK_RXTIMER; tcpsynackrtt(new); - free(lp); + jehanne_free(lp); /* set up proto header */ switch(version){ case V4: h4 = &tcb->protohdr.tcp4hdr; - memset(h4, 0, sizeof(*h4)); + jehanne_memset(h4, 0, sizeof(*h4)); h4->proto = IP_TCPPROTO; hnputs(h4->tcpsport, new->lport); hnputs(h4->tcpdport, new->rport); @@ -1717,7 +1717,7 @@ tcpincoming(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version) break; case V6: h6 = &tcb->protohdr.tcp6hdr; - memset(h6, 0, sizeof(*h6)); + jehanne_memset(h6, 0, sizeof(*h6)); h6->proto = IP_TCPPROTO; hnputs(h6->tcpsport, new->lport); hnputs(h6->tcpdport, new->rport); @@ -1916,7 +1916,7 @@ update(Conv *s, Tcp *seg) if(tcb->srtt <= 0) tcb->srtt = 1; - delta = abs(delta) - (tcb->mdev>>LOGDGAIN); + delta = jehanne_abs(delta) - (tcb->mdev>>LOGDGAIN); tcb->mdev += delta; if(tcb->mdev <= 0) tcb->mdev = 1; @@ -1968,7 +1968,7 @@ tcpiput(Proto *tcp, Ipifc* _1, Block *bp) h4 = (Tcp4hdr*)(bp->rp); h6 = (Tcp6hdr*)(bp->rp); - memset(&seg, 0, sizeof seg); + jehanne_memset(&seg, 0, sizeof seg); if((h4->vihl&0xF0)==IP_VER4) { version = V4; @@ -2169,7 +2169,7 @@ reset: if(tcb->state != Syn_received && (seg.flags & RST) == 0){ if(tcpporthogdefense && seq_within(seg.ack, tcb->snd.una-(1<<31), tcb->snd.una-(1<<29))){ - print("stateless hog %I.%d->%I.%d f %ux %lux - %lux - %lux\n", + jehanne_print("stateless hog %I.%d->%I.%d f %ux %lux - %lux - %lux\n", source, seg.source, dest, seg.dest, seg.flags, tcb->snd.una-(1<<31), seg.ack, tcb->snd.una-(1<<29)); localclose(s, "stateless hog"); @@ -2213,7 +2213,7 @@ reset: if(length != 0 || (seg.flags & (SYN|FIN))) { update(s, &seg); if(addreseq(tcb, tpriv, &seg, bp, length) < 0) - print("reseq %I.%d -> %I.%d\n", s->raddr, s->rport, s->laddr, s->lport); + jehanne_print("reseq %I.%d -> %I.%d\n", s->raddr, s->rport, s->laddr, s->lport); tcb->flags |= FORCE; goto output; } @@ -2227,7 +2227,7 @@ reset: if(tcb->state == Established) { tpriv->stats[EstabResets]++; if(tcb->rcv.nxt != seg.seq) - print("out of order RST rcvd: %I.%d -> %I.%d, rcv.nxt %lux seq %lux\n", s->raddr, s->rport, s->laddr, s->lport, tcb->rcv.nxt, seg.seq); + jehanne_print("out of order RST rcvd: %I.%d -> %I.%d, rcv.nxt %lux seq %lux\n", s->raddr, s->rport, s->laddr, s->lport, tcb->rcv.nxt, seg.seq); } localclose(s, Econrefused); goto raise; @@ -2454,7 +2454,7 @@ tcpoutput(Conv *s) f = s->p->f; tpriv = s->p->priv; version = s->ipversion; - memset(&seg, 0, sizeof seg); + jehanne_memset(&seg, 0, sizeof seg); for(msgs = 0; msgs < 100; msgs++) { tcb = (Tcpctl*)s->ptcl; @@ -2667,7 +2667,7 @@ tcpsendka(Conv *s) tcb = (Tcpctl*)s->ptcl; dbp = nil; - memset(&seg, 0, sizeof seg); + jehanne_memset(&seg, 0, sizeof seg); seg.urg = 0; seg.source = s->lport; seg.dest = s->rport; @@ -2763,7 +2763,7 @@ tcpstartka(Conv *s, char **f, int n) if(tcb->state != Established) return "connection must be in Establised state"; if(n > 1){ - x = atoi(f[1]); + x = jehanne_atoi(f[1]); if(x >= MSPTICK) tcb->katimer.start = x/MSPTICK; } @@ -2782,7 +2782,7 @@ tcpsetchecksum(Conv *s, char **f, int _1) Tcpctl *tcb; tcb = (Tcpctl*)s->ptcl; - tcb->nochecksum = !atoi(f[1]); + tcb->nochecksum = !jehanne_atoi(f[1]); return nil; } @@ -2895,7 +2895,7 @@ addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, uint16_t length) Reseq *rp, *rp1; int i, rqlen, qmax; - rp = malloc(sizeof(Reseq)); + rp = jehanne_malloc(sizeof(Reseq)); if(rp == nil){ freeblist(bp); /* bp always consumed by add_reseq */ return 0; @@ -2929,13 +2929,13 @@ addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, uint16_t length) } qmax = QMAX<rcv.scale; if(rqlen > qmax){ - print("resequence queue > window: %d > %d\n", rqlen, qmax); + jehanne_print("resequence queue > window: %d > %d\n", rqlen, qmax); i = 0; for(rp1 = tcb->reseq; rp1 != nil; rp1 = rp1->next){ - print("%#lux %#lux %#ux\n", rp1->seg.seq, + jehanne_print("%#lux %#lux %#ux\n", rp1->seg.seq, rp1->seg.ack, rp1->seg.flags); if(i++ > 10){ - print("...\n"); + jehanne_print("...\n"); break; } } @@ -2947,7 +2947,7 @@ addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, uint16_t length) for(rp = tcb->reseq; rp != nil; rp = rp1){ rp1 = rp->next; freeblist(rp->bp); - free(rp); + jehanne_free(rp); } tcb->reseq = nil; @@ -2971,7 +2971,7 @@ getreseq(Tcpctl *tcb, Tcp *seg, Block **bp, uint16_t *length) *bp = rp->bp; *length = rp->length; - free(rp); + jehanne_free(rp); } static int @@ -3101,9 +3101,9 @@ tcpadvise(Proto *tcp, Block *bp, char *msg) static char* tcpporthogdefensectl(char *val) { - if(strcmp(val, "on") == 0) + if(jehanne_strcmp(val, "on") == 0) tcpporthogdefense = 1; - else if(strcmp(val, "off") == 0) + else if(jehanne_strcmp(val, "off") == 0) tcpporthogdefense = 0; else return "unknown value for tcpporthogdefense"; @@ -3114,13 +3114,13 @@ tcpporthogdefensectl(char *val) static char* tcpctl(Conv* c, char** f, int n) { - if(n == 1 && strcmp(f[0], "hangup") == 0) + if(n == 1 && jehanne_strcmp(f[0], "hangup") == 0) return tcphangup(c); - if(n >= 1 && strcmp(f[0], "keepalive") == 0) + if(n >= 1 && jehanne_strcmp(f[0], "keepalive") == 0) return tcpstartka(c, f, n); - if(n >= 1 && strcmp(f[0], "checksum") == 0) + if(n >= 1 && jehanne_strcmp(f[0], "checksum") == 0) return tcpsetchecksum(c, f, n); - if(n >= 1 && strcmp(f[0], "tcpporthogdefense") == 0) + if(n >= 1 && jehanne_strcmp(f[0], "tcpporthogdefense") == 0) return tcpporthogdefensectl(f[1]); return "unknown control request"; } @@ -3136,7 +3136,7 @@ tcpstats(Proto *tcp, char *buf, int len) p = buf; e = p+len; for(i = 0; i < Nstats; i++) - p = seprint(p, e, "%s: %llud\n", statnames[i], priv->stats[i]); + p = jehanne_seprint(p, e, "%s: %llud\n", statnames[i], priv->stats[i]); return p - buf; } diff --git a/sys/src/kern/ip/udp.c b/sys/src/kern/ip/udp.c index b1cdb7f..aa20274 100644 --- a/sys/src/kern/ip/udp.c +++ b/sys/src/kern/ip/udp.c @@ -9,7 +9,7 @@ #include "ipv6.h" -#define DPRINT if(0)print +#define DPRINT if(0)jehanne_print enum { @@ -124,7 +124,7 @@ udpconnect(Conv *c, char **argv, int argc) static int udpstate(Conv *c, char *state, int n) { - return snprint(state, n, "%s qin %d qout %d\n", + return jehanne_snprint(state, n, "%s qin %d qout %d\n", c->inuse ? "Open" : "Closed", c->rq ? qlen(c->rq) : 0, c->wq ? qlen(c->wq) : 0 @@ -217,15 +217,15 @@ udpkick(void *x, Block *bp) rport = nhgets(bp->rp); bp->rp += 2+2; /* Ignore local port */ - if(memcmp(laddr, v4prefix, IPv4off) == 0 + if(jehanne_memcmp(laddr, v4prefix, IPv4off) == 0 || ipcmp(laddr, IPnoaddr) == 0) version = 4; else version = 6; } else { rport = 0; - if( (memcmp(c->raddr, v4prefix, IPv4off) == 0 && - memcmp(c->laddr, v4prefix, IPv4off) == 0) + if( (jehanne_memcmp(c->raddr, v4prefix, IPv4off) == 0 && + jehanne_memcmp(c->laddr, v4prefix, IPv4off) == 0) || ipcmp(c->raddr, IPnoaddr) == 0) version = 4; else @@ -281,7 +281,7 @@ udpkick(void *x, Block *bp) * first then reset it to the normal ip header */ uh6 = (Udp6hdr *)(bp->rp); - memset(uh6, 0, 8); + jehanne_memset(uh6, 0, 8); ptcllen = dlen + UDP_UDPHDR_SZ; hnputl(uh6->viclfl, ptcllen); uh6->hoplimit = IP_UDPPROTO; @@ -304,7 +304,7 @@ udpkick(void *x, Block *bp) uh6->udpcksum[1] = 0; hnputs(uh6->udpcksum, ptclcsum(bp, UDP6_PHDR_OFF, dlen+UDP_UDPHDR_SZ+UDP6_PHDR_SZ)); - memset(uh6, 0, 8); + jehanne_memset(uh6, 0, 8); uh6->viclfl[0] = IP_VER6; hnputs(uh6->len, ptcllen); uh6->nextheader = IP_UDPPROTO; @@ -377,7 +377,7 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp) ipmove(laddr, uh6->udpdst); lport = nhgets(uh6->udpdport); rport = nhgets(uh6->udpsport); - memset(uh6, 0, 8); + jehanne_memset(uh6, 0, 8); hnputl(uh6->viclfl, len); uh6->hoplimit = IP_UDPPROTO; if(ptclcsum(bp, UDP6_PHDR_OFF, len+UDP6_PHDR_SZ)) { @@ -514,7 +514,7 @@ udpctl(Conv *c, char **f, int n) ucb = (Udpcb*)c->ptcl; if(n == 1){ - if(strcmp(f[0], "headers") == 0){ + if(jehanne_strcmp(f[0], "headers") == 0){ ucb->headers = 7; /* new headers format */ return nil; } @@ -583,7 +583,7 @@ udpstats(Proto *udp, char *buf, int len) Udppriv *upriv; upriv = udp->priv; - return snprint(buf, len, "InDatagrams: %llud\nNoPorts: %llud\n" + return jehanne_snprint(buf, len, "InDatagrams: %llud\nNoPorts: %llud\n" "InErrors: %llud\nOutDatagrams: %llud\n", upriv->ustats.udpInDatagrams, upriv->ustats.udpNoPorts, diff --git a/sys/src/kern/port/allocb.c b/sys/src/kern/port/allocb.c index 1a39296..41dc79a 100644 --- a/sys/src/kern/port/allocb.c +++ b/sys/src/kern/port/allocb.c @@ -28,7 +28,7 @@ _allocb(int size, int align) if(align <= 0) align = BLOCKALIGN; n = align + ROUNDUP(size+Hdrspc, align) + sizeof(Block); - if((p = malloc(n)) == nil) + if((p = jehanne_malloc(n)) == nil) return nil; b = (Block*)(p + n - sizeof(Block)); /* block at end of allocated space */ @@ -66,7 +66,7 @@ allocb(int size) mallocsummary(); panic("allocb: no memory for %d bytes\n", size); } - setmalloctag(b->base, getcallerpc()); + jehanne_setmalloctag(b->base, getcallerpc()); return b; } @@ -86,7 +86,7 @@ allocbalign(int size, int align) mallocsummary(); panic("allocbalign: no memory for %d bytes\n", size); } - setmalloctag(b->base, getcallerpc()); + jehanne_setmalloctag(b->base, getcallerpc()); return b; } @@ -127,7 +127,7 @@ iallocb(int size) return nil; } b->flag = BINTR; - setmalloctag(b->base, getcallerpc()); + jehanne_setmalloctag(b->base, getcallerpc()); ilock(&ialloc); ialloc.bytes += b->lim - b->base; @@ -168,7 +168,7 @@ freeb(Block *b) b->lim = dead; b->base = dead; - free(p); + jehanne_free(p); } void @@ -180,9 +180,9 @@ checkb(Block *b, char *msg) panic("checkb b %s %#p", msg, b); if(b->base == dead || b->lim == dead || b->next == dead || b->rp == dead || b->wp == dead){ - print("checkb: base %#p lim %#p next %#p\n", + jehanne_print("checkb: base %#p lim %#p next %#p\n", b->base, b->lim, b->next); - print("checkb: rp %#p wp %#p\n", b->rp, b->wp); + jehanne_print("checkb: rp %#p wp %#p\n", b->rp, b->wp); panic("checkb dead: %s\n", msg); } @@ -201,5 +201,5 @@ checkb(Block *b, char *msg) void iallocsummary(void) { - print("ialloc %lud/%lud\n", ialloc.bytes, ialloc.limit); + jehanne_print("ialloc %lud/%lud\n", ialloc.bytes, ialloc.limit); } diff --git a/sys/src/kern/port/awake.c b/sys/src/kern/port/awake.c index bd5a89f..86c5b27 100644 --- a/sys/src/kern/port/awake.c +++ b/sys/src/kern/port/awake.c @@ -143,7 +143,7 @@ awakekproc(void* v) } } tail = toAwake->next; - free(toAwake); + jehanne_free(toAwake); toAwake = tail; } @@ -193,7 +193,7 @@ clearnext: w = freelist; while(w != nil) { freelist = w->next; - free(w); + jehanne_free(w); w = freelist; } } @@ -221,7 +221,7 @@ wakeupafter(int64_t ms) int64_t when; when = ms2tk(ms) + sys->ticks + 2; /* +2 against round errors and cpu's clocks misalignment */ - new = mallocz(sizeof(PendingWakeup), 1); + new = jehanne_mallocz(sizeof(PendingWakeup), 1); if(new == nil) return 0; new->p = up; @@ -271,7 +271,7 @@ forgivewakeup(int64_t time) --up->wakeups; qunlock(&l); - free(w); + jehanne_free(w); return -time; } diff --git a/sys/src/kern/port/bud.c b/sys/src/kern/port/bud.c index 168ac4b..624789c 100644 --- a/sys/src/kern/port/bud.c +++ b/sys/src/kern/port/bud.c @@ -122,7 +122,7 @@ bpoolcreate(uint32_t mink, uint32_t maxk, uintmem base, uintmem top, void* (*all pool->kofb = alloc((pool->maxb+1)*sizeof(*pool->kofb), 1); if(pool->kofb == nil) panic("physinit: can't allocate %ud kofb", pool->maxb+1); - print("pool %#p space base %#P top=%#P maxb=%#ux (%d)\n", pool, base, top, pool->maxb, pool->maxb); + jehanne_print("pool %#p space base %#P top=%#P maxb=%#ux (%d)\n", pool, base, top, pool->maxb, pool->maxb); return pool; } @@ -264,7 +264,7 @@ bpoolinitfree(Bpool *pool, uintmem base, uintmem lim) lim -= pool->base; lim &= ~(pool->minbsize-1); if(BI(lim) > pool->maxb){ - print("physinitfree: address space too large"); + jehanne_print("physinitfree: address space too large"); lim = IB(pool->maxb); } @@ -283,7 +283,7 @@ bpoolinitfree(Bpool *pool, uintmem base, uintmem lim) if(size < m) break; if(base & (m-1)){ - print(" ** error: %#P %#P\n", base, m); + jehanne_print(" ** error: %#P %#P\n", base, m); return; } ibpoolfree(pool, base, m); @@ -296,7 +296,7 @@ bpoolinitfree(Bpool *pool, uintmem base, uintmem lim) m = (uintmem)1<maxk; while(size >= m){ if(base & (m-1)){ - print(" ** error: %#P %#P\n", base, m); + jehanne_print(" ** error: %#P %#P\n", base, m); return; } ibpoolfree(pool, base, m); @@ -309,7 +309,7 @@ bpoolinitfree(Bpool *pool, uintmem base, uintmem lim) if(size & m){ DBG("\t%#P %#P\n", base, m); if(base & (m-1)){ - print(" ** error: %#P %#P\n", base, m); + jehanne_print(" ** error: %#P %#P\n", base, m); return; } ibpoolfree(pool, base, m); @@ -329,7 +329,7 @@ seprintbpoolstats(Bpool *pool, char *s, char *e) for(i = 0; i < nelem(pool->blist); i++){ b = &pool->blist[i]; if(b->avail != 0) - s = seprint(s, e, "%ud %ulldK blocks avail\n", + s = jehanne_seprint(s, e, "%ud %ulldK blocks avail\n", b->avail, (1ull<lk); @@ -347,14 +347,14 @@ bpooldump(Bpool *pool) for(i=0; iblist); i++){ b = pool->blist[i].h.forw; if(b != &pool->blist[i].h){ - print("%d ", i); + jehanne_print("%d ", i); for(; b != &pool->blist[i].h; b = b->forw){ bi = b-pool->blocks; a = IB(bi); k = pool->kofb[bi]; - print(" [%#llux %d %#ux b=%#llux]", a, k, 1<cache); + jehanne_free(e->cache); e->cache = nil; lock(&ecache.l); e->next = ecache.head; @@ -78,7 +78,7 @@ extentalloc(void) lock(&ecache.l); if(ecache.head == nil){ - e = malloc(NEXTENT*sizeof(Extent)); + e = jehanne_malloc(NEXTENT*sizeof(Extent)); if(e == nil){ unlock(&ecache.l); return nil; @@ -94,7 +94,7 @@ extentalloc(void) e = ecache.head; ecache.head = e->next; - memset(e, 0, sizeof(Extent)); + jehanne_memset(e, 0, sizeof(Extent)); ecache.free--; unlock(&ecache.l); @@ -107,7 +107,7 @@ cinit(void) int i; Mntcache *mc; - if((cache.head = malloc(sizeof(Mntcache)*NFILE)) == nil) + if((cache.head = jehanne_malloc(sizeof(Mntcache)*NFILE)) == nil) panic("cinit: no memory"); mc = cache.head; @@ -304,7 +304,7 @@ cread(Chan *c, uint8_t *buf, int len, int64_t off) nexterror(); } - memmove(buf, p+o, l); + jehanne_memmove(buf, p+o, l); poperror(); @@ -337,7 +337,7 @@ cchain(uint8_t *buf, uint32_t offset, int len, Extent **tail) if(e == 0) break; - p = mallocz(PGSZ, 0); + p = jehanne_mallocz(PGSZ, 0); if(p == nil){ extentfree(e); break; @@ -350,7 +350,7 @@ cchain(uint8_t *buf, uint32_t offset, int len, Extent **tail) e->start = offset; e->len = l; - memmove(p, buf, l); + jehanne_memmove(p, buf, l); buf += l; offset += l; @@ -369,11 +369,11 @@ cpgmove(Extent *e, uint8_t *buf, int boff, int len) { if(e->cache == nil){ /* shouldn't happen */ - print("CACHE: cpgmove %#p %d %d nil\n", e, boff, len); + jehanne_print("CACHE: cpgmove %#p %d %d nil\n", e, boff, len); return 0; } - memmove(e->cache+boff, buf, len); + jehanne_memmove(e->cache+boff, buf, len); return 1; } @@ -454,7 +454,7 @@ cupdate(Chan *c, uint8_t *buf, int len, int64_t off) len -= o; offset += o; if(len <= 0) { -if(f && p->start + p->len > f->start) print("CACHE: p->start=%uld p->len=%d f->start=%uld\n", p->start, p->len, f->start); +if(f && p->start + p->len > f->start) jehanne_print("CACHE: p->start=%uld p->len=%d f->start=%uld\n", p->start, p->len, f->start); qunlock(mc); return; } diff --git a/sys/src/kern/port/chan.c b/sys/src/kern/port/chan.c index 306b64e..c07a6ca 100644 --- a/sys/src/kern/port/chan.c +++ b/sys/src/kern/port/chan.c @@ -62,25 +62,25 @@ kstrcpy(char *s, char *t, int ns) { int nt; - nt = strlen(t); + nt = jehanne_strlen(t); if(nt+1 <= ns){ - memmove(s, t, nt+1); + jehanne_memmove(s, t, nt+1); return; } /* too long */ if(ns < 4){ /* but very short! */ - strncpy(s, t, ns); + jehanne_strncpy(s, t, ns); return; } /* truncate with ... at character boundary (very rare case) */ - memmove(s, t, ns-4); + jehanne_memmove(s, t, ns-4); ns -= 4; s[ns] = '\0'; /* look for first byte of UTF-8 sequence by skipping continuation bytes */ while(ns>0 && (s[--ns]&0xC0)==0x80) ; - strcpy(s+ns, "..."); + jehanne_strcpy(s+ns, "..."); } int @@ -102,21 +102,21 @@ kstrdup(char **p, char *s) int n; char *t, *prev; - n = strlen(s); + n = jehanne_strlen(s); /* if it's a user, we can wait for memory; if not, something's very wrong */ if(up){ t = smalloc(n+1); }else{ - t = malloc(n+1); + t = jehanne_malloc(n+1); if(t == nil) panic("kstrdup: no memory"); } - setmalloctag(t, getcallerpc()); - memmove(t, s, n); + jehanne_setmalloctag(t, getcallerpc()); + jehanne_memmove(t, s, n); t[n] = '\0'; prev = *p; *p = t; - free(prev); + jehanne_free(prev); } Chan* @@ -153,7 +153,7 @@ newchan(void) c->mchan = 0; c->mc = 0; c->mux = 0; - memset(&c->mqid, 0, sizeof(c->mqid)); + jehanne_memset(&c->mqid, 0, sizeof(c->mqid)); c->path = 0; c->ismtpt = 0; @@ -169,11 +169,11 @@ newpath(char *s) Path *p; p = smalloc(sizeof(Path)); - i = strlen(s); + i = jehanne_strlen(s); p->len = i; p->alen = i+PATHSLOP; p->s = smalloc(p->alen); - memmove(p->s, s, i+1); + jehanne_memmove(p->s, s, i+1); p->r.ref = 1; incref(&npath); @@ -182,8 +182,8 @@ newpath(char *s) * array will not be populated correctly. The names #/ and / are * allowed, but other names with / in them draw warnings. */ - if(strchr(s, '/') && strcmp(s, "#/") != 0 && strcmp(s, "/") != 0) - print("newpath: %s from %#p\n", s, getcallerpc()); + if(jehanne_strchr(s, '/') && jehanne_strcmp(s, "#/") != 0 && jehanne_strcmp(s, "/") != 0) + jehanne_print("newpath: %s from %#p\n", s, getcallerpc()); p->mlen = 1; p->malen = PATHMSLOP; @@ -205,7 +205,7 @@ copypath(Path *p) pp->len = p->len; pp->alen = p->alen; pp->s = smalloc(p->alen); - memmove(pp->s, p->s, p->len+1); + jehanne_memmove(pp->s, p->s, p->len+1); pp->mlen = p->mlen; pp->malen = p->malen; @@ -235,12 +235,12 @@ pathclose(Path *p) if(decref(&p->r)) return; decref(&npath); - free(p->s); + jehanne_free(p->s); for(i=0; imlen; i++) if(p->mtpt[i]) cclose(p->mtpt[i]); - free(p->mtpt); - free(p); + jehanne_free(p->mtpt); + jehanne_free(p); } /* @@ -254,20 +254,20 @@ fixdotdotname(Path *p) char *r; if(p->s[0] == '#'){ - r = strchr(p->s, '/'); + r = jehanne_strchr(p->s, '/'); if(r == nil) return; - cleanname(r); + jehanne_cleanname(r); /* * The correct name is #i rather than #i/, * but the correct name of #/ is #/. */ - if(strcmp(r, "/")==0 && p->s[1] != '/') + if(jehanne_strcmp(r, "/")==0 && p->s[1] != '/') *r = '\0'; }else - cleanname(p->s); - p->len = strlen(p->s); + jehanne_cleanname(p->s); + p->len = jehanne_strlen(p->s); } static Path* @@ -296,19 +296,19 @@ addelem(Path *p, char *s, Chan *from) p = uniquepath(p); - i = strlen(s); + i = jehanne_strlen(s); if(p->len+1+i+1 > p->alen){ a = p->len+1+i+1 + PATHSLOP; t = smalloc(a); - memmove(t, p->s, p->len+1); - free(p->s); + jehanne_memmove(t, p->s, p->len+1); + jehanne_free(p->s); p->s = t; p->alen = a; } /* don't insert extra slash if one is present */ if(p->len>0 && p->s[p->len-1]!='/' && s[0]!='/') p->s[p->len++] = '/'; - memmove(p->s+p->len, s, i+1); + jehanne_memmove(p->s+p->len, s, i+1); p->len += i; if(isdotdot(s)){ fixdotdotname(p); @@ -321,8 +321,8 @@ addelem(Path *p, char *s, Chan *from) if(p->mlen >= p->malen){ p->malen = p->mlen+1+PATHMSLOP; tt = smalloc(p->malen*sizeof tt[0]); - memmove(tt, p->mtpt, p->mlen*sizeof tt[0]); - free(p->mtpt); + jehanne_memmove(tt, p->mtpt, p->mlen*sizeof tt[0]); + jehanne_free(p->mtpt); p->mtpt = tt; } DBG("addelem %s %s => add %#p\n", p->s, s, from); @@ -339,7 +339,7 @@ chanfree(Chan *c) c->flag = CFREE; if(c->dirrock != nil){ - free(c->dirrock); + jehanne_free(c->dirrock); c->dirrock = 0; c->nrock = 0; c->mrock = 0; @@ -557,7 +557,7 @@ cmount(Chan **newp, Chan *old, int flag, char *spec) error(Emount); if(old->umh) - print("cmount: unexpected umh, caller %#p\n", getcallerpc()); + jehanne_print("cmount: unexpected umh, caller %#p\n", getcallerpc()); if(!(old->qid.type & QTDIR) && order != MREPL) error(Emount); @@ -668,7 +668,7 @@ cunmount(Chan *mnt, Chan *mounted) Mount *f, **p; if(mnt->umh) /* should not happen */ - print("cunmount newp extra umh %#p has %#p\n", mnt, mnt->umh); + jehanne_print("cunmount newp extra umh %#p has %#p\n", mnt, mnt->umh); /* * It _can_ happen that mounted->umh is non-nil, @@ -745,7 +745,7 @@ cclone(Chan *c) if(wq == nil) error("clone failed"); nc = wq->clone; - free(wq); + jehanne_free(wq); nc->path = c->path; if(c->path) incref(&c->path->r); @@ -764,7 +764,7 @@ findmount(Chan **cp, Mhead **mp, int dc, uint32_t devno, Qid qid) for(mh = MOUNTH(pg, qid); mh; mh = mh->hash){ rlock(&mh->lock); if(mh->from == nil){ - print("mh %#p: mh->from nil\n", mh); + jehanne_print("mh %#p: mh->from nil\n", mh); runlock(&mh->lock); continue; } @@ -806,7 +806,7 @@ domount(Chan **cp, Mhead **mp, Path **path) p = *path; p = uniquepath(p); if(p->mlen <= 0) - print("domount: path %s has mlen==%d\n", p->s, p->mlen); + jehanne_print("domount: path %s has mlen==%d\n", p->s, p->mlen); else{ lc = &p->mtpt[p->mlen-1]; DBG("domount %#p %s => add %#p (was %#p)\n", @@ -832,7 +832,7 @@ undomount(Chan *c, Path *path) Chan *nc; if(path->r.ref != 1 || path->mlen == 0) - print("undomount: path %s ref %d mlen %d caller %#p\n", + jehanne_print("undomount: path %s ref %d mlen %d caller %#p\n", path->s, path->r.ref, path->mlen, getcallerpc()); if(path->mlen>0 && (nc=path->mtpt[path->mlen-1]) != nil){ @@ -900,7 +900,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror) *nerror = nhave; pathclose(path); cclose(c); - strcpy(up->errstr, Enotdir); + jehanne_strcpy(up->errstr, Enotdir); putmhead(mh); return -1; } @@ -979,13 +979,13 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror) if(wq->nqid==0 || (wq->qid[wq->nqid-1].type & QTDIR)){ if(nerror) *nerror = nhave+wq->nqid+1; - strcpy(up->errstr, Edoesnotexist); + jehanne_strcpy(up->errstr, Edoesnotexist); }else{ if(nerror) *nerror = nhave+wq->nqid; - strcpy(up->errstr, Enotdir); + jehanne_strcpy(up->errstr, Enotdir); } - free(wq); + jehanne_free(wq); putmhead(mh); return -1; } @@ -1010,7 +1010,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror) c = nc; putmhead(mh); mh = nmh; - free(wq); + jehanne_free(wq); } putmhead(mh); @@ -1018,7 +1018,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror) c = cunique(c); if(c->umh != nil){ //BUG - print("walk umh\n"); + jehanne_print("walk umh\n"); putmhead(c->umh); c->umh = nil; } @@ -1074,12 +1074,12 @@ growparse(Elemlist *e) if(e->nelems % Delta == 0){ new = smalloc((e->nelems+Delta) * sizeof(char*)); - memmove(new, e->elems, e->nelems*sizeof(char*)); - free(e->elems); + jehanne_memmove(new, e->elems, e->nelems*sizeof(char*)); + jehanne_free(e->elems); e->elems = new; inew = smalloc((e->nelems+Delta+1) * sizeof(int)); - memmove(inew, e->off, (e->nelems+1)*sizeof(int)); - free(e->off); + jehanne_memmove(inew, e->off, (e->nelems+1)*sizeof(int)); + jehanne_free(e->off); e->off = inew; } } @@ -1107,15 +1107,15 @@ parsename(char *aname, Elemlist *e) for(;;){ name = skipslash(name); if(*name == '\0'){ - e->off[e->nelems] = name+strlen(name) - e->name; + e->off[e->nelems] = name+jehanne_strlen(name) - e->name; e->mustbedir = 1; break; } growparse(e); e->elems[e->nelems++] = name; - slash = utfrune(name, '/'); + slash = jehanne_utfrune(name, '/'); if(slash == nil){ - e->off[e->nelems] = name+strlen(name) - e->name; + e->off[e->nelems] = name+jehanne_strlen(name) - e->name; e->mustbedir = 0; break; } @@ -1155,10 +1155,10 @@ namelenerror(char *aname, int len, char *err) /* * If the name is short enough, just use the whole thing. */ - errlen = strlen(err); + errlen = jehanne_strlen(err); if(len < ERRMAX/3 || len+errlen < 2*ERRMAX/3) - snprint(up->genbuf, sizeof up->genbuf, "%.*s", - utfnlen(aname, len), aname); + jehanne_snprint(up->genbuf, sizeof up->genbuf, "%.*s", + jehanne_utfnlen(aname, len), aname); else{ /* * Print a suffix of the name, but try to get a little info. @@ -1184,17 +1184,17 @@ namelenerror(char *aname, int len, char *err) for(i=0; (*name&0xC0)==0x80 && igenbuf, sizeof up->genbuf, "...%.*s", - utfnlen(name, ename-name), name); + jehanne_snprint(up->genbuf, sizeof up->genbuf, "...%.*s", + jehanne_utfnlen(name, ename-name), name); } - snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, err); + jehanne_snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, err); nexterror(); } void nameerror(char *name, char *err) { - namelenerror(name, strlen(name), err); + namelenerror(name, jehanne_strlen(name), err); } /* @@ -1230,7 +1230,7 @@ namec(char *aname, int amode, long omode, long perm) error("empty file name"); aname = validnamedup(aname, 1); if(waserror()){ - free(aname); + jehanne_free(aname); nexterror(); } DBG("namec %s %d %d\n", aname, amode, omode); @@ -1264,7 +1264,7 @@ namec(char *aname, int amode, long omode, long perm) error(Ebadsharp); r = dev->dc; up->genbuf[0] = '#'; - n = 1+runetochar(up->genbuf+1, &r); + n = 1+jehanne_runetochar(up->genbuf+1, &r); if(*name == '!'){ name++; while(*name != '\0' && *name != '/'){ @@ -1282,10 +1282,10 @@ namec(char *aname, int amode, long omode, long perm) up->genbuf[n++] = *name++; } up->genbuf[n] = '\0'; - n = chartorune(&r, up->genbuf+1)+1; + n = jehanne_chartorune(&r, up->genbuf+1)+1; } /* actually / is caught by parsing earlier */ - if(utfrune("9", r)) + if(jehanne_utfrune("9", r)) error(Enoattach); /* * noattach is sandboxing. @@ -1304,7 +1304,7 @@ namec(char *aname, int amode, long omode, long perm) * Who actually need them can bind #c and #p somewhere * before rfork(RFNOMNT) */ - if(up->pgrp->noattach && utfrune("|0de", r)==nil) + if(up->pgrp->noattach && jehanne_utfrune("|0de", r)==nil) error(Enoattach); dev = devtabget(r, 1); //XDYNX if(dev == nil) @@ -1327,16 +1327,16 @@ namec(char *aname, int amode, long omode, long perm) e.nerror = 0; if(waserror()){ cclose(c); - free(e.name); - free(e.elems); + jehanne_free(e.name); + jehanne_free(e.elems); /* * Prepare nice error, showing first e.nerror elements of name. */ if(e.nerror == 0) nexterror(); - strcpy(tmperrbuf, up->errstr); + jehanne_strcpy(tmperrbuf, up->errstr); if(e.off[e.nerror]==0) - print("nerror=%d but off=%d\n", + jehanne_print("nerror=%d but off=%d\n", e.nerror, e.off[e.nerror]); if(DBGFLG > 0){ DBG("showing %d+%d/%d (of %d) of %s (%d %d)\n", @@ -1344,7 +1344,7 @@ namec(char *aname, int amode, long omode, long perm) e.nelems, aname, e.off[0], e.off[1]); } len = e.prefix+e.off[e.nerror]; - free(e.off); + jehanne_free(e.off); namelenerror(aname, len, tmperrbuf); } @@ -1371,7 +1371,7 @@ namec(char *aname, int amode, long omode, long perm) if(walk(&c, e.elems, e.nelems, nomount, &e.nerror) < 0){ if(e.nerror < 0 || e.nerror > e.nelems){ - print("namec %s walk error nerror=%d\n", aname, e.nerror); + jehanne_print("namec %s walk error nerror=%d\n", aname, e.nerror); e.nerror = 0; } nexterror(); @@ -1429,7 +1429,7 @@ namec(char *aname, int amode, long omode, long perm) case Aopen: case Acreate: if(c->umh != nil){ - print("cunique umh Open\n"); + jehanne_print("cunique umh Open\n"); putmhead(c->umh); c->umh = nil; } @@ -1530,11 +1530,11 @@ namec(char *aname, int amode, long omode, long perm) kstrcpy(up->genbuf, e.elems[e.nelems-1], sizeof up->genbuf); else kstrcpy(up->genbuf, ".", sizeof up->genbuf); - free(e.name); - free(e.elems); - free(e.off); + jehanne_free(e.name); + jehanne_free(e.elems); + jehanne_free(e.off); poperror(); /* e c */ - free(aname); + jehanne_free(aname); poperror(); /* aname */ return c; @@ -1585,10 +1585,10 @@ validname0(char *aname, int slashok, int dup, uintptr_t pc) name = aname; if(!iskaddr(name)){ if(!dup) - print("warning: validname* called from %#p with user pointer", pc); + jehanne_print("warning: validname* called from %#p with user pointer", pc); ename = vmemchr(name, 0, (1<<16)); }else - ename = memchr(name, 0, (1<<16)); + ename = jehanne_memchr(name, 0, (1<<16)); if(ename==nil || ename-name>=(1<<16)) error("name too long"); @@ -1597,23 +1597,23 @@ validname0(char *aname, int slashok, int dup, uintptr_t pc) if(dup){ n = ename-name; s = smalloc(n+1); - memmove(s, name, n); + jehanne_memmove(s, name, n); s[n] = 0; aname = s; name = s; - setmalloctag(s, pc); + jehanne_setmalloctag(s, pc); } while(*name){ /* all characters above '~' are ok */ c = *(uint8_t*)name; if(c >= Runeself) - name += chartorune(&r, name); + name += jehanne_chartorune(&r, name); else{ if(isfrog[c]) if(!slashok || c!='/'){ - snprint(up->genbuf, sizeof(up->genbuf), "%s: %q", Ebadchar, aname); - free(s); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%s: %q", Ebadchar, aname); + jehanne_free(s); error(up->genbuf); } name++; @@ -1666,7 +1666,7 @@ putmhead(Mhead *mh) { if(mh && decref(&mh->r) == 0){ mh->mount = (Mount*)0xCafeBeef; - free(mh); + jehanne_free(mh); } } diff --git a/sys/src/kern/port/debug.c b/sys/src/kern/port/debug.c index aa25a71..a5af1ab 100644 --- a/sys/src/kern/port/debug.c +++ b/sys/src/kern/port/debug.c @@ -48,7 +48,7 @@ peekAtExecFaults(uintptr_t addr) return; if (__onExecFaultBreakForPID && up->pid == __onExecFaultBreakForPID) brk = 1; - if (__onExecFaultBreakForCMD[0] && strcmp(__onExecFaultBreakForCMD, up->text) == 0) + if (__onExecFaultBreakForCMD[0] && jehanne_strcmp(__onExecFaultBreakForCMD, up->text) == 0) brk = 1; if (brk > 10) brk = 1; @@ -60,11 +60,11 @@ rdmsr(uint32_t reg) extern uint64_t _rdmsr(uint32_t reg); uint64_t res; #ifdef LOGMSR - print("rdmsr(%#p)", reg); + jehanne_print("rdmsr(%#p)", reg); #endif res = _rdmsr(reg); #ifdef LOGMSR - print(" = %#P", res); + jehanne_print(" = %#P", res); #endif return res; } @@ -74,7 +74,7 @@ wrmsr(uint32_t reg, uint64_t val) { extern void _wrmsr(uint32_t reg, uint64_t val); #ifdef LOGMSR - print("wrmsr(%#p, %#P)", reg, val); + jehanne_print("wrmsr(%#p, %#P)", reg, val); #endif _wrmsr(reg, val); } diff --git a/sys/src/kern/port/dev.c b/sys/src/kern/port/dev.c index 42263a0..38412c5 100644 --- a/sys/src/kern/port/dev.c +++ b/sys/src/kern/port/dev.c @@ -83,7 +83,7 @@ devgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp) /* nothing */ }else if(name){ for(i=1; idev = devtabget(dc, 0); if(spec == nil) spec = ""; - n = 1+UTFmax+strlen(spec)+1; + n = 1+UTFmax+jehanne_strlen(spec)+1; buf = smalloc(n); - snprint(buf, n, "#%C%s", dc, spec); + jehanne_snprint(buf, n, "#%C%s", dc, spec); c->path = newpath(buf); - free(buf); + jehanne_free(buf); return c; } @@ -184,7 +184,7 @@ devwalk(Chan *c, Chan *nc, char **name, int nname, Dirtab *tab, int ntab, Devgen if(waserror()){ if(alloc && wq->clone!=nil) cclose(wq->clone); - free(wq); + jehanne_free(wq); return nil; } if(nc == nil){ @@ -203,18 +203,18 @@ devwalk(Chan *c, Chan *nc, char **name, int nname, Dirtab *tab, int ntab, Devgen goto Done; } n = name[j]; - if(strcmp(n, ".") == 0){ + if(jehanne_strcmp(n, ".") == 0){ Accept: wq->qid[wq->nqid++] = nc->qid; continue; } - if(strcmp(n, "..") == 0){ + if(jehanne_strcmp(n, "..") == 0){ /* * Use c->dev->name in the error because * nc->dev should be nil here. */ if((*gen)(nc, nil, tab, ntab, DEVDOTDOT, &dir) != 1){ - print("devgen walk .. in dev%s %#llux broken\n", + jehanne_print("devgen walk .. in dev%s %#llux broken\n", c->dev->name, nc->qid.path); error("broken devgen"); } @@ -242,7 +242,7 @@ devwalk(Chan *c, Chan *nc, char **name, int nname, Dirtab *tab, int ntab, Devgen case 0: continue; case 1: - if(strcmp(n, dir.name) == 0){ + if(jehanne_strcmp(n, dir.name) == 0){ nc->qid = dir.qid; goto Accept; } @@ -286,14 +286,14 @@ devstat(Chan *c, uint8_t *db, long n, Dirtab *tab, int ntab, Devgen *gen) if(c->qid.type & QTDIR){ if(c->path == nil) elem = "???"; - else if(strcmp(c->path->s, "/") == 0) + else if(jehanne_strcmp(c->path->s, "/") == 0) elem = "/"; else for(elem=p=c->path->s; *p; p++) if(*p == '/') elem = p+1; devdir(c, c->qid, elem, 0, eve, DMDIR|0555, &dir); - n = convD2M(&dir, db, n); + n = jehanne_convD2M(&dir, db, n); if(n == 0) error(Ebadarg); return n; @@ -306,7 +306,7 @@ devstat(Chan *c, uint8_t *db, long n, Dirtab *tab, int ntab, Devgen *gen) if(c->qid.path == dir.qid.path) { if(c->flag&CMSG) dir.mode |= DMMOUNT; - n = convD2M(&dir, db, n); + n = jehanne_convD2M(&dir, db, n); if(n == 0) error(Ebadarg); return n; @@ -331,7 +331,7 @@ devdirread(Chan *c, char *d, long n, Dirtab *tab, int ntab, Devgen *gen) break; case 1: - dsz = convD2M(&dir, (uint8_t*)d, n-m); + dsz = jehanne_convD2M(&dir, (uint8_t*)d, n-m); if(dsz <= BIT16SZ){ /* <= not < because this isn't stat; read is stuck */ if(m == 0) error(Eshort); @@ -355,7 +355,7 @@ devpermcheck(char *fileuid, int perm, int omode) int required; static int access[] = { 0000, 0400, 0200, 0600, 0100, 0xff, 0xff, 0xff }; - if(strcmp(up->user, fileuid) == 0) + if(jehanne_strcmp(up->user, fileuid) == 0) perm <<= 0; else if(ingroup(up->user, eve)) perm <<= 3; diff --git a/sys/src/kern/port/dev9p.c b/sys/src/kern/port/dev9p.c index 3a6c6e9..f86cc93 100644 --- a/sys/src/kern/port/dev9p.c +++ b/sys/src/kern/port/dev9p.c @@ -84,8 +84,8 @@ mntreset(void) mntalloc.id = 1; mntalloc.tagmask[0] = 1; /* don't allow 0 as a tag */ mntalloc.tagmask[NMASK-1] = 0x80000000UL; /* don't allow NOTAG */ - fmtinstall('F', fcallfmt); - fmtinstall('D', dirfmt); + jehanne_fmtinstall('F', fcallfmt); + jehanne_fmtinstall('D', dirfmt); /* We can't install %M since eipfmt does and is used in the kernel [sape] */ cinit(); @@ -124,7 +124,7 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) /* validity */ // if(msize < 0) // msize is unsigned, this is always false // error("bad iounit in version call"); - if(strncmp(v, VERSION9P, strlen(VERSION9P)) != 0) + if(jehanne_strncmp(v, VERSION9P, jehanne_strlen(VERSION9P)) != 0) error("bad 9P version specification"); mnt = c->mux; @@ -133,16 +133,16 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) qunlock(&c->umqlock); poperror(); - strecpy(buf, buf+sizeof buf, mnt->version); - k = strlen(buf); - if(strncmp(buf, v, k) != 0){ - snprint(buf, sizeof buf, "incompatible 9P versions %s %s", mnt->version, v); + jehanne_strecpy(buf, buf+sizeof buf, mnt->version); + k = jehanne_strlen(buf); + if(jehanne_strncmp(buf, v, k) != 0){ + jehanne_snprint(buf, sizeof buf, "incompatible 9P versions %s %s", mnt->version, v); error(buf); } if(returnlen != 0){ if(returnlen < k) error(Eshort); - memmove(version, buf, k); + jehanne_memmove(version, buf, k); } return k; } @@ -151,11 +151,11 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) f.tag = NOTAG; f.msize = msize; f.version = v; - msg = malloc(MAXRPC); + msg = jehanne_malloc(MAXRPC); if(msg == nil) exhausted("version memory"); if(waserror()){ - free(msg); + jehanne_free(msg); nexterror(); } k = convS2M(&f, msg, MAXRPC); @@ -197,8 +197,8 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) error("server tries to increase msize in fversion"); if(f.msize<256 || f.msize>1024*1024) error("nonsense value of msize in fversion"); - k = strlen(f.version); - if(strncmp(f.version, v, k) != 0) + k = jehanne_strlen(f.version); + if(jehanne_strncmp(f.version, v, k) != 0) error("bad 9P version returned from server"); /* now build Mnt associated with this connection */ @@ -207,7 +207,7 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) if(mnt != nil) mntalloc.mntfree = mnt->list; else { - mnt = malloc(sizeof(Mnt)); + mnt = jehanne_malloc(sizeof(Mnt)); if(mnt == nil) { unlock(&mntalloc); exhausted("mount devices"); @@ -225,11 +225,11 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen) if(returnlen != 0){ if(returnlen < k) error(Eshort); - memmove(version, f.version, k); + jehanne_memmove(version, f.version, k); } poperror(); /* msg */ - free(msg); + jehanne_free(msg); lock(&mnt->l); mnt->queue = 0; @@ -378,7 +378,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) Walkqid *wq; if(nc != nil) - print("mntwalk: nc != nil\n"); + jehanne_print("mntwalk: nc != nil\n"); if(nname > MAXWELEM) error("devmnt: too many name elements"); alloc = 0; @@ -386,7 +386,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) if(waserror()){ if(alloc && wq->clone!=nil) cclose(wq->clone); - free(wq); + jehanne_free(wq); return nil; } @@ -412,7 +412,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) r->request.fid = c->fid; r->request.newfid = nc->fid; r->request.nwname = nname; - memmove(r->request.wname, name, nname*sizeof(char*)); + jehanne_memmove(r->request.wname, name, nname*sizeof(char*)); mountrpc(mnt, r); @@ -423,7 +423,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname) cclose(nc); wq->clone = nil; if(r->reply.nwqid == 0){ - free(wq); + jehanne_free(wq); wq = nil; goto Return; } @@ -476,7 +476,7 @@ mntstat(Chan *c, uint8_t *dp, long n) PBIT16(dp, r->reply.nstat-2); }else{ nstat = r->reply.nstat; - memmove(dp, r->reply.stat, nstat); + jehanne_memmove(dp, r->reply.stat, nstat); validstat(dp, nstat); mntdirfix(dp, c); } @@ -636,7 +636,7 @@ muxclose(Mnt *mnt) mntfree(q); } mnt->id = 0; - free(mnt->version); + jehanne_free(mnt->version); mnt->version = nil; mntpntfree(mnt); } @@ -826,7 +826,7 @@ mountrpc(Mnt *mnt, Mntrpc *r) cn = "?"; if(r->c != nil && r->c->path != nil) cn = r->c->path->s; - print("mnt: proc %s %d: mismatch from %s %s rep %#p tag %d fid %d T%d R%d rp %d\n", + jehanne_print("mnt: proc %s %d: mismatch from %s %s rep %#p tag %d fid %d T%d R%d rp %d\n", up->text, up->pid, sn, cn, r, r->request.tag, r->request.fid, r->request.type, r->reply.type, r->reply.tag); @@ -842,7 +842,7 @@ mountio(Mnt *mnt, Mntrpc *r) while(waserror()) { if(mnt->rip == up) mntgate(mnt); - if(strcmp(up->errstr, Eintr) != 0){ + if(jehanne_strcmp(up->errstr, Eintr) != 0){ mntflushfree(mnt, r); nexterror(); } @@ -946,7 +946,7 @@ mntrpcread(Mnt *mnt, Mntrpc *r) if(convM2S(nb->rp, len, &r->reply) <= 0){ /* bad message, dump it */ - print("mntrpcread: convM2S failed\n"); + jehanne_print("mntrpcread: convM2S failed\n"); qdiscard(mnt->q, len); return -1; } @@ -969,7 +969,7 @@ mntrpcread(Mnt *mnt, Mntrpc *r) } else { /* split block and put unused bit back */ nb = allocb(i-len); - memmove(nb->wp, b->rp+len, i-len); + jehanne_memmove(nb->wp, b->rp+len, i-len); b->wp = b->rp+len; nb->wp += i-len; qputback(mnt->q, nb); @@ -1029,7 +1029,7 @@ mountmux(Mnt *mnt, Mntrpc *r) l = &q->list; } unlock(&mnt->l); - print("unexpected reply tag %ud; type %d\n", r->reply.tag, r->reply.type); + jehanne_print("unexpected reply tag %ud; type %d\n", r->reply.tag, r->reply.type); } /* @@ -1111,7 +1111,7 @@ mntralloc(Chan *c, uint32_t msize) lock(&mntalloc); new = mntalloc.rpcfree; if(new == nil){ - new = malloc(sizeof(Mntrpc)); + new = jehanne_malloc(sizeof(Mntrpc)); if(new == nil) { unlock(&mntalloc); exhausted("mount rpc header"); @@ -1120,9 +1120,9 @@ mntralloc(Chan *c, uint32_t msize) * The header is split from the data buffer as * mountmux may swap the buffer with another header. */ - new->rpc = mallocz(msize, 0); + new->rpc = jehanne_mallocz(msize, 0); if(new->rpc == nil){ - free(new); + jehanne_free(new); unlock(&mntalloc); exhausted("mount rpc buffer"); } @@ -1133,10 +1133,10 @@ mntralloc(Chan *c, uint32_t msize) mntalloc.rpcfree = new->list; mntalloc.nrpcfree--; if(new->rpclen < msize){ - free(new->rpc); - new->rpc = mallocz(msize, 0); + jehanne_free(new->rpc); + new->rpc = jehanne_mallocz(msize, 0); if(new->rpc == nil){ - free(new); + jehanne_free(new); mntalloc.nrpcused--; unlock(&mntalloc); exhausted("mount rpc buffer"); @@ -1160,9 +1160,9 @@ mntfree(Mntrpc *r) freeblist(r->b); lock(&mntalloc); if(mntalloc.nrpcfree >= 10){ - free(r->rpc); + jehanne_free(r->rpc); freetag(r->request.tag); - free(r); + jehanne_free(r); } else{ r->list = mntalloc.rpcfree; @@ -1205,7 +1205,7 @@ mntchk(Chan *c) mnt = c->mchan->mux; if(mnt == nil) - print("mntchk 2: nil mux c %s c->mchan %s \n", chanpath(c), chanpath(c->mchan)); + jehanne_print("mntchk 2: nil mux c %s c->mchan %s \n", chanpath(c), chanpath(c->mchan)); /* * Was it closed and reused (was error(Eshutdown); now, it cannot happen) diff --git a/sys/src/kern/port/devbridge.c b/sys/src/kern/port/devbridge.c index 94b1adb..4b2d0a6 100644 --- a/sys/src/kern/port/devbridge.c +++ b/sys/src/kern/port/devbridge.c @@ -208,7 +208,7 @@ bridgeattach(Chan *c, Chan *ac, char *spec, int flags) { int dev; - dev = atoi(spec); + dev = jehanne_atoi(spec); if(dev<0 || dev >= Maxbridge) error("bad specification"); @@ -263,7 +263,7 @@ bridgeclose(Chan* c) switch(TYPE(c->qid)) { case Qcache: if(c->flag & COPEN) - free(c->aux); + jehanne_free(c->aux); break; case Qlog: if(c->flag & COPEN) @@ -294,7 +294,7 @@ bridgeread(Chan *c, void *a, long n, int64_t off) qlock(&b->ql); port = b->port[PORT(c->qid)]; if(port == 0) - strcpy(buf, "unbound\n"); + jehanne_strcpy(buf, "unbound\n"); else { i = 0; switch(port->type) { @@ -302,15 +302,15 @@ bridgeread(Chan *c, void *a, long n, int64_t off) panic("bridgeread: unknown port type: %d", port->type); case Tether: - i += snprint(buf+i, sizeof(buf)-i, "ether %s: ", port->name); + i += jehanne_snprint(buf+i, sizeof(buf)-i, "ether %s: ", port->name); break; case Ttun: - i += snprint(buf+i, sizeof(buf)-i, "tunnel %s: ", port->name); + i += jehanne_snprint(buf+i, sizeof(buf)-i, "tunnel %s: ", port->name); break; } ingood = port->in - port->inmulti - port->inunknown; outgood = port->out - port->outmulti - port->outunknown; - i += snprint(buf+i, sizeof(buf)-i, + i += jehanne_snprint(buf+i, sizeof(buf)-i, "in=%d(%d:%d:%d) out=%d(%d:%d:%d:%d)\n", port->in, ingood, port->inmulti, port->inunknown, port->out, outgood, port->outmulti, @@ -321,7 +321,7 @@ bridgeread(Chan *c, void *a, long n, int64_t off) qunlock(&b->ql); return n; case Qbctl: - snprint(buf, sizeof(buf), "%s tcpmss\ndelay %ld %ld\n", + jehanne_snprint(buf, sizeof(buf), "%s tcpmss\ndelay %ld %ld\n", b->tcpmss ? "set" : "clear", b->delay0, b->delayn); n = readstr(off, a, n, buf); return n; @@ -329,7 +329,7 @@ bridgeread(Chan *c, void *a, long n, int64_t off) n = readstr(off, a, n, c->aux); return n; case Qstats: - snprint(buf, sizeof(buf), "hit=%uld miss=%uld copy=%uld\n", + jehanne_snprint(buf, sizeof(buf), "hit=%uld miss=%uld copy=%uld\n", b->hit, b->miss, b->copy); n = readstr(off, a, n, buf); return n; @@ -339,7 +339,7 @@ bridgeread(Chan *c, void *a, long n, int64_t off) static void bridgeoption(Bridge *b, char *option, int value) { - if(strcmp(option, "tcpmss") == 0) + if(jehanne_strcmp(option, "tcpmss") == 0) b->tcpmss = value; else error("unknown bridge option"); @@ -362,42 +362,42 @@ bridgewrite(Chan *c, void *a, long n, int64_t off) qlock(&b->ql); if(waserror()) { qunlock(&b->ql); - free(cb); + jehanne_free(cb); nexterror(); } if(cb->nf == 0) error("short write"); arg0 = cb->f[0]; - if(strcmp(arg0, "bind") == 0) { + if(jehanne_strcmp(arg0, "bind") == 0) { portbind(b, cb->nf-1, cb->f+1); - } else if(strcmp(arg0, "unbind") == 0) { + } else if(jehanne_strcmp(arg0, "unbind") == 0) { portunbind(b, cb->nf-1, cb->f+1); - } else if(strcmp(arg0, "cacheflush") == 0) { + } else if(jehanne_strcmp(arg0, "cacheflush") == 0) { log(b, Logcache, "cache flush\n"); - memset(b->cache, 0, CacheSize*sizeof(Centry)); - } else if(strcmp(arg0, "set") == 0) { + jehanne_memset(b->cache, 0, CacheSize*sizeof(Centry)); + } else if(jehanne_strcmp(arg0, "set") == 0) { if(cb->nf != 2) error("usage: set option"); bridgeoption(b, cb->f[1], 1); - } else if(strcmp(arg0, "clear") == 0) { + } else if(jehanne_strcmp(arg0, "clear") == 0) { if(cb->nf != 2) error("usage: clear option"); bridgeoption(b, cb->f[1], 0); - } else if(strcmp(arg0, "delay") == 0) { + } else if(jehanne_strcmp(arg0, "delay") == 0) { if(cb->nf != 3) error("usage: delay delay0 delayn"); - b->delay0 = strtol(cb->f[1], nil, 10); - b->delayn = strtol(cb->f[2], nil, 10); + b->delay0 = jehanne_strtol(cb->f[1], nil, 10); + b->delayn = jehanne_strtol(cb->f[2], nil, 10); } else error("unknown control request"); poperror(); qunlock(&b->ql); - free(cb); + jehanne_free(cb); return n; case Qlog: cb = parsecmd(a, n); p = logctl(b, cb->nf, cb->f, logflags); - free(cb); + jehanne_free(cb); if(p != nil) error(p); return n; @@ -416,12 +416,12 @@ bridgegen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) switch(TYPE(c->qid)){ case Qtopdir: case Qbridgedir: - snprint(up->genbuf, sizeof(up->genbuf), "#B%ld", c->devno); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "#B%ld", c->devno); mkqid(&qid, Qtopdir, 0, QTDIR); devdir(c, qid, up->genbuf, 0, eve, 0555, dp); break; case Qportdir: - snprint(up->genbuf, sizeof(up->genbuf), "bridge%ld", c->devno); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "bridge%ld", c->devno); mkqid(&qid, Qbridgedir, 0, QTDIR); devdir(c, qid, up->genbuf, 0, eve, 0555, dp); break; @@ -446,7 +446,7 @@ bridgegen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) case Qtopdir: if(s != 0) return -1; - snprint(up->genbuf, sizeof(up->genbuf), "bridge%ld", c->devno); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "bridge%ld", c->devno); mkqid(&qid, QID(0, Qbridgedir), 0, QTDIR); devdir(c, qid, up->genbuf, 0, eve, 0555, dp); return 1; @@ -460,7 +460,7 @@ bridgegen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) if(s >= b->nport) return -1; mkqid(&qid, QID(s, Qportdir), 0, QTDIR); - snprint(up->genbuf, sizeof(up->genbuf), "%d", s); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d", s); devdir(c, qid, up->genbuf, 0, eve, 0555, dp); return 1; case Qportdir: @@ -485,32 +485,32 @@ portbind(Bridge *b, int argc, char *argv[]) char buf[100], name[KNAMELEN], path[8*KNAMELEN]; static char usage[] = "usage: bind ether|tunnel name ownhash dev [dev2]"; - memset(name, 0, KNAMELEN); + jehanne_memset(name, 0, KNAMELEN); if(argc < 4) error(usage); - if(strcmp(argv[0], "ether") == 0) { + if(jehanne_strcmp(argv[0], "ether") == 0) { if(argc != 4) error(usage); type = Tether; - strncpy(name, argv[1], KNAMELEN-1); + jehanne_strncpy(name, argv[1], KNAMELEN-1); name[KNAMELEN-1] = 0; // parseaddr(addr, argv[1], Eaddrlen); - } else if(strcmp(argv[0], "tunnel") == 0) { + } else if(jehanne_strcmp(argv[0], "tunnel") == 0) { if(argc != 5) error(usage); type = Ttun; - strncpy(name, argv[1], KNAMELEN-1); + jehanne_strncpy(name, argv[1], KNAMELEN-1); name[KNAMELEN-1] = 0; // parseip(addr, argv[1]); dev2 = argv[4]; } else error(usage); - ownhash = strtoul(argv[2], 0, 0); + ownhash = jehanne_strtoul(argv[2], 0, 0); dev = argv[3]; for(i=0; inport; i++) { port = b->port[i]; if(port != nil && port->type == type && - memcmp(port->name, name, KNAMELEN) == 0) + jehanne_memcmp(port->name, name, KNAMELEN) == 0) error("port in use"); } for(i=0; itype = type; - memmove(port->name, name, KNAMELEN); + jehanne_memmove(port->name, name, KNAMELEN); switch(port->type) { default: panic("portbind: unknown port type: %d", type); case Tether: - snprint(path, sizeof(path), "%s/clone", dev); + jehanne_snprint(path, sizeof(path), "%s/clone", dev); ctl = namec(path, Aopen, ORDWR, 0); if(waserror()) { cclose(ctl); @@ -546,15 +546,15 @@ portbind(Bridge *b, int argc, char *argv[]) buf[n] = 0; for(p = buf; *p == ' '; p++) ; - snprint(path, sizeof(path), "%s/%lud/data", dev, strtoul(p, 0, 0)); + jehanne_snprint(path, sizeof(path), "%s/%lud/data", dev, jehanne_strtoul(p, 0, 0)); // setup connection to be promiscuous - snprint(buf, sizeof(buf), "connect -1"); - devtab[ctl->qid.type]->write(ctl, buf, strlen(buf), 0); - snprint(buf, sizeof(buf), "promiscuous"); - devtab[ctl->qid.type]->write(ctl, buf, strlen(buf), 0); - snprint(buf, sizeof(buf), "bridge"); - devtab[ctl->qid.type]->write(ctl, buf, strlen(buf), 0); + jehanne_snprint(buf, sizeof(buf), "connect -1"); + devtab[ctl->qid.type]->write(ctl, buf, jehanne_strlen(buf), 0); + jehanne_snprint(buf, sizeof(buf), "promiscuous"); + devtab[ctl->qid.type]->write(ctl, buf, jehanne_strlen(buf), 0); + jehanne_snprint(buf, sizeof(buf), "bridge"); + devtab[ctl->qid.type]->write(ctl, buf, jehanne_strlen(buf), 0); // open data port port->data[0] = namec(path, Aopen, ORDWR, 0); @@ -595,29 +595,29 @@ portunbind(Bridge *b, int argc, char *argv[]) Port *port = nil; static char usage[] = "usage: unbind ether|tunnel addr [ownhash]"; - memset(name, 0, KNAMELEN); + jehanne_memset(name, 0, KNAMELEN); if(argc < 2 || argc > 3) error(usage); - if(strcmp(argv[0], "ether") == 0) { + if(jehanne_strcmp(argv[0], "ether") == 0) { type = Tether; - strncpy(name, argv[1], KNAMELEN-1); + jehanne_strncpy(name, argv[1], KNAMELEN-1); name[KNAMELEN-1] = 0; // parseaddr(addr, argv[1], Eaddrlen); - } else if(strcmp(argv[0], "tunnel") == 0) { + } else if(jehanne_strcmp(argv[0], "tunnel") == 0) { type = Ttun; - strncpy(name, argv[1], KNAMELEN-1); + jehanne_strncpy(name, argv[1], KNAMELEN-1); name[KNAMELEN-1] = 0; // parseip(addr, argv[1]); } else error(usage); if(argc == 3) - ownhash = strtoul(argv[2], 0, 0); + ownhash = jehanne_strtoul(argv[2], 0, 0); else ownhash = 0; for(i=0; inport; i++) { port = b->port[i]; if(port != nil && port->type == type && - memcmp(port->name, name, KNAMELEN) == 0) + jehanne_memcmp(port->name, name, KNAMELEN) == 0) break; } if(i == b->nport) @@ -657,7 +657,7 @@ cachelookup(Bridge *b, uint8_t d[Eaddrlen]) p = b->cache + h; sec = TK2SEC(m->ticks); for(i=0; id, Eaddrlen) == 0) { + if(jehanne_memcmp(d, p->d, Eaddrlen) == 0) { p->dst++; if(sec >= p->expire) { log(b, Logcache, "expired cache entry: %E %d\n", @@ -699,7 +699,7 @@ cacheupdate(Bridge *b, uint8_t d[Eaddrlen], int port) // look for oldest entry for(i=0; id, d, Eaddrlen) == 0) { + if(jehanne_memcmp(p->d, d, Eaddrlen) == 0) { p->expire = TK2SEC(m->ticks) + CacheTimeout; if(p->port != port) { log(b, Logcache, "NIC changed port %d->%d: %E\n", @@ -717,7 +717,7 @@ cacheupdate(Bridge *b, uint8_t d[Eaddrlen], int port) if(pp->expire != 0) log(b, Logcache, "bumping from cache: %E %d\n", pp->d, pp->port); pp->expire = TK2SEC(m->ticks) + CacheTimeout; - memmove(pp->d, d, Eaddrlen); + jehanne_memmove(pp->d, d, Eaddrlen); pp->port = port; pp->src = 1; pp->dst = 0; @@ -735,7 +735,7 @@ cacheflushport(Bridge *b, int port) for(i=0; iport != port) continue; - memset(ce, 0, sizeof(Centry)); + jehanne_memset(ce, 0, sizeof(Centry)); } } @@ -765,7 +765,7 @@ cachedump(Bridge *b) if(ce->expire == 0) continue; c = (sec < ce->expire)?'v':'e'; - p += snprint(p, ep-p, "%E %2d %10ld %10ld %10ld %c\n", ce->d, + p += jehanne_snprint(p, ep-p, "%E %2d %10ld %10ld %10ld %c\n", ce->d, ce->port, ce->src, ce->dst, ce->expire+off, c); } *p = 0; @@ -896,7 +896,7 @@ tcpmsshack(Etherpkt *epkt, int n) // fit checksum cksum = nhgets(tcphdr->cksum); if(optr-(uint8_t*)tcphdr & 1) { -// print("tcpmsshack: odd alignment!\n"); +// jehanne_print("tcpmsshack: odd alignment!\n"); // odd alignments are a pain cksum += nhgets(optr+1); cksum -= (optr[1]<<8)|(TcpMssMax>>8); @@ -934,23 +934,23 @@ etherread(void *a) // release lock to read - error means it is time to quit qunlock(&b->ql); if(waserror()) { - print("etherread read error: %s\n", up->errstr); + jehanne_print("etherread read error: %s\n", up->errstr); qlock(&b->ql); break; } if(0) - print("devbridge: etherread: reading\n"); + jehanne_print("devbridge: etherread: reading\n"); bp = devtab[port->data[0]->qid.type]->bread(port->data[0], ETHERMAXTU, 0); if(0) - print("devbridge: etherread: blocklen = %d\n", + jehanne_print("devbridge: etherread: blocklen = %d\n", blocklen(bp)); poperror(); qlock(&b->ql); if(bp == nil || port->closed) break; if(waserror()) { -// print("etherread bridge error\n"); +// jehanne_print("etherread bridge error\n"); if(bp) freeb(bp); continue; @@ -997,7 +997,7 @@ etherread(void *a) if(bp) freeb(bp); } -// print("etherread: trying to exit\n"); +// jehanne_print("etherread: trying to exit\n"); port->readp = nil; portfree(port); qunlock(&b->ql); @@ -1069,14 +1069,14 @@ etherwrite(Port *port, Block *bp) xp->rp += offset; if(0) - print("seglen=%d, dlen=%d, mf=%x, frag=%d\n", + jehanne_print("seglen=%d, dlen=%d, mf=%x, frag=%d\n", seglen, dlen, mf, frag); for(fragoff = 0; fragoff < dlen; fragoff += seglen) { nb = allocb(ETHERHDRSIZE+IPHDR+seglen); feh = (Iphdr*)(nb->wp+ETHERHDRSIZE); - memmove(nb->wp, epkt, ETHERHDRSIZE+IPHDR); + jehanne_memmove(nb->wp, epkt, ETHERHDRSIZE+IPHDR); nb->wp += ETHERHDRSIZE+IPHDR; if((fragoff + seglen) >= dlen) { @@ -1095,7 +1095,7 @@ etherwrite(Port *port, Block *bp) blklen = chunk; if(BLEN(xp) < chunk) blklen = BLEN(xp); - memmove(nb->wp, xp->rp, blklen); + jehanne_memmove(nb->wp, xp->rp, blklen); nb->wp += blklen; xp->rp += blklen; chunk -= blklen; @@ -1130,8 +1130,8 @@ portfree(Port *port) cclose(port->data[0]); if(port->data[1]) cclose(port->data[1]); - memset(port, 0, sizeof(Port)); - free(port); + jehanne_memset(port, 0, sizeof(Port)); + jehanne_free(port); } Dev bridgedevtab = { diff --git a/sys/src/kern/port/devcap.c b/sys/src/kern/port/devcap.c index 888dd90..a0046ec 100644 --- a/sys/src/kern/port/devcap.c +++ b/sys/src/kern/port/devcap.c @@ -112,7 +112,7 @@ hashstr(uint8_t *hash) int i; for(i = 0; i < Hashlen; i++) - sprint(buf+2*i, "%2.2ux", hash[i]); + jehanne_sprint(buf+2*i, "%2.2ux", hash[i]); buf[2*Hashlen] = 0; return buf; } @@ -128,7 +128,7 @@ remcap(uint8_t *hash) /* find the matching capability */ for(l = &capalloc.first; *l != nil;){ t = *l; - if(memcmp(hash, t->hash, Hashlen) == 0) + if(jehanne_memcmp(hash, t->hash, Hashlen) == 0) break; l = &t->next; } @@ -149,7 +149,7 @@ addcap(uint8_t *hash) Caphash *p, *t, **l; p = smalloc(sizeof *p); - memmove(p->hash, hash, Hashlen); + jehanne_memmove(p->hash, hash, Hashlen); p->next = nil; p->ticks = m->ticks; @@ -161,7 +161,7 @@ addcap(uint8_t *hash) if(t == nil) panic("addcap"); capalloc.first = t->next; - free(t); + jehanne_free(t); capalloc.nhash--; } @@ -208,7 +208,7 @@ capwrite(Chan *c, void *va, long n, int64_t _1) error(Eperm); if(n < Hashlen) error(Eshort); - memmove(hash, va, Hashlen); + jehanne_memmove(hash, va, Hashlen); addcap(hash); break; @@ -216,34 +216,34 @@ capwrite(Chan *c, void *va, long n, int64_t _1) /* copy key to avoid a fault in hmac_xx */ cp = nil; if(waserror()){ - free(cp); + jehanne_free(cp); nexterror(); } cp = smalloc(n+1); - memmove(cp, va, n); + jehanne_memmove(cp, va, n); cp[n] = 0; from = cp; - key = strrchr(cp, '@'); + key = jehanne_strrchr(cp, '@'); if(key == nil) error(Eshort); *key++ = 0; - hmac_sha1((uint8_t*)from, strlen(from), (uint8_t*)key, strlen(key), hash, nil); + hmac_sha1((uint8_t*)from, jehanne_strlen(from), (uint8_t*)key, jehanne_strlen(key), hash, nil); p = remcap(hash); if(p == nil){ - snprint(err, sizeof err, "invalid capability %s@%s", from, key); + jehanne_snprint(err, sizeof err, "invalid capability %s@%s", from, key); error(err); } /* if a from user is supplied, make sure it matches */ - to = strchr(from, '@'); + to = jehanne_strchr(from, '@'); if(to == nil){ to = from; } else { *to++ = 0; - if(strcmp(from, up->user) != 0) + if(jehanne_strcmp(from, up->user) != 0) error("capability must match user"); } @@ -251,8 +251,8 @@ capwrite(Chan *c, void *va, long n, int64_t _1) kstrdup(&up->user, to); up->basepri = PriNormal; - free(p); - free(cp); + jehanne_free(p); + jehanne_free(cp); poperror(); break; diff --git a/sys/src/kern/port/devcons.c b/sys/src/kern/port/devcons.c index 0218fe4..ba841a1 100644 --- a/sys/src/kern/port/devcons.c +++ b/sys/src/kern/port/devcons.c @@ -280,12 +280,12 @@ kmesgputs(char *str, int n) if(nn + n >= sizeof kmesg.buf){ d = nn + n - sizeof kmesg.buf; if(d) - memmove(kmesg.buf, kmesg.buf+d, sizeof kmesg.buf-d); + jehanne_memmove(kmesg.buf, kmesg.buf+d, sizeof kmesg.buf-d); nn -= d; } /* copy the data in */ - memmove(kmesg.buf+nn, str, n); + jehanne_memmove(kmesg.buf+nn, str, n); nn += n; kmesg.n = nn; iunlock(&kmesg.lk); @@ -331,7 +331,7 @@ putstrn0(char *str, int n, int usewrite) while(len > 0){ t = nil; if((c->flags&Cntorn) && !kbd.raw) - t = memchr(s, '\n', len); + t = jehanne_memchr(s, '\n', len); if(t != nil && !kbd.raw){ m = t-s; consdevputs(c, s, m, usewrite); @@ -352,15 +352,21 @@ putstrn(char *str, int n) putstrn0(str, n, 0); } +void +jehanne__assert(const char *s) +{ + panic("assert failed at %#p: %s\n", getcallerpc(), s); +} + int -print(char *fmt, ...) +jehanne_print(char *fmt, ...) { int n; va_list arg; char buf[PRINTSIZE]; va_start(arg, fmt); - n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); putstrn(buf, n); @@ -400,7 +406,7 @@ iprint(char *fmt, ...) s = splhi(); va_start(arg, fmt); - n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); mlocked = malloclocked(); locked = iprintcanlock(&iprintlock); @@ -437,9 +443,9 @@ panic(char *fmt, ...) consdevs[1].q = nil; /* don't try to write to /dev/kprint */ splhi(); - strcpy(buf, "panic: "); + jehanne_strcpy(buf, "panic: "); va_start(arg, fmt); - n = vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf+jehanne_strlen(buf), buf+sizeof(buf), fmt, arg) - buf; va_end(arg); iprint("%s\n", buf); if(consdebug) @@ -464,7 +470,7 @@ sysfatal(char *fmt, ...) va_list arg; va_start(arg, fmt); - vseprint(err, err + sizeof err, fmt, arg); + jehanne_vseprint(err, err + sizeof err, fmt, arg); va_end(arg); panic("sysfatal: %s", err); } @@ -489,9 +495,9 @@ pprint(char *fmt, ...) c = up->fgrp->fd[2]; if(c==0 || (c->mode!=OWRITE && c->mode!=ORDWR)) return 0; - n = snprint(buf, sizeof buf, "%s %d: ", up->text, up->pid); + n = jehanne_snprint(buf, sizeof buf, "%s %d: ", up->text, up->pid); va_start(arg, fmt); - n = vseprint(buf+n, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf+n, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); if(waserror()) @@ -556,7 +562,7 @@ echo(char *buf, int n) consdebug = rdb; else consdebug = nil; - print("consdebug now %#p\n", consdebug); + jehanne_print("consdebug now %#p\n", consdebug); return; case 'D': if(consdebug == nil) @@ -625,7 +631,7 @@ kbdputc(Queue* _1, int ch) ilock(&kbd.lockputc); /* just a mutex */ r = ch; - n = runetochar(buf, &r); + n = jehanne_runetochar(buf, &r); for(i = 0; i < n; i++){ next = kbd.iw+1; if(next >= kbd.ie) @@ -718,13 +724,13 @@ readnum(uint32_t off, char *buf, uint32_t n, uint32_t val, int size) { char tmp[64]; - snprint(tmp, sizeof(tmp), "%*lud", size-1, val); + jehanne_snprint(tmp, sizeof(tmp), "%*lud", size-1, val); tmp[size-1] = ' '; if(off >= size) return 0; if(off+n > size) n = size-off; - memmove(buf, tmp+off, n); + jehanne_memmove(buf, tmp+off, n); return n; } @@ -733,12 +739,12 @@ readstr(long offset, char *buf, long n, char *str) { long size; - size = strlen(str); + size = jehanne_strlen(str); if(offset >= size) return 0; if(offset+n > size) n = size-offset; - memmove(buf, str+offset, n); + jehanne_memmove(buf, str+offset, n); return n; } @@ -877,7 +883,7 @@ consread(Chan *c, void *buf, long n, int64_t off) break; case 0x15: /* ^U */ kbd.x = 0; - print("\b^U\n"); + jehanne_print("\b^U\n"); break; case '\n': case 0x04: /* ^D */ @@ -922,7 +928,7 @@ consread(Chan *c, void *buf, long n, int64_t off) else{ if(off+n > kmesg.n) n = kmesg.n - off; - memmove(buf, kmesg.buf+off, n); + jehanne_memmove(buf, kmesg.buf+off, n); } return n; @@ -950,7 +956,7 @@ consread(Chan *c, void *buf, long n, int64_t off) n = readstr(offset, buf, n, b); poperror(); } - free(b); + jehanne_free(b); return n; // case Qconfig: @@ -989,17 +995,17 @@ consread(Chan *c, void *buf, long n, int64_t off) *bp++ = '\n'; } if(waserror()){ - free(b); + jehanne_free(b); nexterror(); } n = readstr(offset, buf, n, b); - free(b); + jehanne_free(b); poperror(); return n; case Qswap: memory_stats(&mstats); - snprint(tmp, sizeof tmp, + jehanne_snprint(tmp, sizeof tmp, "%llud memory\n" "%llud pagesize\n" "%lud kernel\n" @@ -1026,7 +1032,7 @@ consread(Chan *c, void *buf, long n, int64_t off) return readstr(offset, buf, n, "2000"); default: - print("consread %#llux\n", c->qid.path); + jehanne_print("consread %#llux\n", c->qid.path); error(Egreg); } return -1; /* never reached */ @@ -1068,7 +1074,7 @@ conswrite(Chan *c, void *va, long n, int64_t off) bp = l; if(bp > sizeof buf) bp = sizeof buf; - memmove(buf, a, bp); + jehanne_memmove(buf, a, bp); putstrn0(buf, bp, 1); a += bp; l -= bp; @@ -1078,22 +1084,22 @@ conswrite(Chan *c, void *va, long n, int64_t off) case Qconsctl: if(n >= sizeof(buf)) n = sizeof(buf)-1; - strncpy(buf, a, n); + jehanne_strncpy(buf, a, n); buf[n] = 0; for(a = buf; a;){ - if(strncmp(a, "rawon", 5) == 0){ + if(jehanne_strncmp(a, "rawon", 5) == 0){ kbd.raw = 1; /* clumsy hack - wake up reader */ ch = 0; qwrite(kbdq, &ch, 1); } - else if(strncmp(a, "rawoff", 6) == 0) + else if(jehanne_strncmp(a, "rawoff", 6) == 0) kbd.raw = 0; - else if(strncmp(a, "ctlpon", 6) == 0) + else if(jehanne_strncmp(a, "ctlpon", 6) == 0) kbd.ctlpoff = 0; - else if(strncmp(a, "ctlpoff", 7) == 0) + else if(jehanne_strncmp(a, "ctlpoff", 7) == 0) kbd.ctlpoff = 1; - if(a = strchr(a, ' ')) + if(a = jehanne_strchr(a, ' ')) a++; } break; @@ -1130,7 +1136,7 @@ conswrite(Chan *c, void *va, long n, int64_t off) cb = parsecmd(a, n); if(waserror()) { - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, rebootmsg, nelem(rebootmsg)); @@ -1146,7 +1152,7 @@ conswrite(Chan *c, void *va, long n, int64_t off) panic("/dev/reboot"); } poperror(); - free(cb); + jehanne_free(cb); break; case Qsysstat: @@ -1171,7 +1177,7 @@ conswrite(Chan *c, void *va, long n, int64_t off) error(Ebadarg); if(n <= 0 || n >= sizeof buf) error(Ebadarg); - strncpy(buf, a, n); + jehanne_strncpy(buf, a, n); buf[n] = 0; if(buf[n-1] == '\n') buf[n-1] = 0; @@ -1179,7 +1185,7 @@ conswrite(Chan *c, void *va, long n, int64_t off) break; default: - print("conswrite: %#llux\n", c->qid.path); + jehanne_print("conswrite: %#llux\n", c->qid.path); error(Egreg); } return n; @@ -1309,7 +1315,7 @@ readtime(uint32_t off, char *buf, int n) if(fasthz == 0LL) fastticks((uint64_t*)&fasthz); sec = nsec/1000000000ULL; - snprint(str, sizeof(str), "%*lud %*llud %*llud %*llud ", + jehanne_snprint(str, sizeof(str), "%*lud %*llud %*llud %*llud ", NUMSIZE-1, sec, VLNUMSIZE-1, nsec, VLNUMSIZE-1, ticks, @@ -1329,9 +1335,9 @@ writetime(char *buf, int n) if(n >= sizeof(b)) error(Ebadtimectl); - strncpy(b, buf, n); + jehanne_strncpy(b, buf, n); b[n] = 0; - i = strtol(b, 0, 0); + i = jehanne_strtol(b, 0, 0); if(i <= 0) error(Ebadtimectl); now = i*1000000000LL; diff --git a/sys/src/kern/port/devdraw.c b/sys/src/kern/port/devdraw.c index 4c508d0..eec6f2c 100644 --- a/sys/src/kern/port/devdraw.c +++ b/sys/src/kern/port/devdraw.c @@ -237,9 +237,9 @@ drawgen(Chan *c, char *cc, Dirtab *dt, int i, int s, Dir *dp) case Q3rd: cl = drawclientofpath(c->qid.path); if(cl == nil) - strncpy(up->genbuf, "??", sizeof up->genbuf); + jehanne_strncpy(up->genbuf, "??", sizeof up->genbuf); else - snprint(up->genbuf, sizeof up->genbuf, + jehanne_snprint(up->genbuf, sizeof up->genbuf, "%d", cl->clientid); mkqid(&q, Q2nd, 0, QTDIR); devdir(c, q, up->genbuf, 0, eve, 0500, dp); @@ -288,7 +288,7 @@ drawgen(Chan *c, char *cc, Dirtab *dt, int i, int s, Dir *dp) cl = sdraw.client[s-1]; if(cl == 0) return 0; - snprint(up->genbuf, sizeof up->genbuf, "%d", + jehanne_snprint(up->genbuf, sizeof up->genbuf, "%d", cl->clientid); mkqid(&q, (s<genbuf, 0, eve, 0555, dp); @@ -367,7 +367,7 @@ drawrefresh(Memimage *m, Rectangle r, void *v) combinerect(&ref->r, r); return; } - ref = malloc(sizeof(Refresh)); + ref = jehanne_malloc(sizeof(Refresh)); if(ref){ ref->dimage = d; ref->r = r; @@ -432,7 +432,7 @@ dstflush(int dstid, Memimage *dst, Rectangle r) } /* how can this happen? -rsc, dec 12 2002 */ if(dst == 0){ - print("nil dstflush\n"); + jehanne_print("nil dstflush\n"); return; } l = dst->layer; @@ -459,9 +459,9 @@ static int drawcmp(char *a, char *b, int n) { - if(strlen(a) != n) + if(jehanne_strlen(a) != n) return 1; - return memcmp(a, b, n); + return jehanne_memcmp(a, b, n); } DName* @@ -489,7 +489,7 @@ drawgoodname(DImage *d) return 0; if(d->name == nil) return 1; - n = drawlookupname(strlen(d->name), d->name); + n = drawlookupname(jehanne_strlen(d->name), d->name); if(n==nil || n->vers!=d->vers) return 0; return 1; @@ -548,7 +548,7 @@ allocdimage(Memimage *i) { DImage *d; - d = malloc(sizeof(DImage)); + d = jehanne_malloc(sizeof(DImage)); if(d == 0) return 0; d->ref = 1; @@ -582,22 +582,22 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df Memscreen *s; CScreen *c; - c = malloc(sizeof(CScreen)); + c = jehanne_malloc(sizeof(CScreen)); if(dimage && dimage->image && dimage->image->chan == 0) panic("bad image %p in drawinstallscreen", dimage->image); if(c == 0) return 0; if(d == 0){ - d = malloc(sizeof(DScreen)); + d = jehanne_malloc(sizeof(DScreen)); if(d == 0){ - free(c); + jehanne_free(c); return 0; } - s = malloc(sizeof(Memscreen)); + s = jehanne_malloc(sizeof(Memscreen)); if(s == 0){ - free(c); - free(d); + jehanne_free(c); + jehanne_free(d); return 0; } s->frontmost = 0; @@ -633,7 +633,7 @@ drawdelname(DName *name) int i; i = name-sdraw.name; - memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName)); + jehanne_memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName)); sdraw.nname--; } @@ -644,7 +644,7 @@ drawfreedscreen(DScreen *this) this->ref--; if(this->ref < 0) - print("negative ref in drawfreedscreen\n"); + jehanne_print("negative ref in drawfreedscreen\n"); if(this->ref > 0) return; ds = dscreen; @@ -666,8 +666,8 @@ drawfreedscreen(DScreen *this) drawfreedimage(this->dimage); if(this->dfill) drawfreedimage(this->dfill); - free(this->screen); - free(this); + jehanne_free(this->screen); + jehanne_free(this); } void @@ -679,7 +679,7 @@ drawfreedimage(DImage *dimage) dimage->ref--; if(dimage->ref < 0) - print("negative ref in drawfreedimage\n"); + jehanne_print("negative ref in drawfreedimage\n"); if(dimage->ref > 0) return; @@ -701,7 +701,7 @@ drawfreedimage(DImage *dimage) if(l->data == screenimage->data) addflush(l->layer->screenr); if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */ - free(l->layer->refreshptr); + jehanne_free(l->layer->refreshptr); l->layer->refreshptr = nil; if(drawgoodname(dimage)) memldelete(l); @@ -711,8 +711,8 @@ drawfreedimage(DImage *dimage) }else freememimage(dimage->image); Return: - free(dimage->fchar); - free(dimage); + jehanne_free(dimage->fchar); + jehanne_free(dimage); } void @@ -724,14 +724,14 @@ drawuninstallscreen(Client *client, CScreen *this) if(cs == this){ client->cscreen = this->next; drawfreedscreen(this->dscreen); - free(this); + jehanne_free(this); return; } while(next = cs->next){ /* assign = */ if(next == this){ cs->next = this->next; drawfreedscreen(this->dscreen); - free(this); + jehanne_free(this); return; } cs = next; @@ -773,13 +773,13 @@ drawaddname(Client *client, DImage *di, int n, char *str) if(drawcmp(name->name, str, n) == 0) error(Enameused); t = sqmalloc((sdraw.nname+1)*sizeof(DName)); - memmove(t, sdraw.name, sdraw.nname*sizeof(DName)); - free(sdraw.name); + jehanne_memmove(t, sdraw.name, sdraw.nname*sizeof(DName)); + jehanne_free(sdraw.name); sdraw.name = t; new = &sdraw.name[sdraw.nname++]; - memset(new, 0, sizeof(DName)); // clear the new element. + jehanne_memset(new, 0, sizeof(DName)); // clear the new element. new->name = sqmalloc(n+1); - memmove(new->name, str, n); + jehanne_memmove(new->name, str, n); new->name[n] = 0; new->dimage = di; new->client = client; @@ -798,19 +798,19 @@ drawnewclient(void) break; } if(i == sdraw.nclient){ - cp = malloc((sdraw.nclient+1)*sizeof(Client*)); + cp = jehanne_malloc((sdraw.nclient+1)*sizeof(Client*)); if(cp == 0) return 0; - memmove(cp, sdraw.client, sdraw.nclient*sizeof(Client*)); - free(sdraw.client); + jehanne_memmove(cp, sdraw.client, sdraw.nclient*sizeof(Client*)); + jehanne_free(sdraw.client); sdraw.client = cp; sdraw.nclient++; cp[i] = 0; } - cl = malloc(sizeof(Client)); + cl = jehanne_malloc(sizeof(Client)); if(cl == 0) return 0; - memset(cl, 0, sizeof(Client)); + jehanne_memset(cl, 0, sizeof(Client)); cl->slot = i; cl->clientid = ++sdraw.clientid; cl->op = SoverD; @@ -948,20 +948,20 @@ makescreenimage(void) Memimage *i; Rectangle r; - md = malloc(sizeof *md); + md = jehanne_malloc(sizeof *md); if(md == nil) return nil; md->allocd = 1; md->base = nil; md->bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen); if(md->bdata == nil){ - free(md); + jehanne_free(md); return nil; } md->ref = 1; i = allocmemimaged(r, chan, md); if(i == nil){ - free(md); + jehanne_free(md); return nil; } i->width = width; @@ -973,8 +973,8 @@ makescreenimage(void) return nil; } if(!waserror()){ - snprint(screenname, sizeof screenname, "noborder.screen.%d", ++screennameid); - drawaddname(nil, di, strlen(screenname), screenname); + jehanne_snprint(screenname, sizeof screenname, "noborder.screen.%d", ++screennameid); + drawaddname(nil, di, jehanne_strlen(screenname), screenname); poperror(); } return di; @@ -1083,7 +1083,7 @@ drawopen(Chan *c, unsigned long omode) error(Einuse); cl->busy = 1; flushrect = Rect(10000, 10000, -10000, -10000); - dn = drawlookupname(strlen(screenname), screenname); + dn = drawlookupname(jehanne_strlen(screenname), screenname); if(dn == 0) error("draw: cannot happen 2"); if(drawinstall(cl, 0, dn->dimage->image, 0) == 0) @@ -1092,8 +1092,8 @@ drawopen(Chan *c, unsigned long omode) if(di == 0) error("draw: cannot happen 1"); di->vers = dn->vers; - di->name = sqmalloc(strlen(screenname)+1); - strcpy(di->name, screenname); + di->name = sqmalloc(jehanne_strlen(screenname)+1); + jehanne_strcpy(di->name, screenname); di->fromname = dn->dimage; di->fromname->ref++; incref(&cl->r); @@ -1137,7 +1137,7 @@ drawclose(Chan *c) if((c->flag&COPEN) && (decref(&cl->r)==0)){ while(r = cl->refresh){ /* assign = */ cl->refresh = r->next; - free(r); + jehanne_free(r); } /* free names */ for(i=0; islot] = 0; drawflush(); /* to erase visible, now dead windows */ - free(cl); + jehanne_free(cl); } dunlock(); poperror(); @@ -1204,7 +1204,7 @@ drawread(Chan *c, void *a, long n, int64_t off) error(Enodrawimage); i = di->image; } - n = snprint(a, n, + n = jehanne_snprint(a, n, "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d ", cl->clientid, cl->infoid, chantostr(buf, i->chan), (i->flags&Frepl)==Frepl, @@ -1216,18 +1216,18 @@ drawread(Chan *c, void *a, long n, int64_t off) case Qcolormap: drawactive(1); /* to restore map from backup */ - p = malloc(4*12*256+1); + p = jehanne_malloc(4*12*256+1); if(p == 0) error(Enomem); m = 0; for(index = 0; index < 256; index++){ getcolor(index, &red, &green, &blue); - m += snprint((char*)p+m, 4*12*256+1 - m, + m += jehanne_snprint((char*)p+m, 4*12*256+1 - m, "%11d %11lud %11lud %11lud\n", index, red>>24, green>>24, blue>>24); } n = readstr(offset, a, n, (char*)p); - free(p); + jehanne_free(p); break; case Qdata: @@ -1236,8 +1236,8 @@ drawread(Chan *c, void *a, long n, int64_t off) if(n < cl->nreaddata) error(Eshortread); n = cl->nreaddata; - memmove(a, cl->readdata, cl->nreaddata); - free(cl->readdata); + jehanne_memmove(a, cl->readdata, cl->nreaddata); + jehanne_free(cl->readdata); cl->readdata = nil; break; @@ -1265,7 +1265,7 @@ drawread(Chan *c, void *a, long n, int64_t off) BPLONG(p+3*4, r->r.max.x); BPLONG(p+4*4, r->r.max.y); cl->refresh = r->next; - free(r); + jehanne_free(r); p += 5*4; n -= 5*4; } @@ -1322,7 +1322,7 @@ drawwrite(Chan *c, void *a, long n, int64_t nn) x = m; if(x > sizeof(buf)-1) x = sizeof(buf)-1; - q = memccpy(buf, a, '\n', x); + q = jehanne_memccpy(buf, a, '\n', x); if(q == 0) break; i = q-buf; @@ -1330,12 +1330,12 @@ drawwrite(Chan *c, void *a, long n, int64_t nn) a = (char*)a + i; m -= i; *q = 0; - if(tokenize(buf, fields, nelem(fields)) != 4) + if(jehanne_tokenize(buf, fields, nelem(fields)) != 4) error(Ebadarg); - i = strtoul(fields[0], 0, 0); - red = strtoul(fields[1], 0, 0); - green = strtoul(fields[2], 0, 0); - blue = strtoul(fields[3], &q, 0); + i = jehanne_strtoul(fields[0], 0, 0); + red = jehanne_strtoul(fields[1], 0, 0); + green = jehanne_strtoul(fields[2], 0, 0); + blue = jehanne_strtoul(fields[3], &q, 0); if(fields[3] == q) error(Ebadarg); if(red>255 || green>255 || blue>255 || i<0 || i>255) @@ -1406,31 +1406,31 @@ printmesg(char *fmt, unsigned char *a, int plsprnt) left = sizeof buf - 2 - (q - buf); /* 2 for \n\0 */ switch(*p){ case 'l': - q += snprint(q, left, " %ld", (int32_t)BGLONG(a)); + q += jehanne_snprint(q, left, " %ld", (int32_t)BGLONG(a)); a += 4; break; case 'L': - q += snprint(q, left, " %.8lux", (uint32_t)BGLONG(a)); + q += jehanne_snprint(q, left, " %.8lux", (uint32_t)BGLONG(a)); a += 4; break; case 'R': - q += snprint(q, left, " [%d %d %d %d]", BGLONG(a), + q += jehanne_snprint(q, left, " [%d %d %d %d]", BGLONG(a), BGLONG(a+4), BGLONG(a+8), BGLONG(a+12)); a += 16; break; case 'P': - q += snprint(q, left, " [%d %d]", BGLONG(a), BGLONG(a+4)); + q += jehanne_snprint(q, left, " [%d %d]", BGLONG(a), BGLONG(a+4)); a += 8; break; case 'b': - q += snprint(q, left, " %d", *a++); + q += jehanne_snprint(q, left, " %d", *a++); break; case 's': - q += snprint(q, left, " %d", BGSHORT(a)); + q += jehanne_snprint(q, left, " %d", BGSHORT(a)); a += 2; break; case 'S': - q += snprint(q, left, " %.4ux", BGSHORT(a)); + q += jehanne_snprint(q, left, " %.4ux", BGSHORT(a)); a += 2; break; } @@ -1522,7 +1522,7 @@ drawmesg(Client *client, void *av, int n) if(reffn){ refx = nil; if(reffn == drawrefresh){ - refx = malloc(sizeof(Refx)); + refx = jehanne_malloc(sizeof(Refx)); if(refx == 0){ drawuninstall(client, dstid); error(Edrawmem); @@ -1686,11 +1686,11 @@ drawmesg(Client *client, void *av, int n) ni = BGLONG(a+5); if(ni<=0 || ni>4096) error("bad font size (4096 chars max)"); - free(font->fchar); /* should we complain if non-zero? */ - font->fchar = malloc(ni*sizeof(FChar)); + jehanne_free(font->fchar); /* should we complain if non-zero? */ + font->fchar = jehanne_malloc(ni*sizeof(FChar)); if(font->fchar == 0) error("no memory for font"); - memset(font->fchar, 0, ni*sizeof(FChar)); + jehanne_memset(font->fchar, 0, ni*sizeof(FChar)); font->nfchar = ni; font->ascent = a[9]; continue; @@ -1788,7 +1788,7 @@ drawmesg(Client *client, void *av, int n) di->name = sqmalloc(j+1); di->fromname = dn->dimage; di->fromname->ref++; - memmove(di->name, a+6, j); + jehanne_memmove(di->name, a+6, j); di->name[j] = 0; client->infoid = dstid; continue; @@ -1880,7 +1880,7 @@ drawmesg(Client *client, void *av, int n) drawpoint(&sp, a+23); drawpoint(&p, a+31); ni++; - pp = malloc(ni*sizeof(Point)); + pp = jehanne_malloc(ni*sizeof(Point)); if(pp == nil) error(Enomem); doflush = 0; @@ -1928,7 +1928,7 @@ drawmesg(Client *client, void *av, int n) mempoly(dst, pp, ni, e0, e1, j, src, sp, op); else memfillpoly(dst, pp, ni, e0, src, sp, op); - free(pp); + jehanne_free(pp); m = u-a; continue; @@ -1944,13 +1944,13 @@ drawmesg(Client *client, void *av, int n) error(Ereadoutside); c = bytesperline(r, i->depth); c *= Dy(r); - free(client->readdata); - client->readdata = mallocz(c, 0); + jehanne_free(client->readdata); + client->readdata = jehanne_mallocz(c, 0); if(client->readdata == nil) error("readimage malloc failed"); client->nreaddata = memunload(i, r, client->readdata, c); if(client->nreaddata < 0){ - free(client->readdata); + jehanne_free(client->readdata); client->readdata = nil; error("bad readimage call"); } @@ -2055,11 +2055,11 @@ drawmesg(Client *client, void *av, int n) m += nw*4; if(n < m) error(Eshortdraw); - lp = malloc(nw*sizeof(Memimage*)); + lp = jehanne_malloc(nw*sizeof(Memimage*)); if(lp == 0) error(Enomem); if(waserror()){ - free(lp); + jehanne_free(lp); nexterror(); } for(j=0; jgenbuf, "%dctl", s/2); + jehanne_sprint(up->genbuf, "%dctl", s/2); }else{ p = perm[f->mode&7]; - sprint(up->genbuf, "%d", s/2); + jehanne_sprint(up->genbuf, "%d", s/2); } mkqid(&q, s+1, 0, QTFILE); devdir(c, q, up->genbuf, 0, eve, p, dp); diff --git a/sys/src/kern/port/devenv.c b/sys/src/kern/port/devenv.c index dd78473..0f81e15 100644 --- a/sys/src/kern/port/devenv.c +++ b/sys/src/kern/port/devenv.c @@ -23,7 +23,7 @@ envlookup(Egrp *eg, char *name, uint32_t qidpath) for(i=0; inent; i++){ e = eg->ent[i]; - if(e->qid.path == qidpath || (name && e->name[0]==name[0] && strcmp(e->name, name) == 0)) + if(e->qid.path == qidpath || (name && e->name[0]==name[0] && jehanne_strcmp(e->name, name) == 0)) return e; } return nil; @@ -47,7 +47,7 @@ envgen(Chan *c, char *name, Dirtab* _1, int _2, int s, Dir *dp) else if(s < eg->nent) e = eg->ent[s]; - if(e == nil || name != nil && (strlen(e->name) >= sizeof(up->genbuf))) { + if(e == nil || name != nil && (jehanne_strlen(e->name) >= sizeof(up->genbuf))) { runlock(&eg->rwl); return -1; } @@ -65,7 +65,7 @@ envattach(Chan *c, Chan *ac, char *spec, int flags) Egrp *egrp = nil; if(spec && *spec) { - if(strcmp(spec, "c") != 0) + if(jehanne_strcmp(spec, "c") != 0) error(Ebadarg); egrp = &confegrp; } @@ -119,7 +119,7 @@ envopen(Chan *c, unsigned long omode) } if(trunc && e->value) { e->qid.vers++; - free(e->value); + jehanne_free(e->value); e->value = nil; e->len = 0; } @@ -159,15 +159,15 @@ envcreate(Chan *c, char *name, unsigned long omode, unsigned long _1) error(Eexist); e = smalloc(sizeof(Evalue)); - e->name = smalloc(strlen(name)+1); - strcpy(e->name, name); + e->name = smalloc(jehanne_strlen(name)+1); + jehanne_strcpy(e->name, name); if(eg->nent == eg->ment){ eg->ment += 32; ent = smalloc(sizeof(eg->ent[0])*eg->ment); if(eg->nent) - memmove(ent, eg->ent, sizeof(eg->ent[0])*eg->nent); - free(eg->ent); + jehanne_memmove(ent, eg->ent, sizeof(eg->ent[0])*eg->nent); + jehanne_free(eg->ent); eg->ent = ent; } e->qid.path = ++eg->path; @@ -215,9 +215,9 @@ envremove(Chan *c) wunlock(&eg->rwl); if(e == nil) error(Enonexist); - free(e->name); - free(e->value); - free(e); + jehanne_free(e->name); + jehanne_free(e->value); + jehanne_free(e); } static void @@ -264,7 +264,7 @@ envread(Chan *c, void *a, long n, int64_t off) if(n <= 0) n = 0; else - memmove(a, e->value+offset, n); + jehanne_memmove(a, e->value+offset, n); runlock(&eg->rwl); return n; } @@ -295,13 +295,13 @@ envwrite(Chan *c, void *a, long n, int64_t off) if(len > e->len) { s = smalloc(len); if(e->value){ - memmove(s, e->value, e->len); - free(e->value); + jehanne_memmove(s, e->value, e->len); + jehanne_free(e->value); } e->value = s; e->len = len; } - memmove(e->value+offset, a, n); + jehanne_memmove(e->value+offset, a, n); e->qid.vers++; eg->vers++; wunlock(&eg->rwl); @@ -341,11 +341,11 @@ envcpy(Egrp *to, Egrp *from) for(i=0; inent; i++){ e = from->ent[i]; ne = smalloc(sizeof(Evalue)); - ne->name = smalloc(strlen(e->name)+1); - strcpy(ne->name, e->name); + ne->name = smalloc(jehanne_strlen(e->name)+1); + jehanne_strcpy(ne->name, e->name); if(e->value){ ne->value = smalloc(e->len); - memmove(ne->value, e->value, e->len); + jehanne_memmove(ne->value, e->value, e->len); ne->len = e->len; } ne->qid.path = ++to->path; @@ -364,12 +364,12 @@ closeegrp(Egrp *eg) if(decref(&eg->r) == 0 && eg != &confegrp){ for(i=0; inent; i++){ e = eg->ent[i]; - free(e->name); - free(e->value); - free(e); + jehanne_free(e->name); + jehanne_free(e->value); + jehanne_free(e); } - free(eg->ent); - free(eg); + jehanne_free(eg->ent); + jehanne_free(eg); } } @@ -396,9 +396,9 @@ ksetenv(char *ename, char *eval, int conf) Chan *c; char buf[2*KNAMELEN]; - snprint(buf, sizeof(buf), "#e%s/%s", conf?"c":"", ename); + jehanne_snprint(buf, sizeof(buf), "#e%s/%s", conf?"c":"", ename); c = namec(buf, Acreate, OWRITE, 0600); - c->dev->write(c, eval, strlen(eval), 0); + c->dev->write(c, eval, jehanne_strlen(eval), 0); cclose(c); } @@ -425,20 +425,20 @@ getconfenv(void) n = 0; for(i=0; inent; i++){ e = eg->ent[i]; - n += strlen(e->name) + e->len + 2; + n += jehanne_strlen(e->name) + e->len + 2; } - p = malloc(n + 1); + p = jehanne_malloc(n + 1); if(p == nil) error(Enomem); q = p; for(i=0; inent; i++){ e = eg->ent[i]; - strcpy(q, e->name); - q += strlen(q) + 1; - memmove(q, e->value, e->len); + jehanne_strcpy(q, e->name); + q += jehanne_strlen(q) + 1; + jehanne_memmove(q, e->value, e->len); q[e->len] = 0; /* move up to the first null */ - q += strlen(q) + 1; + q += jehanne_strlen(q) + 1; } *q = 0; diff --git a/sys/src/kern/port/devfs.c b/sys/src/kern/port/devfs.c index fd334d4..8d83b10 100644 --- a/sys/src/kern/port/devfs.c +++ b/sys/src/kern/port/devfs.c @@ -96,7 +96,7 @@ struct Tree uint32_t nadevs; /* number of allocated devices in devs */ }; -#define dprint if(debug)print +#define dprint if(debug)jehanne_print extern Dev fsdevtab; /* forward */ @@ -144,25 +144,25 @@ seprintdev(char *s, char *e, Fsdev *mp) int i; if(mp == nil) - return seprint(s, e, ""); + return jehanne_seprint(s, e, ""); if(mp->type < 0 || mp->type >= nelem(tnames) || tnames[mp->type] == nil) - return seprint(s, e, "bad device type %d\n", mp->type); + return jehanne_seprint(s, e, "bad device type %d\n", mp->type); - s = strecpy(s, e, tnames[mp->type]); + s = jehanne_strecpy(s, e, tnames[mp->type]); if(mp->tree != &fstree) - s = seprint(s, e, " %s/%s", mp->tree->name, mp->name); + s = jehanne_seprint(s, e, " %s/%s", mp->tree->name, mp->name); else - s = seprint(s, e, " %s", mp->name); + s = jehanne_seprint(s, e, " %s", mp->name); for(i = 0; i < mp->ndevs; i++) - s = seprint(s, e, " %s", mp->inner[i]->iname); + s = jehanne_seprint(s, e, " %s", mp->inner[i]->iname); switch(mp->type){ case Fmirror: case Fcat: case Finter: - s = strecpy(s, e, "\n"); + s = jehanne_strecpy(s, e, "\n"); break; case Fpart: - s = seprint(s, e, " %ulld %ulld\n", mp->start, mp->size); + s = jehanne_seprint(s, e, " %ulld %ulld\n", mp->start, mp->size); break; default: panic("#k: seprintdev bug"); @@ -238,7 +238,7 @@ treealloc(char *name) break; if(i == nelem(trees)) return nil; - t = trees[i] = mallocz(sizeof(Tree), 1); + t = trees[i] = jehanne_mallocz(sizeof(Tree), 1); if(t == nil) return nil; if(i == ntrees) @@ -254,7 +254,7 @@ lookuptree(char *name) dprint("lookuptree %s\n", name); for(i = 0; i < ntrees; i++) - if(trees[i] != nil && strcmp(trees[i]->name, name) == 0) + if(trees[i] != nil && jehanne_strcmp(trees[i]->name, name) == 0) return trees[i]; return nil; } @@ -266,7 +266,7 @@ devalloc(Tree *t, char *name) Fsdev *mp, **devs; dprint("devalloc %s %s\n", t->name, name); - mp = mallocz(sizeof(Fsdev), 1); + mp = jehanne_mallocz(sizeof(Fsdev), 1); if(mp == nil) return nil; for(i = 0; i < t->nadevs; i++) @@ -275,9 +275,9 @@ devalloc(Tree *t, char *name) if(i >= t->nadevs){ if(t->nadevs % Incr == 0){ ndevs = t->nadevs + Incr; - devs = realloc(t->devs, ndevs * sizeof(Fsdev*)); + devs = jehanne_realloc(t->devs, ndevs * sizeof(Fsdev*)); if(devs == nil){ - free(mp); + jehanne_free(mp); return nil; } t->devs = devs; @@ -302,9 +302,9 @@ deltree(Tree *t) for(i = 0; i < ntrees; i++) if(trees[i] == t){ if(i > 0){ /* "fs" never goes away */ - free(t->name); - free(t->devs); - free(t); + jehanne_free(t->name); + jehanne_free(t->devs); + jehanne_free(t); trees[i] = nil; } return; @@ -341,17 +341,17 @@ mdeldev(Fsdev *mp) } wunlock(&lck); - free(mp->name); + jehanne_free(mp->name); for(i = 0; i < mp->ndevs; i++){ in = mp->inner[i]; if(in->idev != nil) cclose(in->idev); - free(in->iname); - free(in); + jehanne_free(in->iname); + jehanne_free(in); } if(debug) - memset(mp, 9, sizeof *mp); /* poison */ - free(mp); + jehanne_memset(mp, 9, sizeof *mp); /* poison */ + jehanne_free(mp); } /* @@ -365,8 +365,8 @@ mdelctl(char *tname, char *dname) Tree *t; dprint("delctl %s\n", dname); - alldevs = strcmp(dname, "*") == 0; - alltrees = strcmp(tname, "*") == 0; + alldevs = jehanne_strcmp(dname, "*") == 0; + alltrees = jehanne_strcmp(tname, "*") == 0; some = 0; Again: wlock(&lck); @@ -374,13 +374,13 @@ Again: t = trees[i]; if(t == nil) continue; - if(alltrees == 0 && strcmp(t->name, tname) != 0) + if(alltrees == 0 && jehanne_strcmp(t->name, tname) != 0) continue; for(i = 0; i < t->nadevs; i++){ mp = t->devs[i]; if(t->devs[i] == nil) continue; - if(alldevs == 0 && strcmp(mp->name, dname) != 0) + if(alldevs == 0 && jehanne_strcmp(mp->name, dname) != 0) continue; /* * Careful: must close outside locks and that @@ -431,7 +431,7 @@ setdsize(Fsdev* mp, int64_t *ilen) if(mp->start > inlen) error("partition starts after device end"); if(inlen < mp->start + mp->size){ - print("#k: %s: partition truncated from " + jehanne_print("#k: %s: partition truncated from " "%lld to %lld bytes\n", mp->name, mp->size, inlen - mp->start); mp->size = inlen - mp->start; @@ -449,7 +449,7 @@ validdevname(Tree *t, char *dname) int i; for(i = 0; i < t->nadevs; i++) - if(t->devs[i] != nil && strcmp(t->devs[i]->name, dname) == 0) + if(t->devs[i] != nil && jehanne_strcmp(t->devs[i]->name, dname) == 0) error(Eexist); } @@ -489,7 +489,7 @@ parsename(char *name, char *disk, char **tree, char **dev) { char *slash; - slash = strchr(name, '/'); + slash = jehanne_strchr(name, '/'); if(slash == nil){ if(disk != nil) *tree = disk; @@ -515,7 +515,7 @@ getattrs(Chan *c, int64_t *lenp, int *permp) *lenp = 0; *permp = 0; l = c->dev->stat(c, buf, sizeof buf); - if (l >= 0 && convM2D(buf, l, &d, nil) > 0) { + if (l >= 0 && jehanne_convM2D(buf, l, &d, nil) > 0) { *lenp = d.length; *permp = d.mode & 0777; } @@ -559,7 +559,7 @@ mconfig(char* a, long n) iperm = nil; if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } @@ -568,21 +568,21 @@ mconfig(char* a, long n) case Fdisk: kstrdup(&disk, cb->f[0]); if(cb->nf >= 2) - sectorsz = strtoul(cb->f[1], 0, 0); + sectorsz = jehanne_strtoul(cb->f[1], 0, 0); else sectorsz = Sectorsz; if(cb->nf == 3) kstrdup(&source, cb->f[2]); else{ - free(source); + jehanne_free(source); source = nil; } poperror(); - free(cb); + jehanne_free(cb); return; case Fclear: poperror(); - free(cb); + jehanne_free(cb); mdelctl("*", "*"); /* del everything */ return; case Fpart: @@ -599,8 +599,8 @@ mconfig(char* a, long n) cb->f = fakef; cb->nf = 4; } - start = strtoll(cb->f[2], nil, 10); - size = strtoll(cb->f[3], nil, 10); + start = jehanne_strtoll(cb->f[2], nil, 10); + size = jehanne_strtoll(cb->f[3], nil, 10); if(cb->f == fakef) size -= start; /* it was end */ cb->nf -= 2; @@ -613,7 +613,7 @@ mconfig(char* a, long n) if(ct->index == Fdel){ mdelctl(tname, dname); poperror(); - free(cb); + jehanne_free(cb); return; } @@ -630,10 +630,10 @@ Fail: cclose(idev[i-1]); if(mp != nil) mdeldev(mp); - free(idev); - free(ilen); - free(iperm); - free(cb); + jehanne_free(idev); + jehanne_free(ilen); + jehanne_free(iperm); + jehanne_free(cb); nexterror(); } /* record names, lengths and perms of all named files */ @@ -678,7 +678,7 @@ Fail: } mp->perm = 0666; for(i = 1; i < cb->nf; i++){ - inprv = mp->inner[i-1] = mallocz(sizeof(Inner), 1); + inprv = mp->inner[i-1] = jehanne_mallocz(sizeof(Inner), 1); if(inprv == nil) error(Enomem); mp->ndevs++; @@ -692,10 +692,10 @@ Fail: poperror(); wunlock(&lck); - free(idev); - free(ilen); - free(iperm); - free(cb); + jehanne_free(idev); + jehanne_free(ilen); + jehanne_free(iperm); + jehanne_free(cb); } static void @@ -732,7 +732,7 @@ rdconf(void) if (cc != nil) cclose(cc); if (c) - free(c); + jehanne_free(c); if (!mustrd) return; nexterror(); @@ -743,16 +743,16 @@ rdconf(void) cc = nil; /* validate, copy and erase config; mconfig will repopulate confstr */ - if (strncmp(confstr, cfgstr, sizeof cfgstr - 1) != 0) + if (jehanne_strncmp(confstr, cfgstr, sizeof cfgstr - 1) != 0) error("bad #k config, first line must be: 'fsdev:\\n'"); kstrdup(&c, confstr + sizeof cfgstr - 1); - memset(confstr, 0, sizeof confstr); + jehanne_memset(confstr, 0, sizeof confstr); /* process config copy one line at a time */ for (p = c; p != nil && *p != '\0'; p = e){ - e = strchr(p, '\n'); + e = jehanne_strchr(p, '\n'); if (e == nil) - e = p + strlen(p); + e = p + jehanne_strlen(p); else e++; mconfig(p, e - p); @@ -869,7 +869,7 @@ mstat(Chan *c, uint8_t *db, long n) nexterror(); } p = c->qid.path; - memset(&d, 0, sizeof d); + jehanne_memset(&d, 0, sizeof d); switch(p){ case Qtop: devdir(c, tqid, "#k", 0, eve, DMDIR|0775, &d); @@ -888,7 +888,7 @@ mstat(Chan *c, uint8_t *db, long n) devdir(c, q, mp->name, mp->size, eve, mp->perm, &d); } } - n = convD2M(&d, db, n); + n = jehanne_convD2M(&d, db, n); if (n == 0) error(Ebadarg); poperror(); @@ -948,9 +948,9 @@ mclose(Chan *c) mp = nil; q = c->qid.path; if(q == Qctl){ - free(disk); + jehanne_free(disk); disk = nil; /* restore defaults */ - free(source); + jehanne_free(source); source = nil; sectorsz = Sectorsz; }else{ @@ -976,7 +976,7 @@ io(Fsdev *mp, Inner *in, int isread, void *a, long l, int64_t off) if(mc == nil) error(Egone); if (waserror()) { - print("#k: %s: byte %,lld count %ld (of #k/%s): %s error: %s\n", + jehanne_print("#k: %s: byte %,lld count %ld (of #k/%s): %s error: %s\n", in->iname, off, l, mp->name, (isread? "read": "write"), (up && up->errstr? up->errstr: "")); nexterror(); @@ -998,7 +998,7 @@ catio(Fsdev *mp, int isread, void *a, long n, int64_t off) Inner *in; if(debug) - print("catio %d %p %ld %lld\n", isread, a, n, off); + jehanne_print("catio %d %p %ld %lld\n", isread, a, n, off); res = n; for (i = 0; n > 0 && i < mp->ndevs; i++){ in = mp->inner[i]; @@ -1011,7 +1011,7 @@ catio(Fsdev *mp, int isread, void *a, long n, int64_t off) else l = n; if(debug) - print("\tdev %d %p %ld %lld\n", i, a, l, off); + jehanne_print("\tdev %d %p %ld %lld\n", i, a, l, off); if (io(mp, in, isread, a, l, off) != l) error(Eio); @@ -1021,7 +1021,7 @@ catio(Fsdev *mp, int isread, void *a, long n, int64_t off) n -= l; } if(debug) - print("\tres %ld\n", res - n); + jehanne_print("\tres %ld\n", res - n); return res - n; } @@ -1128,7 +1128,7 @@ mread(Chan *c, void *a, long n, int64_t off) retry = 0; do { if (retry > 0) { - print("#k/%s: retry %d read for byte %,lld " + jehanne_print("#k/%s: retry %d read for byte %,lld " "count %ld: %s\n", mp->name, retry, off, n, (up && up->errstr? up->errstr: "")); /* @@ -1150,12 +1150,12 @@ mread(Chan *c, void *a, long n, int64_t off) } while (i == mp->ndevs && ++retry <= Maxretries); if (retry > Maxretries) { /* no mirror had a good copy of the block */ - print("#k/%s: byte %,lld count %ld: CAN'T READ " + jehanne_print("#k/%s: byte %,lld count %ld: CAN'T READ " "from mirror: %s\n", mp->name, off, n, (up && up->errstr? up->errstr: "")); error(Eio); } else if (retry > 0) - print("#k/%s: byte %,lld count %ld: retry read OK " + jehanne_print("#k/%s: byte %,lld count %ld: retry read OK " "from mirror: %s\n", mp->name, off, n, (up && up->errstr? up->errstr: "")); break; @@ -1218,7 +1218,7 @@ mwrite(Chan *c, void *a, long n, int64_t off) retry = 0; do { if (retry > 0) { - print("#k/%s: retry %d write for byte %,lld " + jehanne_print("#k/%s: retry %d write for byte %,lld " "count %ld: %s\n", mp->name, retry, off, n, (up && up->errstr? up->errstr: "")); /* @@ -1244,12 +1244,12 @@ mwrite(Chan *c, void *a, long n, int64_t off) } while (anybad && ++retry <= Maxretries); if (allbad) { /* no mirror took a good copy of the block */ - print("#k/%s: byte %,lld count %ld: CAN'T WRITE " + jehanne_print("#k/%s: byte %,lld count %ld: CAN'T WRITE " "to mirror: %s\n", mp->name, off, n, (up && up->errstr? up->errstr: "")); error(Eio); } else if (retry > 0) - print("#k/%s: byte %,lld count %ld: retry wrote OK " + jehanne_print("#k/%s: byte %,lld count %ld: retry wrote OK " "to mirror: %s\n", mp->name, off, n, (up && up->errstr? up->errstr: "")); diff --git a/sys/src/kern/port/devkprof.c b/sys/src/kern/port/devkprof.c index 608fce4..6c68dda 100644 --- a/sys/src/kern/port/devkprof.c +++ b/sys/src/kern/port/devkprof.c @@ -69,7 +69,7 @@ kprofattach(Chan *c, Chan *ac, char *spec, int flags) kprof.nbuf = (kprof.maxpc-kprof.minpc) >> LRES; n = kprof.nbuf*SZ; if(kprof.buf == 0) { - kprof.buf = malloc(n); + kprof.buf = jehanne_malloc(n); if(kprof.buf == 0) error(Enomem); } @@ -154,12 +154,12 @@ kprofwrite(Chan *c, void *a, long n, int64_t _1) { switch((int)(c->qid.path)){ case Kprofctlqid: - if(strncmp(a, "startclr", 8) == 0){ - memset((char *)kprof.buf, 0, kprof.nbuf*SZ); + if(jehanne_strncmp(a, "startclr", 8) == 0){ + jehanne_memset((char *)kprof.buf, 0, kprof.nbuf*SZ); kprof.time = 1; - }else if(strncmp(a, "start", 5) == 0) + }else if(jehanne_strncmp(a, "start", 5) == 0) kprof.time = 1; - else if(strncmp(a, "stop", 4) == 0) + else if(jehanne_strncmp(a, "stop", 4) == 0) kprof.time = 0; break; default: diff --git a/sys/src/kern/port/devmem.c b/sys/src/kern/port/devmem.c index 6fbc502..c62a720 100644 --- a/sys/src/kern/port/devmem.c +++ b/sys/src/kern/port/devmem.c @@ -307,19 +307,19 @@ memwrite(Chan *c, void *a, long n, int64_t) case Qctl: cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } - if(cb->nf == 1 && strcmp(cb->f[0], "start") == 0){ + if(cb->nf == 1 && jehanne_strcmp(cb->f[0], "start") == 0){ if(incref(&monitoring) == 1) setmemprof(mprofmonitor); - }else if(cb->nf == 1 && strcmp(cb->f[0], "stop") == 0){ + }else if(cb->nf == 1 && jehanne_strcmp(cb->f[0], "stop") == 0){ if(decref(&monitoring) == 0) setmemprof(nil); }else cmderror(cb, "unknown command"); poperror(); - free(cb); + jehanne_free(cb); break; } return n; diff --git a/sys/src/kern/port/devmem1.c b/sys/src/kern/port/devmem1.c index e4a1e45..0ecd381 100644 --- a/sys/src/kern/port/devmem1.c +++ b/sys/src/kern/port/devmem1.c @@ -332,19 +332,19 @@ memwrite(Chan *c, void *a, long n, int64_t) case Qctl: cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } - if(cb->nf == 1 && strcmp(cb->f[0], "start") == 0){ + if(cb->nf == 1 && jehanne_strcmp(cb->f[0], "start") == 0){ if(incref(&monitoring) == 1) setmemprof(mprofmonitor); - }else if(cb->nf == 1 && strcmp(cb->f[0], "stop") == 0){ + }else if(cb->nf == 1 && jehanne_strcmp(cb->f[0], "stop") == 0){ if(decref(&monitoring) == 0) setmemprof(nil); }else cmderror(cb, "unknown command"); poperror(); - free(cb); + jehanne_free(cb); break; } return n; diff --git a/sys/src/kern/port/devmouse.c b/sys/src/kern/port/devmouse.c index 48743dc..3fc30c7 100644 --- a/sys/src/kern/port/devmouse.c +++ b/sys/src/kern/port/devmouse.c @@ -261,8 +261,8 @@ mouseread(Chan *c, void *va, long n, int64_t off) lock(&cursor.l); BPLONG(p+0, curs.offset.x); BPLONG(p+4, curs.offset.y); - memmove(p+8, curs.clr, 2*16); - memmove(p+40, curs.set, 2*16); + jehanne_memmove(p+8, curs.clr, 2*16); + jehanne_memmove(p+40, curs.set, 2*16); unlock(&cursor.l); return n; @@ -301,7 +301,7 @@ mouseread(Chan *c, void *va, long n, int64_t off) b = 16; else if (b == 16) b = 8; - snprint(buf, sizeof buf, "m%11d %11d %11d %11lud ", + jehanne_snprint(buf, sizeof buf, "m%11d %11d %11d %11lud ", m.xy.x, m.xy.y, b, m.msec); @@ -312,7 +312,7 @@ mouseread(Chan *c, void *va, long n, int64_t off) mouse.lastresize = mouse.resize; buf[0] = 'r'; } - memmove(va, buf, n); + jehanne_memmove(va, buf, n); return n; } return 0; @@ -348,7 +348,7 @@ setbuttonmap(char* map) if(map[i]) error(Ebadarg); - memset(buttonmap, 0, 8); + jehanne_memset(buttonmap, 0, 8); for(i = 0; i < 8; i++){ x = 0; if(i & 1) @@ -385,8 +385,8 @@ mousewrite(Chan *c, void *va, long n, int64_t r) n = 2*4+2*2*16; curs.offset.x = BGLONG(p+0); curs.offset.y = BGLONG(p+4); - memmove(curs.clr, p+8, 2*16); - memmove(curs.set, p+40, 2*16); + jehanne_memmove(curs.clr, p+8, 2*16); + jehanne_memmove(curs.set, p+40, 2*16); Cursortocursor(&curs); } qlock(&mouse.ql); @@ -399,7 +399,7 @@ mousewrite(Chan *c, void *va, long n, int64_t r) case Qmousectl: cb = parsecmd(va, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } @@ -430,24 +430,24 @@ mousewrite(Chan *c, void *va, long n, int64_t r) break; } - free(cb); + jehanne_free(cb); poperror(); return n; case Qmousein: if(n > sizeof buf-1) n = sizeof buf -1; - memmove(buf, va, n); + jehanne_memmove(buf, va, n); buf[n] = 0; p = 0; - pt.x = strtol(buf+1, &p, 0); + pt.x = jehanne_strtol(buf+1, &p, 0); if(p == 0) error(Eshort); - pt.y = strtol(p, &p, 0); + pt.y = jehanne_strtol(p, &p, 0); if(p == 0) error(Eshort); - b = strtol(p, &p, 0); - msec = strtol(p, &p, 0); + b = jehanne_strtol(p, &p, 0); + msec = jehanne_strtol(p, &p, 0); if(msec == 0) msec = TK2MS(sys->ticks); mousetrack(pt.x, pt.y, b, msec); @@ -456,13 +456,13 @@ mousewrite(Chan *c, void *va, long n, int64_t r) case Qmouse: if(n > sizeof buf-1) n = sizeof buf -1; - memmove(buf, va, n); + jehanne_memmove(buf, va, n); buf[n] = 0; p = 0; - pt.x = strtoul(buf+1, &p, 0); + pt.x = jehanne_strtoul(buf+1, &p, 0); if(p == 0) error(Eshort); - pt.y = strtoul(p, 0, 0); + pt.y = jehanne_strtoul(p, 0, 0); qlock(&mouse.ql); if(ptinrect(pt, gscreen->r)){ mouse.xy = pt; @@ -503,7 +503,7 @@ void Cursortocursor(Cursor *c) { lock(&cursor.l); - memmove(&cursor.c, c, sizeof(Cursor)); + jehanne_memmove(&cursor.c, c, sizeof(Cursor)); setcursor(c); unlock(&cursor.l); } diff --git a/sys/src/kern/port/devpci.c b/sys/src/kern/port/devpci.c index 23c4c90..091b400 100644 --- a/sys/src/kern/port/devpci.c +++ b/sys/src/kern/port/devpci.c @@ -43,11 +43,11 @@ pcigen2(Chan *c, int t, int tbdf, Dir *dp) q = (Qid){BUSBDF(tbdf)|t, 0, 0}; switch(t) { case Qpcictl: - snprint(up->genbuf, sizeof(up->genbuf), "%d.%d.%dctl", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d.%d.%dctl", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); devdir(c, q, up->genbuf, 0, eve, 0444, dp); return 1; case Qpciraw: - snprint(up->genbuf, sizeof(up->genbuf), "%d.%d.%draw", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d.%d.%draw", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); devdir(c, q, up->genbuf, 128, eve, 0444, dp); return 1; } @@ -65,7 +65,7 @@ pcigen(Chan *c, char * _1, Dirtab* _2, int _3, int s, Dir *dp) case Qtopdir: if(s == DEVDOTDOT){ q = (Qid){QID(0, Qtopdir), 0, QTDIR}; - snprint(up->genbuf, sizeof(up->genbuf), "#%C", pcidevtab.dc); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "#%C", pcidevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } @@ -73,7 +73,7 @@ pcigen(Chan *c, char * _1, Dirtab* _2, int _3, int s, Dir *dp) case Qpcidir: if(s == DEVDOTDOT){ q = (Qid){QID(0, Qtopdir), 0, QTDIR}; - snprint(up->genbuf, sizeof(up->genbuf), "#%C", pcidevtab.dc); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "#%C", pcidevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } @@ -146,12 +146,12 @@ pciread(Chan *c, void *va, long n, int64_t offset) if(p == nil) error(Egreg); ebuf = buf+sizeof buf-1; /* -1 for newline */ - w = seprint(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d", + w = jehanne_seprint(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d", p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl); for(i=0; imem); i++){ if(p->mem[i].size == 0) continue; - w = seprint(w, ebuf, " %d:%.8lux %d", i, p->mem[i].bar, p->mem[i].size); + w = jehanne_seprint(w, ebuf, " %d:%.8lux %d", i, p->mem[i].bar, p->mem[i].size); } *w++ = '\n'; *w = '\0'; @@ -200,7 +200,7 @@ pciwrite(Chan *c, void *va, long n, int64_t offset) if(n >= sizeof(buf)) n = sizeof(buf)-1; - strncpy(buf, va, n); + jehanne_strncpy(buf, va, n); buf[n] = 0; switch(TYPE(c->qid)){ diff --git a/sys/src/kern/port/devpipe.c b/sys/src/kern/port/devpipe.c index 8f4cb62..7015dd4 100644 --- a/sys/src/kern/port/devpipe.c +++ b/sys/src/kern/port/devpipe.c @@ -52,20 +52,20 @@ pipeattach(Chan *c, Chan *ac, char *spec, int flags) Pipe *p; c = devattach('|', spec); - p = malloc(sizeof(Pipe)); + p = jehanne_malloc(sizeof(Pipe)); if(p == 0) exhausted("memory"); p->ref = 1; p->q[0] = qopen(PIPEQSIZE, 0, 0, 0); if(p->q[0] == 0){ - free(p); + jehanne_free(p); exhausted("memory"); } p->q[1] = qopen(PIPEQSIZE, 0, 0, 0); if(p->q[1] == 0){ - free(p->q[0]); - free(p); + jehanne_free(p->q[0]); + jehanne_free(p); exhausted("memory"); } @@ -125,7 +125,7 @@ pipewalk(Chan *c, Chan *nc, char **name, int nname) qlock(p); p->ref++; if(c->flag & COPEN){ - print("channel open in pipewalk\n"); + jehanne_print("channel open in pipewalk\n"); switch(PIPETYPE(c->qid.path)){ case Qdata0: p->qref[0]++; @@ -161,7 +161,7 @@ pipestat(Chan *c, uint8_t *db, long n) default: panic("pipestat"); } - n = convD2M(&dir, db, n); + n = jehanne_convD2M(&dir, db, n); if(n < BIT16SZ) error(Eshortstat); return n; @@ -248,9 +248,9 @@ pipeclose(Chan *c) p->ref--; if(p->ref == 0){ qunlock(p); - free(p->q[0]); - free(p->q[1]); - free(p); + jehanne_free(p->q[0]); + jehanne_free(p->q[1]); + jehanne_free(p); } else qunlock(p); } @@ -302,7 +302,7 @@ pipewrite(Chan *c, void *va, long n, int64_t _1) Pipe *p; if(!islo()) - print("pipewrite hi %#p\n", getcallerpc()); + jehanne_print("pipewrite hi %#p\n", getcallerpc()); if(waserror()) { /* avoid notes when pipe is a mounted queue */ if((c->flag & CMSG) == 0) diff --git a/sys/src/kern/port/devproc.c b/sys/src/kern/port/devproc.c index 2478e0c..d6b57dc 100644 --- a/sys/src/kern/port/devproc.c +++ b/sys/src/kern/port/devproc.c @@ -182,7 +182,7 @@ procgen(Chan *c, char *name, Dirtab *tab, int _1, int s, Dir *dp) if(c->qid.path == Qdir){ if(s == 0){ - strcpy(up->genbuf, "trace"); + jehanne_strcpy(up->genbuf, "trace"); mkqid(&qid, Qtrace, -1, QTFILE); devdir(c, qid, up->genbuf, 0, eve, 0444, dp); return 1; @@ -190,7 +190,7 @@ procgen(Chan *c, char *name, Dirtab *tab, int _1, int s, Dir *dp) if(name != nil){ /* ignore s and use name to find pid */ - pid = strtol(name, &ename, 10); + pid = jehanne_strtol(name, &ename, 10); if(pid<=0 || ename[0]!='\0') return -1; s = psindex(pid); @@ -202,12 +202,12 @@ procgen(Chan *c, char *name, Dirtab *tab, int _1, int s, Dir *dp) if((p = psincref(s)) == nil || (pid = p->pid) == 0) return 0; - sprint(up->genbuf, "%d", pid); + jehanne_sprint(up->genbuf, "%d", pid); /* * String comparison is done in devwalk so * name must match its formatted pid. */ - if(name != nil && strcmp(name, up->genbuf) != 0) + if(name != nil && jehanne_strcmp(name, up->genbuf) != 0) return -1; mkqid(&qid, (s+1)<genbuf, 0, p->user, DMDIR|0555, dp); @@ -215,7 +215,7 @@ procgen(Chan *c, char *name, Dirtab *tab, int _1, int s, Dir *dp) return 1; } if(c->qid.path == Qtrace){ - strcpy(up->genbuf, "trace"); + jehanne_strcpy(up->genbuf, "trace"); mkqid(&qid, Qtrace, -1, QTFILE); devdir(c, qid, up->genbuf, 0, eve, 0444, dp); return 1; @@ -247,7 +247,7 @@ procgen(Chan *c, char *name, Dirtab *tab, int _1, int s, Dir *dp) /* file length might be relevant to the caller to * malloc enough space in the buffer */ - len = 1 + strlen(p->dot->path->s); + len = 1 + jehanne_strlen(p->dot->path->s); break; } @@ -280,7 +280,7 @@ static void procinit(void) { if(procalloc.nproc >= (1<<(16-QSHIFT))-1) - print("warning: too many procs for devproc\n"); + jehanne_print("warning: too many procs for devproc\n"); addclock0link((void (*)(void))profclock, 113); /* Relative prime to HZ */ } @@ -313,7 +313,7 @@ nonone(Proc *p) { if(p == up) return; - if(strcmp(up->user, "none") != 0) + if(jehanne_strcmp(up->user, "none") != 0) return; if(isevegroup()) return; @@ -343,7 +343,7 @@ procopen(Chan *c, unsigned long omode) error("already open"); topens++; if (tevents == nil){ - tevents = (Traceevent*)malloc(sizeof(Traceevent) * Nevents); + tevents = (Traceevent*)jehanne_malloc(sizeof(Traceevent) * Nevents); if(tevents == nil) error(Enomem); tproduced = tconsumed = 0; @@ -428,7 +428,7 @@ procopen(Chan *c, unsigned long omode) case Qns: if(omode != OREAD) error(Eperm); - c->aux = malloc(sizeof(Mntwalk)); + c->aux = jehanne_malloc(sizeof(Mntwalk)); break; case Qnotepg: @@ -447,7 +447,7 @@ procopen(Chan *c, unsigned long omode) break; if(omode > ORDWR) error(Eperm); - if(strcmp(up->user, p->user) != 0 /* process owner can read/write */ + if(jehanne_strcmp(up->user, p->user) != 0 /* process owner can read/write */ || !iseve() /* host owner can read */ || (omode&OWRITE) != 0) error(Eperm); @@ -498,22 +498,22 @@ procwstat(Chan *c, uint8_t *db, long n) if(waserror()){ qunlock(&p->debug); psdecref(p); - free(d); + jehanne_free(d); nexterror(); } if(p->pid != PID(c->qid)) error(Eprocdied); - if(strcmp(up->user, p->user) != 0 && strcmp(up->user, eve) != 0) + if(jehanne_strcmp(up->user, p->user) != 0 && jehanne_strcmp(up->user, eve) != 0) error(Eperm); d = smalloc(sizeof(Dir)+n); - n = convM2D(db, n, &d[0], (char*)&d[1]); + n = jehanne_convM2D(db, n, &d[0], (char*)&d[1]); if(n == 0) error(Eshortstat); - if(!emptystr(d->uid) && strcmp(d->uid, p->user) != 0){ - if(strcmp(up->user, eve) != 0) + if(!emptystr(d->uid) && jehanne_strcmp(d->uid, p->user) != 0){ + if(jehanne_strcmp(up->user, eve) != 0) error(Eperm); else kstrdup(&p->user, d->uid); @@ -524,7 +524,7 @@ procwstat(Chan *c, uint8_t *db, long n) poperror(); qunlock(&p->debug); psdecref(p); - free(d); + jehanne_free(d); return n; } @@ -536,7 +536,7 @@ procoffset(long offset, char *va, int *np) if(offset > 0) { offset -= *np; if(offset < 0) { - memmove(va, va+*np+offset, -offset); + jehanne_memmove(va, va+*np+offset, -offset); *np = -offset; } else @@ -550,7 +550,7 @@ procqidwidth(Chan *c) { char buf[32]; - return sprint(buf, "%lud", c->qid.vers); + return jehanne_sprint(buf, "%lud", c->qid.vers); } static int @@ -559,7 +559,7 @@ _procfdprint(Chan *c, int fd, int w, char *s, int ns, char * modestr) int n; if(w == 0) w = procqidwidth(c); - n = snprint(s, ns, "%3d %.2s %C %4ud (%.16llux %*lud %.2ux) %5ld %8lld %s\n", + n = jehanne_snprint(s, ns, "%3d %.2s %C %4ud (%.16llux %*lud %.2ux) %5ld %8lld %s\n", fd, &modestr[(c->mode&3)<<1], c->dev->dc, c->devno, @@ -602,7 +602,7 @@ procfds(Proc *p, char *va, int count, long offset) } n = readstr(0, a, count, p->dot->path->s); - n += snprint(a+n, count-n, "\n"); + n += jehanne_snprint(a+n, count-n, "\n"); offset = procoffset(offset, a, &n); /* compute width of qid.path */ w = 0; @@ -633,7 +633,7 @@ procfds(Proc *p, char *va, int count, long offset) qunlock(&p->debug); /* copy result to user space, now that locks are released */ - memmove(va, buf, n); + jehanne_memmove(va, buf, n); return n; } @@ -654,7 +654,7 @@ procclose(Chan * c) break; case Qns: if(c->aux != nil) - free(c->aux); + jehanne_free(c->aux); break; case Qsyscall: if((p = psincref(SLOT(c->qid))) != nil){ @@ -703,8 +703,8 @@ procargs(Proc *p, char *buf, int nbuf) if(args == nil) return 0; if(p->setargs){ - snprint(buf, nbuf, "%s [%s]", p->text, args[0]); - return strlen(buf); + jehanne_snprint(buf, nbuf, "%s [%s]", p->text, args[0]); + return jehanne_strlen(buf); } e = buf + nbuf; @@ -723,7 +723,7 @@ procargs(Proc *p, char *buf, int nbuf) */ page = segment_page(s, USTKTOP - PGSZ); if(page == 0){ - buf = seprint(buf, e, "cannot print args for %s %d: stack gone", p->text, p->pid); + buf = jehanne_seprint(buf, e, "cannot print args for %s %d: stack gone", p->text, p->pid); goto ArgsPrinted; } @@ -734,9 +734,9 @@ procargs(Proc *p, char *buf, int nbuf) break; argaddr = (uintptr_t)args[i]; if(argaddr > USTKTOP || argaddr < USTKTOP - PGSZ || argaddr < (uintptr_t)args[p->nargs-1]){ - buf = seprint(buf, e, i?" *%#p":"*%#p", args[i]); + buf = jehanne_seprint(buf, e, i?" *%#p":"*%#p", args[i]); } else { - buf = seprint(buf, e, i?" %q":"%q", pbase + (argaddr&(PGSZ-1))); + buf = jehanne_seprint(buf, e, i?" %q":"%q", pbase + (argaddr&(PGSZ-1))); } } @@ -789,7 +789,7 @@ procread(Chan *c, void *va, long n, int64_t off) else ne = navail; i = ne * sizeof(Traceevent); - memmove(rptr, &tevents[tconsumed & Emask], i); + jehanne_memmove(rptr, &tevents[tconsumed & Emask], i); tconsumed += ne; rptr += i; @@ -818,7 +818,7 @@ procread(Chan *c, void *va, long n, int64_t off) return 0; if(offset+n > j) n = j-offset; - memmove(va, &up->genbuf[offset], n); + jehanne_memmove(va, &up->genbuf[offset], n); return n; case Qsyscall: @@ -841,7 +841,7 @@ procread(Chan *c, void *va, long n, int64_t off) if(offset < PTR2UINT(end)) { if(offset+n > PTR2UINT(end)) n = PTR2UINT(end) - offset; - memmove(va, UINT2PTR(offset), n); + jehanne_memmove(va, UINT2PTR(offset), n); psdecref(p); return n; } @@ -854,7 +854,7 @@ procread(Chan *c, void *va, long n, int64_t off) /* plimit-1 because plimit might be zero (address space top) */ if(paddr+n >= plimit-1) n = plimit - paddr; - memmove(va, UINT2PTR(offset), n); + jehanne_memmove(va, UINT2PTR(offset), n); psdecref(p); return n; @@ -872,14 +872,14 @@ procread(Chan *c, void *va, long n, int64_t off) if(p->nnote == 0) n = 0; else { - i = strlen(p->note[0].msg) + 1; + i = jehanne_strlen(p->note[0].msg) + 1; if(i > n) i = n; rptr = va; - memmove(rptr, p->note[0].msg, i); + jehanne_memmove(rptr, p->note[0].msg, i); rptr[i-1] = '\0'; p->nnote--; - memmove(p->note, p->note+1, p->nnote*sizeof(Note)); + jehanne_memmove(p->note, p->note+1, p->nnote*sizeof(Note)); n = i; } if(p->nnote == 0) @@ -896,7 +896,7 @@ procread(Chan *c, void *va, long n, int64_t off) } if(offset+n > sizeof(Proc)) n = sizeof(Proc) - offset; - memmove(va, ((char*)p)+offset, n); + jehanne_memmove(va, ((char*)p)+offset, n); psdecref(p); return n; @@ -914,12 +914,12 @@ procread(Chan *c, void *va, long n, int64_t off) } if(offset+n > rsize) n = rsize - offset; - memmove(va, rptr+offset, n); + jehanne_memmove(va, rptr+offset, n); psdecref(p); return n; case Qkregs: - memset(&kur, 0, sizeof(Ureg)); + jehanne_memset(&kur, 0, sizeof(Ureg)); setkernur(&kur, p); rptr = (uint8_t*)&kur; rsize = sizeof(Ureg); @@ -941,8 +941,8 @@ procread(Chan *c, void *va, long n, int64_t off) sps = p->psstate; if(sps == 0) sps = statename[p->state]; - memset(statbuf, ' ', sizeof statbuf); - sprint(statbuf, "%-*.*s%-*.*s%-12.11s", + jehanne_memset(statbuf, ' ', sizeof statbuf); + jehanne_sprint(statbuf, "%-*.*s%-*.*s%-12.11s", KNAMELEN, KNAMELEN-1, p->text, KNAMELEN, KNAMELEN-1, p->user, sps); @@ -972,7 +972,7 @@ procread(Chan *c, void *va, long n, int64_t off) statbuf[j++] = '\n'; if(offset+n > j) n = j-offset; - memmove(va, statbuf+offset, n); + jehanne_memmove(va, statbuf+offset, n); psdecref(p); return n; @@ -982,7 +982,7 @@ procread(Chan *c, void *va, long n, int64_t off) sg = p->seg[i]; if(sg == 0) continue; - j += sprint(statbuf+j, "%-6s %c%c %p %p %4d\n", + j += jehanne_sprint(statbuf+j, "%-6s %c%c %p %p %4d\n", segment_name(sg), !(sg->type&SgWrite) ? 'R' : ' ', (sg->type&SgExecute) ? 'x' : ' ', @@ -996,7 +996,7 @@ procread(Chan *c, void *va, long n, int64_t off) n = j-offset; if(n == 0 && offset == 0) exhausted("segments"); - memmove(va, &statbuf[offset], n); + jehanne_memmove(va, &statbuf[offset], n); return n; case Qwait: @@ -1032,11 +1032,11 @@ procread(Chan *c, void *va, long n, int64_t off) poperror(); qunlock(&p->qwaitr); psdecref(p); - n = snprint(va, n, "%d %lud %lud %lud %q", + n = jehanne_snprint(va, n, "%d %lud %lud %lud %q", wq->w.pid, wq->w.time[TUser], wq->w.time[TSys], wq->w.time[TReal], wq->w.msg); - free(wq); + jehanne_free(wq); return n; case Qns: @@ -1058,21 +1058,21 @@ procread(Chan *c, void *va, long n, int64_t off) mntscan(mw, p); if(mw->mh == 0){ mw->cddone = 1; - i = snprint(va, n, "cd %s\n", p->dot->path->s); + i = jehanne_snprint(va, n, "cd %s\n", p->dot->path->s); poperror(); qunlock(&p->debug); psdecref(p); return i; } int2flag(mw->cm->mflag, flag); - if(strcmp(mw->cm->to->path->s, "#9") == 0){ + if(jehanne_strcmp(mw->cm->to->path->s, "#9") == 0){ srv = srvname(mw->cm->to->mchan); - i = snprint(va, n, "mount %s %s %s %s\n", flag, + i = jehanne_snprint(va, n, "mount %s %s %s %s\n", flag, srv==nil? mw->cm->to->mchan->path->s : srv, mw->mh->from->path->s, mw->cm->spec? mw->cm->spec : ""); - free(srv); + jehanne_free(srv); }else - i = snprint(va, n, "bind %s %s %s\n", flag, + i = jehanne_snprint(va, n, "bind %s %s %s\n", flag, mw->cm->to->path->s, mw->mh->from->path->s); poperror(); qunlock(&p->debug); @@ -1173,17 +1173,17 @@ procwrite(Chan *c, void *va, long n, int64_t off) error(Eshort); if(n >= ERRMAX) error(Etoobig); - memmove(buf, va, n); - args = malloc(sizeof(char*)+n+1); + jehanne_memmove(buf, va, n); + args = jehanne_malloc(sizeof(char*)+n+1); if(args == nil) error(Enomem); args[0] = ((char*)args)+sizeof(char*); - memmove(args[0], buf, n); + jehanne_memmove(args[0], buf, n); l = n; if(args[0][l-1] != 0) args[0][l++] = 0; if(p->setargs) /* setargs == 0 => args in stack from sysexec */ - free(p->args); + jehanne_free(p->args); p->nargs = l; p->args = args; p->setargs = 1; @@ -1219,13 +1219,13 @@ procwrite(Chan *c, void *va, long n, int64_t off) error(Eperm); if(n >= ERRMAX-1) error(Etoobig); - memmove(buf, va, n); + jehanne_memmove(buf, va, n); buf[n] = 0; if(!postnote(p, 0, buf, NUser)) error("note not posted"); break; case Qnoteid: - id = atoi(va); + id = jehanne_atoi(va); if(id == p->pid) { p->noteid = id; break; @@ -1235,7 +1235,7 @@ procwrite(Chan *c, void *va, long n, int64_t off) psdecref(t); continue; } - if(strcmp(p->user, t->user) != 0){ + if(jehanne_strcmp(p->user, t->user) != 0){ psdecref(t); error(Eperm); } @@ -1389,7 +1389,7 @@ procctlreq(Proc *p, char *va, int n) cb = parsecmd(va, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } @@ -1397,7 +1397,7 @@ procctlreq(Proc *p, char *va, int n) switch(ct->index){ case CMclose: - procctlclosefiles(p, 0, atoi(cb->f[1])); + procctlclosefiles(p, 0, jehanne_atoi(cb->f[1])); break; case CMclosefiles: procctlclosefiles(p, 1, 0); @@ -1415,13 +1415,13 @@ procctlreq(Proc *p, char *va, int n) /* obsolete */ break; case CMpri: - pri = atoi(cb->f[1]); + pri = jehanne_atoi(cb->f[1]); if(pri > PriNormal && !iseve()) error(Eperm); procpriority(p, pri, 0); break; case CMfixedpri: - pri = atoi(cb->f[1]); + pri = jehanne_atoi(cb->f[1]); if(pri > PriNormal && !iseve()) error(Eperm); procpriority(p, pri, 1); @@ -1455,7 +1455,7 @@ procctlreq(Proc *p, char *va, int n) procstopwait(p, 0); break; case CMwired: - procwired(p, atoi(cb->f[1])); + procwired(p, jehanne_atoi(cb->f[1])); break; case CMtrace: switch(cb->nf){ @@ -1463,7 +1463,7 @@ procctlreq(Proc *p, char *va, int n) p->trace ^= 1; break; case 2: - p->trace = (atoi(cb->f[1]) != 0); + p->trace = (jehanne_atoi(cb->f[1]) != 0); break; default: error("args"); @@ -1472,7 +1472,7 @@ procctlreq(Proc *p, char *va, int n) } poperror(); - free(cb); + jehanne_free(cb); } static int @@ -1520,10 +1520,10 @@ procctlmemio(Proc *p, uintptr_t offset, int n, void *va, int read) /* caller is reading: the destination buffer is at va * and it can fault if not yet loaded */ - memmove(va, b, n); + jehanne_memmove(va, b, n); } else { /* caller is writing: the source buffer is at va */ - memmove(b, va, n); + jehanne_memmove(b, va, n); } poperror(); page_kunmap(page, &k); diff --git a/sys/src/kern/port/devroot.c b/sys/src/kern/port/devroot.c index 16456df..e7775d3 100644 --- a/sys/src/kern/port/devroot.c +++ b/sys/src/kern/port/devroot.c @@ -63,7 +63,7 @@ addlist(Dirlist *l, char *name, uint8_t *contents, uint32_t len, int perm) panic("too many root files"); l->data[l->ndir] = contents; d = &l->dir[l->ndir]; - strcpy(d->name, name); + jehanne_strcpy(d->name, name); d->length = len; d->perm = perm; d->qid.type = 0; @@ -154,7 +154,7 @@ rootgen(Chan *c, char *name, Dirtab* _1, int _2, int s, Dir *dp) if(t >= l->ndir) return -1; if(t < 0){ -print("rootgen %#llux %d %d\n", c->qid.path, s, t); +jehanne_print("rootgen %#llux %d %d\n", c->qid.path, s, t); panic("whoops"); } d = &l->dir[t]; @@ -222,7 +222,7 @@ rootread(Chan *c, void *buf, long n, int64_t off) return 0; if(offset+n > d->length) n = d->length - offset; - memmove(buf, data+offset, n); + jehanne_memmove(buf, data+offset, n); return n; } diff --git a/sys/src/kern/port/devsd.c b/sys/src/kern/port/devsd.c index 0921651..6a8d8f1 100644 --- a/sys/src/kern/port/devsd.c +++ b/sys/src/kern/port/devsd.c @@ -91,7 +91,7 @@ sdaddpart(SDunit* unit, char* name, uint64_t start, uint64_t end) partno = i; break; } - if(strcmp(name, pp->name) == 0){ + if(jehanne_strcmp(name, pp->name) == 0){ if(pp->start == start && pp->end == end) return; error(Ebadctl); @@ -99,7 +99,7 @@ sdaddpart(SDunit* unit, char* name, uint64_t start, uint64_t end) } } else{ - if((unit->part = malloc(sizeof(SDpart)*SDnpart)) == nil) + if((unit->part = jehanne_malloc(sizeof(SDpart)*SDnpart)) == nil) error(Enomem); unit->npart = SDnpart; partno = 0; @@ -112,10 +112,10 @@ sdaddpart(SDunit* unit, char* name, uint64_t start, uint64_t end) if(partno == -1){ if(unit->npart >= NPart) error(Enomem); - if((pp = malloc(sizeof(SDpart)*(unit->npart+SDnpart))) == nil) + if((pp = jehanne_malloc(sizeof(SDpart)*(unit->npart+SDnpart))) == nil) error(Enomem); - memmove(pp, unit->part, sizeof(SDpart)*unit->npart); - free(unit->part); + jehanne_memmove(pp, unit->part, sizeof(SDpart)*unit->npart); + jehanne_free(unit->part); unit->part = pp; partno = unit->npart; unit->npart += SDnpart; @@ -147,13 +147,13 @@ sddelpart(SDunit* unit, char* name) */ pp = unit->part; for(i = 0; i < unit->npart; i++){ - if(strcmp(name, pp->name) == 0) + if(jehanne_strcmp(name, pp->name) == 0) break; pp++; } if(i >= unit->npart) error(Ebadctl); - if(strcmp(up->user, pp->user) && !iseve()) + if(jehanne_strcmp(up->user, pp->user) && !iseve()) error(Eperm); pp->valid = 0; pp->vers++; @@ -212,16 +212,16 @@ sdinitpart(SDunit* unit) * partitions will have the null-string for user. * The gen functions patch it up. */ - snprint(buf, sizeof buf, "%spart", unit->name); + jehanne_snprint(buf, sizeof buf, "%spart", unit->name); for(p = getconf(buf); p != nil; p = q){ - if(q = strchr(p, '/')) + if(q = jehanne_strchr(p, '/')) *q++ = '\0'; - nf = tokenize(p, f, nelem(f)); + nf = jehanne_tokenize(p, f, nelem(f)); if(nf < 3) continue; - start = strtoull(f[1], 0, 0); - end = strtoull(f[2], 0, 0); + start = jehanne_strtoull(f[1], 0, 0); + end = jehanne_strtoull(f[2], 0, 0); if(!waserror()){ sdaddpart(unit, f[0], start, end); poperror(); @@ -237,7 +237,7 @@ sdindex(int idno) { char *p; - p = strchr(devletters, idno); + p = jehanne_strchr(devletters, idno); if(p == nil) return -1; return p-devletters; @@ -287,13 +287,13 @@ sdgetunit(SDev* sdev, int subno) qunlock(&sdev->unitlock); return nil; } - if((unit = malloc(sizeof(SDunit))) == nil){ + if((unit = jehanne_malloc(sizeof(SDunit))) == nil){ qunlock(&sdev->unitlock); return nil; } sdev->unitflg[subno] = 1; - snprint(buf, sizeof(buf), "%s%d", sdev->name, subno); + jehanne_snprint(buf, sizeof(buf), "%s%d", sdev->name, subno); kstrdup(&unit->name, buf); kstrdup(&unit->user, eve); unit->perm = 0555; @@ -311,7 +311,7 @@ sdgetunit(SDev* sdev, int subno) */ if(unit->dev->ifc->verify(unit) == 0){ qunlock(&sdev->unitlock); - free(unit); + jehanne_free(unit); return nil; } sdev->unit[subno] = unit; @@ -345,21 +345,21 @@ sdadddevs(SDev *sdev) for(; sdev; sdev=next){ next = sdev->next; - sdev->unit = (SDunit**)malloc(sdev->nunit * sizeof(SDunit*)); - sdev->unitflg = (int*)malloc(sdev->nunit * sizeof(int)); + sdev->unit = (SDunit**)jehanne_malloc(sdev->nunit * sizeof(SDunit*)); + sdev->unitflg = (int*)jehanne_malloc(sdev->nunit * sizeof(int)); if(sdev->unit == nil || sdev->unitflg == nil){ - print("sdadddevs: out of memory\n"); + jehanne_print("sdadddevs: out of memory\n"); giveup: - free(sdev->unit); - free(sdev->unitflg); + jehanne_free(sdev->unit); + jehanne_free(sdev->unitflg); if(sdev->ifc->clear) sdev->ifc->clear(sdev); - free(sdev); + jehanne_free(sdev); continue; } id = sdindex(sdev->idno); if(id == -1){ - print("sdadddevs: bad id number %d (%C)\n", id, id); + jehanne_print("sdadddevs: bad id number %d (%C)\n", id, id); goto giveup; } qlock(&devslock); @@ -367,13 +367,13 @@ sdadddevs(SDev *sdev) if(devs[j = (id+i)%nelem(devs)] == nil){ sdev->idno = devletters[j]; devs[j] = sdev; - snprint(sdev->name, sizeof sdev->name, "sd%c", devletters[j]); + jehanne_snprint(sdev->name, sizeof sdev->name, "sd%c", devletters[j]); break; } } qunlock(&devslock); if(i == nelem(devs)){ - print("sdadddevs: out of device letters\n"); + jehanne_print("sdadddevs: out of device letters\n"); goto giveup; } } @@ -384,7 +384,7 @@ sdadddevs(SDev *sdev) // { // char buf[2]; // -// snprint(buf, sizeof buf, "%c", sdev->idno); +// jehanne_snprint(buf, sizeof buf, "%c", sdev->idno); // unconfigure(buf); // } @@ -485,7 +485,7 @@ sdgen(Chan* c, char* _1, Dirtab* _2, int _3, int s, Dir* dp) case Qtopdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#%C", sddevtab.dc); + jehanne_sprint(up->genbuf, "#%C", sddevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } @@ -533,7 +533,7 @@ sdgen(Chan* c, char* _1, Dirtab* _2, int _3, int s, Dir* dp) case Qunitdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#%C", sddevtab.dc); + jehanne_sprint(up->genbuf, "#%C", sddevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } @@ -623,7 +623,7 @@ sdattach(Chan *c, Chan *ac, char *spec, int flags) if(spec[0] != 's' || spec[1] != 'd') error(Ebadspec); idno = spec[2]; - subno = strtol(&spec[3], &p, 0); + subno = jehanne_strtol(&spec[3], &p, 0); if(p == &spec[3]) error(Ebadspec); @@ -751,7 +751,7 @@ sdbio(Chan* c, int write, char* a, long len, int64_t off) qlock(&unit->ctl); while(waserror()){ /* notification of media change; go around again */ - if(strcmp(up->errstr, Eio) == 0 && unit->sectors == 0 && nchange++ == 0){ + if(jehanne_strcmp(up->errstr, Eio) == 0 && unit->sectors == 0 && nchange++ == 0){ sdinitpart(unit); continue; } @@ -821,7 +821,7 @@ sdbio(Chan* c, int write, char* a, long len, int64_t off) len = l; } } - memmove(b+offset, a, len); + jehanne_memmove(b+offset, a, len); l = unit->dev->ifc->bio(unit, 0, 1, b, nb, bno); if(l < 0) error(Eio); @@ -838,7 +838,7 @@ sdbio(Chan* c, int write, char* a, long len, int64_t off) len = 0; else if(len > l - offset) len = l - offset; - memmove(a, b+offset, len); + jehanne_memmove(a, b+offset, len); } sdfree(b); poperror(); @@ -865,7 +865,7 @@ sdrio(SDreq* r, void* a, long n) if((data = sdmalloc(n)) == nil) error(Enomem); if(r->write) - memmove(data, a, n); + jehanne_memmove(data, a, n); } r->data = data; r->dlen = n; @@ -880,7 +880,7 @@ sdrio(SDreq* r, void* a, long n) error(Eio); if(!r->write && r->rlen > 0) - memmove(a, data, r->rlen); + jehanne_memmove(a, data, r->rlen); sdfree(data); r->data = nil; poperror(); @@ -908,7 +908,7 @@ sdsetsense(SDreq *r, int status, int key, int asc, int ascq) len = sizeof unit->sense; if(len > sizeof r->sense-1) len = sizeof r->sense-1; - memmove(r->sense, unit->sense, len); + jehanne_memmove(r->sense, unit->sense, len); unit->sense[2] = 0; unit->sense[12] = 0; unit->sense[13] = 0; @@ -938,11 +938,11 @@ sdmodesense(SDreq *r, uint8_t *cmd, void *info, int ilen) if(r->data == nil || r->dlen < len) return sdsetsense(r, SDcheck, 0x05, 0x20, 1); data = r->data; - memset(data, 0, 8); + jehanne_memset(data, 0, 8); data[0] = ilen>>8; data[1] = ilen; if(ilen) - memmove(data+8, info, ilen); + jehanne_memmove(data+8, info, ilen); r->rlen = 8+ilen; return sdsetsense(r, SDok, 0, 0, 0); } @@ -998,7 +998,7 @@ sdfakescsi(SDreq *r, void *info, int ilen) else len = sizeof unit->sense; if(r->data && r->dlen >= len){ - memmove(r->data, unit->sense, len); + jehanne_memmove(r->data, unit->sense, len); r->rlen = len; } return sdsetsense(r, SDok, 0, 0, 0); @@ -1009,7 +1009,7 @@ sdfakescsi(SDreq *r, void *info, int ilen) else len = sizeof unit->inquiry; if(r->data && r->dlen >= len){ - memmove(r->data, unit->inquiry, len); + jehanne_memmove(r->data, unit->inquiry, len); r->rlen = len; } return sdsetsense(r, SDok, 0, 0, 0); @@ -1096,7 +1096,7 @@ sdread(Chan *c, void *a, long n, int64_t off) error(Eperm); case Qtopctl: m = 64*1024; /* room for register dumps */ - p = buf = malloc(m); + p = buf = jehanne_malloc(m); if(p == nil) error(Enomem); e = p + m; @@ -1108,7 +1108,7 @@ sdread(Chan *c, void *a, long n, int64_t off) } qunlock(&devslock); n = readstr(offset, a, n, buf); - free(buf); + jehanne_free(buf); return n; case Qtopdir: @@ -1122,10 +1122,10 @@ sdread(Chan *c, void *a, long n, int64_t off) unit = sdev->unit[UNIT(c->qid)]; m = 16*1024; /* room for register dumps */ - p = malloc(m); + p = jehanne_malloc(m); if(p == nil) error(Enomem); - l = snprint(p, m, "inquiry %.48s\n", + l = jehanne_snprint(p, m, "inquiry %.48s\n", (char*)unit->inquiry+8); qlock(&unit->ctl); /* @@ -1139,13 +1139,13 @@ sdread(Chan *c, void *a, long n, int64_t off) sdinitpart(unit); if(unit->sectors){ if(unit->dev->ifc->rctl == nil) - l += snprint(p+l, m-l, + l += jehanne_snprint(p+l, m-l, "geometry %llud %lud\n", unit->sectors, unit->secsize); pp = unit->part; for(i = 0; i < unit->npart; i++){ if(pp->valid) - l += snprint(p+l, m-l, + l += jehanne_snprint(p+l, m-l, "part %s %llud %llud\n", pp->name, pp->start, pp->end); pp++; @@ -1154,7 +1154,7 @@ sdread(Chan *c, void *a, long n, int64_t off) qunlock(&unit->ctl); decref(&sdev->r); l = readstr(offset, a, n, p); - free(p); + jehanne_free(p); return l; case Qraw: @@ -1176,7 +1176,7 @@ sdread(Chan *c, void *a, long n, int64_t off) else if(unit->state == Rawstatus){ status = unit->req->status; unit->state = Rawcmd; - free(unit->req); + jehanne_free(unit->req); unit->req = nil; i = readnum(0, a, n, status, NUMSIZE); } else @@ -1211,7 +1211,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) case Qtopctl: cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } if(cb->nf == 0) @@ -1219,11 +1219,11 @@ sdwrite(Chan* c, void* a, long n, int64_t off) f0 = cb->f[0]; cb->f++; cb->nf--; - if(strcmp(f0, "config") == 0){ + if(jehanne_strcmp(f0, "config") == 0){ /* wormhole into ugly legacy interface */ legacytopctl(cb); poperror(); - free(cb); + jehanne_free(cb); break; } /* @@ -1233,7 +1233,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) ifc = nil; sdev = nil; for(i=0; sdifc[i]; i++){ - if(strcmp(sdifc[i]->name, f0) == 0){ + if(jehanne_strcmp(sdifc[i]->name, f0) == 0){ ifc = sdifc[i]; sdev = nil; goto subtopctl; @@ -1266,7 +1266,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) poperror(); if(sdev) decref(&sdev->r); - free(cb); + jehanne_free(cb); break; case Qctl: @@ -1280,7 +1280,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) if(waserror()){ qunlock(&unit->ctl); decref(&sdev->r); - free(cb); + jehanne_free(cb); nexterror(); } if(unit->vers != c->qid.vers) @@ -1288,16 +1288,16 @@ sdwrite(Chan* c, void* a, long n, int64_t off) if(cb->nf < 1) error(Ebadctl); - if(strcmp(cb->f[0], "part") == 0){ + if(jehanne_strcmp(cb->f[0], "part") == 0){ if(cb->nf != 4) error(Ebadctl); if(unit->sectors == 0 && !sdinitpart(unit)) error(Eio); - start = strtoull(cb->f[2], 0, 0); - end = strtoull(cb->f[3], 0, 0); + start = jehanne_strtoull(cb->f[2], 0, 0); + end = jehanne_strtoull(cb->f[3], 0, 0); sdaddpart(unit, cb->f[1], start, end); } - else if(strcmp(cb->f[0], "delpart") == 0){ + else if(jehanne_strcmp(cb->f[0], "delpart") == 0){ if(cb->nf != 2 || unit->part == nil) error(Ebadctl); sddelpart(unit, cb->f[1]); @@ -1309,7 +1309,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) qunlock(&unit->ctl); decref(&sdev->r); poperror(); - free(cb); + jehanne_free(cb); break; case Qraw: @@ -1327,10 +1327,10 @@ sdwrite(Chan* c, void* a, long n, int64_t off) case Rawcmd: if(n < 6 || n > sizeof(req->cmd)) error(Ebadarg); - if((req = malloc(sizeof(SDreq))) == nil) + if((req = jehanne_malloc(sizeof(SDreq))) == nil) error(Enomem); req->unit = unit; - memmove(req->cmd, a, n); + jehanne_memmove(req->cmd, a, n); req->clen = n; req->flags = SDnosense; req->status = ~0; @@ -1341,7 +1341,7 @@ sdwrite(Chan* c, void* a, long n, int64_t off) case Rawstatus: unit->state = Rawcmd; - free(unit->req); + jehanne_free(unit->req); unit->req = nil; error(Ebadusefd); @@ -1380,7 +1380,7 @@ sdwstat(Chan* c, uint8_t* dp, long n) qlock(&unit->ctl); d = nil; if(waserror()){ - free(d); + jehanne_free(d); qunlock(&unit->ctl); decref(&sdev->r); nexterror(); @@ -1403,11 +1403,11 @@ sdwstat(Chan* c, uint8_t* dp, long n) break; } - if(strcmp(up->user, perm->user) && !iseve()) + if(jehanne_strcmp(up->user, perm->user) && !iseve()) error(Eperm); d = smalloc(sizeof(Dir)+n); - n = convM2D(dp, n, &d[0], (char*)&d[1]); + n = jehanne_convM2D(dp, n, &d[0], (char*)&d[1]); if(n == 0) error(Eshortstat); if(!emptystr(d[0].uid)) @@ -1415,7 +1415,7 @@ sdwstat(Chan* c, uint8_t* dp, long n) if(d[0].mode != (uint32_t)~0UL) perm->perm = (perm->perm & ~0777) | (d[0].mode & 0777); - free(d); + jehanne_free(d); qunlock(&unit->ctl); decref(&sdev->r); poperror(); @@ -1432,11 +1432,11 @@ configure(char* spec, DevConf* cf) if(sdindex(*spec) < 0) error("bad sd spec"); - if((p = strchr(cf->type, '/')) != nil) + if((p = jehanne_strchr(cf->type, '/')) != nil) *p++ = '\0'; for(i = 0; sdifc[i] != nil; i++) - if(strcmp(sdifc[i]->name, cf->type) == 0) + if(jehanne_strcmp(sdifc[i]->name, cf->type) == 0) break; if(sdifc[i] == nil) error("sd type not found"); @@ -1481,15 +1481,15 @@ unconfigure(char* spec) for(i = 0; i != sdev->nunit; i++){ if(unit = sdev->unit[i]){ - free(unit->name); - free(unit->user); - free(unit); + jehanne_free(unit->name); + jehanne_free(unit->user); + jehanne_free(unit); } } if(sdev->ifc->clear) sdev->ifc->clear(sdev); - free(sdev); + jehanne_free(sdev); return 0; } @@ -1537,9 +1537,9 @@ struct Confdata { static void parseswitch(Confdata* cd, char* option) { - if(!strcmp("on", option)) + if(!jehanne_strcmp("on", option)) cd->on = 1; - else if(!strcmp("off", option)) + else if(!jehanne_strcmp("off", option)) cd->on = 0; else error(Ebadarg); @@ -1548,7 +1548,7 @@ parseswitch(Confdata* cd, char* option) static void parsespec(Confdata* cd, char* option) { - if(strlen(option) > 1) + if(jehanne_strlen(option) > 1) error(Ebadarg); cd->spec = option; } @@ -1558,12 +1558,12 @@ getnewport(DevConf* dc) { Devport *p; - p = (Devport *)malloc((dc->nports + 1) * sizeof(Devport)); + p = (Devport *)jehanne_malloc((dc->nports + 1) * sizeof(Devport)); if(p == nil) error(Enomem); if(dc->nports > 0){ - memmove(p, dc->ports, dc->nports * sizeof(Devport)); - free(dc->ports); + jehanne_memmove(p, dc->ports, dc->nports * sizeof(Devport)); + jehanne_free(dc->ports); } dc->ports = p; p = &dc->ports[dc->nports++]; @@ -1582,7 +1582,7 @@ parseport(Confdata* cd, char* option) p = getnewport(&cd->cf); else p = &cd->cf.ports[cd->cf.nports-1]; - p->port = strtol(option, &e, 0); + p->port = jehanne_strtol(option, &e, 0); if(e == nil || *e != '\0') error(Ebadarg); } @@ -1597,7 +1597,7 @@ parsesize(Confdata* cd, char* option) p = getnewport(&cd->cf); else p = &cd->cf.ports[cd->cf.nports-1]; - p->size = (int)strtol(option, &e, 0); + p->size = (int)jehanne_strtol(option, &e, 0); if(e == nil || *e != '\0') error(Ebadarg); } @@ -1607,7 +1607,7 @@ parseirq(Confdata* cd, char* option) { char *e; - cd->cf.intnum = strtoul(option, &e, 0); + cd->cf.intnum = jehanne_strtoul(option, &e, 0); if(e == nil || *e != '\0') error(Ebadarg); } @@ -1637,14 +1637,14 @@ legacytopctl(Cmdbuf *cb) int i, j; Confdata cd; - memset(&cd, 0, sizeof cd); + jehanne_memset(&cd, 0, sizeof cd); cd.on = -1; for(i=0; inf; i+=2){ if(i+2 > cb->nf) error(Ebadarg); opt = cb->f[i]; for(j=0; jf[i+1]); break; } diff --git a/sys/src/kern/port/devsegment.c b/sys/src/kern/port/devsegment.c index 1d53aef..ca762d2 100644 --- a/sys/src/kern/port/devsegment.c +++ b/sys/src/kern/port/devsegment.c @@ -97,9 +97,9 @@ putgseg(Globalseg *g) putseg(g->s); if(g->kproc) docmd(g, Cdie); - free(g->name); - free(g->uid); - free(g); + jehanne_free(g->name); + jehanne_free(g->uid); + jehanne_free(g); } static int @@ -300,7 +300,7 @@ segmentcreate(Chan *c, char *name, int omode, int perm) if(xfree < 0) xfree = x; } else { - if(strcmp(g->name, name) == 0) + if(jehanne_strcmp(g->name, name) == 0) error(Eexist); } } @@ -337,7 +337,7 @@ segmentread(Chan *c, void *a, long n, int64_t voff) g = c->aux; if(g->s == nil) error("segment not yet allocated"); - snprint(buf, sizeof buf, "va %#lux %#lux\n", g->s->base, + jehanne_snprint(buf, sizeof buf, "va %#lux %#lux\n", g->s->base, g->s->top-g->s->base); return readstr(voff, a, n, buf); case Qdata: @@ -350,14 +350,14 @@ segmentread(Chan *c, void *a, long n, int64_t voff) g->off = voff + g->s->base; g->data = smalloc(n); if(waserror()){ - free(g->data); + jehanne_free(g->data); qunlock(&g->l); nexterror(); } g->dlen = n; docmd(g, Cread); - memmove(a, g->data, g->dlen); - free(g->data); + jehanne_memmove(a, g->data, g->dlen); + jehanne_free(g->data); qunlock(&g->l); poperror(); return g->dlen; @@ -381,13 +381,13 @@ segmentwrite(Chan *c, void *a, long n, int64_t voff) case Qctl: g = c->aux; cb = parsecmd(a, n); - if(strcmp(cb->f[0], "va") == 0){ + if(jehanne_strcmp(cb->f[0], "va") == 0){ if(g->s != nil) error("already has a virtual address"); if(cb->nf < 3) error(Ebadarg); - va = strtoull(cb->f[1], 0, 0); - len = strtoull(cb->f[2], 0, 0); + va = jehanne_strtoull(cb->f[1], 0, 0); + len = jehanne_strtoull(cb->f[2], 0, 0); top = ROUNDUP(va + len, PGSZ); va = va&~(PGSZ-1); len = (top - va) / PGSZ; @@ -405,14 +405,14 @@ segmentwrite(Chan *c, void *a, long n, int64_t voff) g->off = voff + g->s->base; g->data = smalloc(n); if(waserror()){ - free(g->data); + jehanne_free(g->data); qunlock(&g->l); nexterror(); } g->dlen = n; - memmove(g->data, a, g->dlen); + jehanne_memmove(g->data, a, g->dlen); docmd(g, Cwrite); - free(g->data); + jehanne_free(g->data); qunlock(&g->l); poperror(); return g->dlen; @@ -437,16 +437,16 @@ segmentwstat(Chan *c, uint8_t *dp, long n) nexterror(); } - if(strcmp(g->uid, up->user) && !iseve()) + if(jehanne_strcmp(g->uid, up->user) && !iseve()) error(Eperm); d = smalloc(sizeof(Dir)+n); - n = convM2D(dp, n, &d[0], (char*)&d[1]); + n = jehanne_convM2D(dp, n, &d[0], (char*)&d[1]); g->perm = d->mode & 0777; putgseg(g); poperror(); - free(d); + jehanne_free(d); return n; } @@ -485,7 +485,7 @@ globalsegattach(Proc *p, char *name) lock(&globalseglock); for(x = 0; x < nelem(globalseg); x++){ g = globalseg[x]; - if(g != nil && strcmp(g->name, name) == 0) + if(g != nil && jehanne_strcmp(g->name, name) == 0) break; } if(x == nelem(globalseg)){ @@ -544,7 +544,7 @@ segmentkproc(void *arg) for(done = 0; !done;){ sleep(&g->cmdwait, cmdready, g); if(waserror()){ - strncpy(g->err, up->errstr, sizeof(g->err)); + jehanne_strncpy(g->err, up->errstr, sizeof(g->err)); } else { switch(g->cmd){ case Cstart: @@ -553,10 +553,10 @@ segmentkproc(void *arg) done = 1; break; case Cread: - memmove(g->data, (char*)g->off, g->dlen); + jehanne_memmove(g->data, (char*)g->off, g->dlen); break; case Cwrite: - memmove((char*)g->off, g->data, g->dlen); + jehanne_memmove((char*)g->off, g->data, g->dlen); break; } poperror(); diff --git a/sys/src/kern/port/devself.c b/sys/src/kern/port/devself.c index eb918f2..eb8f636 100644 --- a/sys/src/kern/port/devself.c +++ b/sys/src/kern/port/devself.c @@ -91,7 +91,7 @@ selfgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp) if(name){ for(i=1; idot->path->s); + length = 1 + jehanne_strlen(up->dot->path->s); } else { length = tab->length; } @@ -197,7 +197,7 @@ selfcreate(Chan* c, char* name, unsigned long omode, unsigned long perm) default: error(Eperm); case Qbrk: - if(strcmp(name, "set") != 0) + if(jehanne_strcmp(name, "set") != 0) error(Eperm); e = (long)grow_bss(perm); errorl(nil, ~e); @@ -233,7 +233,7 @@ read_working_dir(Proc* p, void *va, long n, int64_t off) dot = up->dot; path = dot->path->s; - i = 1 + strlen(path); + i = 1 + jehanne_strlen(path); if(va == nil){ /* the user is actually asking for the space */ if(off != 0 && off != ~0) { @@ -247,7 +247,7 @@ read_working_dir(Proc* p, void *va, long n, int64_t off) j = i - off; if(n < j) j = n; - memmove(va, path, j); + jehanne_memmove(va, path, j); return j; } @@ -301,7 +301,7 @@ selfread(Chan *c, void *va, long n, int64_t offset) sg = up->seg[i]; if(sg == 0) continue; - j += sprint(statbuf+j, "%-6s %c%c %p %p %4d\n", + j += jehanne_sprint(statbuf+j, "%-6s %c%c %p %p %4d\n", segment_name(sg), !(sg->type&SgWrite) ? 'R' : ' ', (sg->type&SgExecute) ? 'x' : ' ', @@ -315,7 +315,7 @@ selfread(Chan *c, void *va, long n, int64_t offset) n = j-offset; if(n == 0 && offset == 0) exhausted("segments"); - memmove(va, &statbuf[offset], n); + jehanne_memmove(va, &statbuf[offset], n); return n; case Qwdir: return read_working_dir(up, va, n, offset); @@ -330,7 +330,7 @@ selfread(Chan *c, void *va, long n, int64_t offset) case Qnull: return 0; case Qzero: - memset(va, 0, n); + jehanne_memset(va, 0, n); return n; default: @@ -440,7 +440,7 @@ procsegctl(Proc *p, char *va, int n) cb = parsecmd(va, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } @@ -450,19 +450,19 @@ procsegctl(Proc *p, char *va, int n) error(Ebadctl); return -1; case CMsegattach: - attr = strtoul(cb->f[1], 0, 0); - vareq = strtoull(cb->f[2], 0, 0); - len = strtoull(cb->f[3], 0, 0); + attr = jehanne_strtoul(cb->f[1], 0, 0); + vareq = jehanne_strtoull(cb->f[2], 0, 0); + len = jehanne_strtoull(cb->f[3], 0, 0); class = cb->f[4]; result = segattach(p, attr, class, vareq, len); break; case CMsegdetach: - vareq = strtoull(cb->f[1], 0, 0); + vareq = jehanne_strtoull(cb->f[1], 0, 0); result = segdetach(p, vareq); break; case CMsegfree: - vareq = strtoull(cb->f[1], 0, 0); - len = strtoull(cb->f[2], 0, 0); + vareq = jehanne_strtoull(cb->f[1], 0, 0); + len = jehanne_strtoull(cb->f[2], 0, 0); result = segfree(p, vareq, len); break; } diff --git a/sys/src/kern/port/devshr.c b/sys/src/kern/port/devshr.c index a5950bf..8960dde 100644 --- a/sys/src/kern/port/devshr.c +++ b/sys/src/kern/port/devshr.c @@ -95,9 +95,9 @@ putmpt(Mpt *mpt) return; if(mpt->m.to != nil) cclose(mpt->m.to); - free(mpt->name); - free(mpt->owner); - free(mpt); + jehanne_free(mpt->name); + jehanne_free(mpt->owner); + jehanne_free(mpt); } static void @@ -105,9 +105,9 @@ putshr(Shr *shr) { if(decref(&shr->ref)) return; - free(shr->name); - free(shr->owner); - free(shr); + jehanne_free(shr->name); + jehanne_free(shr->owner); + jehanne_free(shr); } static Qid @@ -153,7 +153,7 @@ shrclone(Chan *c) // this is a plan9-9k specific behaviour, but why? // many related places are marked with XDYNX sch = smalloc(sizeof(*sch)); - memmove(sch, och, sizeof(*sch)); + jehanne_memmove(sch, och, sizeof(*sch)); if(sch->shr != nil) incref(&sch->shr->ref); if(sch->mpt != nil) @@ -175,7 +175,7 @@ shrclunk(Chan *c) putmpt(sch->mpt); if(sch->shr != nil) putshr(sch->shr); - free(sch); + jehanne_free(sch); } static Walkqid* @@ -204,7 +204,7 @@ shrwalk(Chan *c, Chan *nc, char **name, int nname) if(wq->nqid > 0) wq->clone = nil; else { - free(wq); + jehanne_free(wq); wq = nil; } return wq; @@ -233,7 +233,7 @@ shrwalk(Chan *c, Chan *nc, char **name, int nname) } else if(sch->level == Qcroot || sch->level == Qroot) { qlock(&shrslk); for(shr = shrs; shr != nil; shr = shr->next) - if(strcmp(nam, shr->name) == 0){ + if(jehanne_strcmp(nam, shr->name) == 0){ incref(&shr->ref); break; } @@ -250,7 +250,7 @@ shrwalk(Chan *c, Chan *nc, char **name, int nname) rlock(&h->lock); for(m = h->mount; m != nil; m = m->next){ mpt = tompt(m); - if(strcmp(nam, mpt->name) == 0){ + if(jehanne_strcmp(nam, mpt->name) == 0){ incref(&mpt->ref); break; } @@ -276,12 +276,12 @@ shrwalk(Chan *c, Chan *nc, char **name, int nname) runlock(&h->lock); if(wq2 == nil) error(Enonexist); - memmove(wq->qid + wq->nqid, wq2->qid, wq2->nqid); + jehanne_memmove(wq->qid + wq->nqid, wq2->qid, wq2->nqid); wq->nqid += wq2->nqid; if(alloc) cclose(wq->clone); wq->clone = wq2->clone; - free(wq2); + jehanne_free(wq2); poperror(); return wq; } else @@ -368,7 +368,7 @@ shrstat(Chan *c, uint8_t *db, long n) devdir(c, c->qid, sch->mpt->name, 0, sch->mpt->owner, sch->mpt->perm, &dir); break; } - rc = convD2M(&dir, db, n); + rc = jehanne_convD2M(&dir, db, n); if(rc == 0) error(Ebadarg); return rc; @@ -445,7 +445,7 @@ shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) switch(sch->level){ case Qcroot: case Qcshr: - if(strcmp(up->user, "none") == 0) + if(jehanne_strcmp(up->user, "none") == 0) error(Eperm); } switch(sch->level){ @@ -472,7 +472,7 @@ shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) error(Enoattach); if((perm & DMDIR) == 0 || mode != OREAD) error(Eperm); - if(strlen(name) >= sizeof(up->genbuf)) + if(jehanne_strlen(name) >= sizeof(up->genbuf)) error(Etoolong); qlock(&shrslk); if(waserror()){ @@ -480,7 +480,7 @@ shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) nexterror(); } for(shr = shrs; shr != nil; shr = shr->next) - if(strcmp(name, shr->name) == 0) + if(jehanne_strcmp(name, shr->name) == 0) error(Eexist); shr = smalloc(sizeof(*shr)); @@ -508,11 +508,11 @@ shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) error(Eperm); shr = sch->shr; - if(strcmp(shr->owner, eve) == 0 && !iseve()) + if(jehanne_strcmp(shr->owner, eve) == 0 && !iseve()) error(Eperm); devpermcheck(shr->owner, shr->perm, ORDWR); - if(strlen(name) >= sizeof(up->genbuf)) + if(jehanne_strlen(name) >= sizeof(up->genbuf)) error(Etoolong); h = &shr->umh; @@ -523,7 +523,7 @@ shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) } for(m = h->mount; m != nil; m = m->next){ mpt = tompt(m); - if(strcmp(name, mpt->name) == 0) + if(jehanne_strcmp(name, mpt->name) == 0) error(Eexist); } @@ -573,7 +573,7 @@ shrremove(Chan *c) case Qcmpt: shr = sch->shr; if(!iseve()){ - if(strcmp(shr->owner, eve) == 0) + if(jehanne_strcmp(shr->owner, eve) == 0) error(Eperm); devpermcheck(shr->owner, shr->perm, ORDWR); } @@ -628,10 +628,10 @@ shrwstat(Chan *c, uint8_t *dp, long n) strs = smalloc(n); if(waserror()){ - free(strs); + jehanne_free(strs); nexterror(); } - n = convM2D(dp, n, &d, strs); + n = jehanne_convM2D(dp, n, &d, strs); if(n == 0) error(Eshortstat); @@ -659,13 +659,13 @@ shrwstat(Chan *c, uint8_t *dp, long n) break; } - if(strcmp(ent->owner, up->user) && !iseve()) + if(jehanne_strcmp(ent->owner, up->user) && !iseve()) error(Eperm); - if(d.name != nil && *d.name && strcmp(ent->name, d.name) != 0) { - if(strchr(d.name, '/') != nil) + if(d.name != nil && *d.name && jehanne_strcmp(ent->name, d.name) != 0) { + if(jehanne_strchr(d.name, '/') != nil) error(Ebadchar); - if(strlen(d.name) >= sizeof(up->genbuf)) + if(jehanne_strlen(d.name) >= sizeof(up->genbuf)) error(Etoolong); kstrdup(&ent->name, d.name); } @@ -686,7 +686,7 @@ shrwstat(Chan *c, uint8_t *dp, long n) } poperror(); - free(strs); + jehanne_free(strs); return n; } @@ -737,13 +737,13 @@ shrwrite(Chan *c, void *va, long n, int64_t _) buf = smalloc(n+1); if(waserror()){ - free(buf); + jehanne_free(buf); nexterror(); } - memmove(buf, va, n); + jehanne_memmove(buf, va, n); buf[n] = 0; - fd = strtol(buf, &p, 10); + fd = jehanne_strtol(buf, &p, 10); if(p == buf || (*p != 0 && *p != '\n')) error(Ebadarg); if(*p == '\n' && *(p+1) != 0) @@ -760,7 +760,7 @@ shrwrite(Chan *c, void *va, long n, int64_t _) poperror(); cclose(bc); poperror(); - free(buf); + jehanne_free(buf); if(c0 == nil) error(Egreg); @@ -811,7 +811,7 @@ Dev shrdevtab = { static void chowner(Ent *ent, char *old, char *new) { - if(ent->owner != nil && strcmp(old, ent->owner) == 0) + if(ent->owner != nil && jehanne_strcmp(old, ent->owner) == 0) kstrdup(&ent->owner, new); } diff --git a/sys/src/kern/port/devsrv.c b/sys/src/kern/port/devsrv.c index 202c40b..6e5ddd5 100644 --- a/sys/src/kern/port/devsrv.c +++ b/sys/src/kern/port/devsrv.c @@ -27,7 +27,7 @@ srvlookup(char *name, uint32_t qidpath) Srv *sp; for(sp = srv; sp != nil; sp = sp->link) { - if(sp->path == qidpath || (name != nil && strcmp(sp->name, name) == 0)) + if(sp->path == qidpath || (name != nil && jehanne_strcmp(sp->name, name) == 0)) return sp; } return nil; @@ -53,7 +53,7 @@ srvgen(Chan *c, char* name, Dirtab* _, int __, int s, Dir *dp) } if(sp == nil || sp->chan == nil - || (name != nil && (strlen(sp->name) >= sizeof(up->genbuf)))) { + || (name != nil && (jehanne_strlen(sp->name) >= sizeof(up->genbuf)))) { qunlock(&srvlk); return -1; } @@ -100,9 +100,9 @@ srvname(Chan *c) qlock(&srvlk); for(sp = srv; sp != nil; sp = sp->link) { if(sp->chan == c){ - s = malloc(3+strlen(sp->name)+1); + s = jehanne_malloc(3+jehanne_strlen(sp->name)+1); if(s != nil) - sprint(s, "#s/%s", sp->name); + jehanne_sprint(s, "#s/%s", sp->name); break; } } @@ -162,7 +162,7 @@ srvcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) //error(Eperm); } - if(strlen(name) >= sizeof(up->genbuf)) + if(jehanne_strlen(name) >= sizeof(up->genbuf)) error(Etoolong); sp = smalloc(sizeof *sp); @@ -172,9 +172,9 @@ srvcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) qlock(&srvlk); if(waserror()){ qunlock(&srvlk); - free(sp->owner); - free(sp->name); - free(sp); + jehanne_free(sp->owner); + jehanne_free(sp->name); + jehanne_free(sp); nexterror(); } if(srvlookup(name, -1) != nil) @@ -224,15 +224,15 @@ srvremove(Chan *c) * Only eve can remove system services. * No one can remove #s/boot. */ - if(strcmp(sp->owner, eve) == 0 && !iseve()) + if(jehanne_strcmp(sp->owner, eve) == 0 && !iseve()) error(Eperm); - if(strcmp(sp->name, "boot") == 0) + if(jehanne_strcmp(sp->name, "boot") == 0) error(Eperm); /* * No removing personal services. */ - if((sp->perm&7) != 7 && strcmp(sp->owner, up->user) && !iseve()) + if((sp->perm&7) != 7 && jehanne_strcmp(sp->owner, up->user) && !iseve()) error(Eperm); *l = sp->link; @@ -243,9 +243,9 @@ srvremove(Chan *c) if(sp->chan != nil) cclose(sp->chan); - free(sp->owner); - free(sp->name); - free(sp); + jehanne_free(sp->owner); + jehanne_free(sp->name); + jehanne_free(sp); } static long @@ -260,10 +260,10 @@ srvwstat(Chan *c, uint8_t *dp, long n) strs = smalloc(n); if(waserror()){ - free(strs); + jehanne_free(strs); nexterror(); } - n = convM2D(dp, n, &d, strs); + n = jehanne_convM2D(dp, n, &d, strs); if(n == 0) error(Eshortstat); @@ -277,13 +277,13 @@ srvwstat(Chan *c, uint8_t *dp, long n) if(sp == nil) error(Enonexist); - if(strcmp(sp->owner, up->user) != 0 && !iseve()) + if(jehanne_strcmp(sp->owner, up->user) != 0 && !iseve()) error(Eperm); - if(d.name != nil && *d.name && strcmp(sp->name, d.name) != 0) { - if(strchr(d.name, '/') != nil) + if(d.name != nil && *d.name && jehanne_strcmp(sp->name, d.name) != 0) { + if(jehanne_strchr(d.name, '/') != nil) error(Ebadchar); - if(strlen(d.name) >= sizeof(up->genbuf)) + if(jehanne_strlen(d.name) >= sizeof(up->genbuf)) error(Etoolong); kstrdup(&sp->name, d.name); } @@ -295,7 +295,7 @@ srvwstat(Chan *c, uint8_t *dp, long n) qunlock(&srvlk); poperror(); - free(strs); + jehanne_free(strs); poperror(); return n; @@ -334,9 +334,9 @@ srvwrite(Chan *c, void *va, long n, int64_t _1) if(n >= sizeof buf) error(Egreg); - memmove(buf, va, n); /* so we can NUL-terminate */ + jehanne_memmove(buf, va, n); /* so we can NUL-terminate */ buf[n] = 0; - fd = strtoul(buf, 0, 0); + fd = jehanne_strtoul(buf, 0, 0); c1 = fdtochan(fd, -1, 0, 1); /* error check and inc ref */ @@ -392,7 +392,7 @@ srvrenameuser(char *old, char *new) qlock(&srvlk); for(sp = srv; sp != nil; sp = sp->link) { - if(sp->owner != nil && strcmp(old, sp->owner) == 0) + if(sp->owner != nil && jehanne_strcmp(old, sp->owner) == 0) kstrdup(&sp->owner, new); } qunlock(&srvlk); diff --git a/sys/src/kern/port/devssl.c b/sys/src/kern/port/devssl.c index 23803b1..edcba01 100644 --- a/sys/src/kern/port/devssl.c +++ b/sys/src/kern/port/devssl.c @@ -166,7 +166,7 @@ sslgen(Chan *c, char* _1, Dirtab *d, int nd, int s, Dir *dp) nm = ds->user; else nm = eve; - snprint(up->genbuf, sizeof(up->genbuf), "%d", s); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d", s); devdir(c, q, up->genbuf, 0, nm, 0555, dp); return 1; } @@ -304,7 +304,7 @@ sslopen(Chan *c, unsigned long omode) dsnew(c, pp); else { if((perm & (s->perm>>6)) != perm - && (strcmp(up->user, s->user) != 0 + && (jehanne_strcmp(up->user, s->user) != 0 || (perm & s->perm) != perm)) error(Eperm); @@ -335,13 +335,13 @@ sslwstat(Chan *c, uint8_t *db, long n) s = dstate[CONV(c->qid)]; if(s == 0) error(Ebadusefd); - if(strcmp(s->user, up->user) != 0) + if(jehanne_strcmp(s->user, up->user) != 0) error(Eperm); dir = smalloc(sizeof(Dir)+n); - l = convM2D(db, n, &dir[0], (char*)&dir[1]); + l = jehanne_convM2D(db, n, &dir[0], (char*)&dir[1]); if(l == 0){ - free(dir); + jehanne_free(dir); error(Eshortstat); } @@ -350,7 +350,7 @@ sslwstat(Chan *c, uint8_t *db, long n) if(dir->mode != (uint32_t)~0UL) s->perm = dir->mode; - free(dir); + jehanne_free(dir); return l; } @@ -382,19 +382,19 @@ sslclose(Chan *c) unlock(&dslock); if(s->user != nil) - free(s->user); + jehanne_free(s->user); sslhangup(s); if(s->c) cclose(s->c); if(s->in.secret) - free(s->in.secret); + jehanne_free(s->in.secret); if(s->out.secret) - free(s->out.secret); + jehanne_free(s->out.secret); if(s->in.state) - free(s->in.state); + jehanne_free(s->in.state); if(s->out.state) - free(s->out.state); - free(s); + jehanne_free(s->out.state); + jehanne_free(s); } } @@ -447,7 +447,7 @@ consume(Block **l, uint8_t *p, int n) i = BLEN(b); if(i > n) i = n; - memmove(p, b->rp, i); + jehanne_memmove(p, b->rp, i); b->rp += i; p += i; if(BLEN(b) < 0) @@ -471,13 +471,13 @@ regurgitate(Dstate *s, uint8_t *p, int n) b = s->unprocessed; if(s->unprocessed == nil || b->rp - b->base < n) { b = allocb(n); - memmove(b->wp, p, n); + jehanne_memmove(b->wp, p, n); b->wp += n; b->next = s->unprocessed; s->unprocessed = b; } else { b->rp -= n; - memmove(b->rp, p, n); + jehanne_memmove(b->rp, p, n); } } */ @@ -511,7 +511,7 @@ qtake(Block **l, int n, int discard) *l = 0; } else { nb = allocb(i); - memmove(nb->wp, b->rp+n, i); + jehanne_memmove(nb->wp, b->rp+n, i); nb->wp += i; b->wp -= i; nb->next = b->next; @@ -577,7 +577,7 @@ sslbread(Chan *c, long n, int64_t _1) len = ((p[0] & 0x3f)<<8) | p[1]; pad = p[2]; if(pad > len){ - print("pad %d buf len %d\n", pad, len); + jehanne_print("pad %d buf len %d\n", pad, len); error("bad pad in ssl message"); } toconsume = 3; @@ -591,7 +591,7 @@ sslbread(Chan *c, long n, int64_t _1) b = qtake(&s->unprocessed, len, 0); if(blocklen(b) != len) - print("devssl: sslbread got wrong count %d != %d", blocklen(b), len); + jehanne_print("devssl: sslbread got wrong count %d != %d", blocklen(b), len); if(waserror()){ qunlock(&s->in.ctlq); @@ -666,7 +666,7 @@ sslread(Chan *c, void *a, long n, int64_t off) error(Ebadusefd); case Qctl: ft = CONV(c->qid); - sprint(buf, "%d", ft); + jehanne_sprint(buf, "%d", ft); return readstr(offset, a, n, buf); case Qdata: b = sslbread(c, n, offset); @@ -688,7 +688,7 @@ sslread(Chan *c, void *a, long n, int64_t off) va = a; for(nb = b; nb; nb = nb->next){ i = BLEN(nb); - memmove(va+n, nb->rp, i); + jehanne_memmove(va+n, nb->rp, i); n += i; } @@ -755,7 +755,7 @@ sslput(Dstate *s, Block * volatile b) if(waserror()){ if(b != nil) - free(b); + jehanne_free(b); nexterror(); } @@ -784,7 +784,7 @@ sslput(Dstate *s, Block * volatile b) rv += l; if(l != n){ nb = allocb(l + h + pad); - memmove(nb->wp + h, b->rp, l); + jehanne_memmove(nb->wp + h, b->rp, l); nb->wp += l + h; b->rp += l; } else { @@ -841,10 +841,10 @@ static void setsecret(OneWay *w, uint8_t *secret, int n) { if(w->secret) - free(w->secret); + jehanne_free(w->secret); w->secret = smalloc(n); - memmove(w->secret, secret, n); + jehanne_memmove(w->secret, secret, n); w->slen = n; } @@ -852,7 +852,7 @@ static void initDESkey(OneWay *w) { if(w->state){ - free(w->state); + jehanne_free(w->state); w->state = 0; } @@ -875,19 +875,19 @@ initDESkey_40(OneWay *w) uint8_t key[8]; if(w->state){ - free(w->state); + jehanne_free(w->state); w->state = 0; } if(w->slen >= 8){ - memmove(key, w->secret, 8); + jehanne_memmove(key, w->secret, 8); key[0] &= 0x0f; key[2] &= 0x0f; key[4] &= 0x0f; key[6] &= 0x0f; } - w->state = malloc(sizeof(DESstate)); + w->state = jehanne_malloc(sizeof(DESstate)); if(w->slen >= 16) setupDESstate(w->state, key, w->secret+8); else if(w->slen >= 8) @@ -900,7 +900,7 @@ static void initRC4key(OneWay *w) { if(w->state){ - free(w->state); + jehanne_free(w->state); w->state = 0; } @@ -916,14 +916,14 @@ static void initRC4key_40(OneWay *w) { if(w->state){ - free(w->state); + jehanne_free(w->state); w->state = 0; } if(w->slen > 5) w->slen = 5; - w->state = malloc(sizeof(RC4state)); + w->state = jehanne_malloc(sizeof(RC4state)); setupRC4state(w->state, w->secret, w->slen); } @@ -935,14 +935,14 @@ static void initRC4key_128(OneWay *w) { if(w->state){ - free(w->state); + jehanne_free(w->state); w->state = 0; } if(w->slen > 16) w->slen = 16; - w->state = malloc(sizeof(RC4state)); + w->state = jehanne_malloc(sizeof(RC4state)); setupRC4state(w->state, w->secret, w->slen); } @@ -970,7 +970,7 @@ parsehashalg(char *p, Dstate *s) Hashalg *ha; for(ha = hashtab; ha->name; ha++){ - if(strcmp(p, ha->name) == 0){ + if(jehanne_strcmp(p, ha->name) == 0){ s->hf = ha->hf; s->diglen = ha->diglen; s->state &= ~Sclear; @@ -1022,7 +1022,7 @@ parseencryptalg(char *p, Dstate *s) Encalg *ea; for(ea = encrypttab; ea->name; ea++){ - if(strcmp(p, ea->name) == 0){ + if(jehanne_strcmp(p, ea->name) == 0){ s->encryptalg = ea->alg; s->blocklen = ea->blocklen; (*ea->keyinit)(&s->in); @@ -1072,7 +1072,7 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) freeb(b); nexterror(); } - memmove(b->wp, p, l); + jehanne_memmove(b->wp, p, l); poperror(); b->wp += l; @@ -1110,16 +1110,16 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) if(n >= sizeof(buf)) error("arg too long"); - strncpy(buf, a, n); + jehanne_strncpy(buf, a, n); buf[n] = 0; - p = strchr(buf, '\n'); + p = jehanne_strchr(buf, '\n'); if(p) *p = 0; - p = strchr(buf, ' '); + p = jehanne_strchr(buf, ' '); if(p) *p++ = 0; - if(strcmp(buf, "fd") == 0){ + if(jehanne_strcmp(buf, "fd") == 0){ s->c = buftochan(p); /* default is clear (msg delimiters only) */ @@ -1129,7 +1129,7 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) s->maxpad = s->max = (1<<15) - s->diglen - 1; s->in.mid = 0; s->out.mid = 0; - } else if(strcmp(buf, "alg") == 0 && p != 0){ + } else if(jehanne_strcmp(buf, "alg") == 0 && p != 0){ s->blocklen = 1; s->diglen = 0; @@ -1138,7 +1138,7 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) s->state = Sclear; s->maxpad = s->max = (1<<15) - s->diglen - 1; - if(strcmp(p, "clear") == 0){ + if(jehanne_strcmp(p, "clear") == 0){ goto out; } @@ -1154,7 +1154,7 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) s->blocklen = 1; for(;;){ - np = strchr(p, ' '); + np = jehanne_strchr(p, ' '); if(np) *np++ = 0; @@ -1177,18 +1177,18 @@ sslwrite(Chan *c, void *a, long n, int64_t _1) s->maxpad -= s->maxpad % s->blocklen; } else s->maxpad = s->max = (1<<15) - s->diglen - 1; - } else if(strcmp(buf, "secretin") == 0 && p != 0) { - l = (strlen(p)*3)/2; + } else if(jehanne_strcmp(buf, "secretin") == 0 && p != 0) { + l = (jehanne_strlen(p)*3)/2; x = smalloc(l); - t = dec64(x, l, p, strlen(p)); + t = jehanne_dec64(x, l, p, jehanne_strlen(p)); setsecret(&s->in, x, t); - free(x); - } else if(strcmp(buf, "secretout") == 0 && p != 0) { - l = (strlen(p)*3)/2 + 1; + jehanne_free(x); + } else if(jehanne_strcmp(buf, "secretout") == 0 && p != 0) { + l = (jehanne_strlen(p)*3)/2 + 1; x = smalloc(l); - t = dec64(x, l, p, strlen(p)); + t = jehanne_dec64(x, l, p, jehanne_strlen(p)); setsecret(&s->out, x, t); - free(x); + jehanne_free(x); } else error(Ebadarg); @@ -1209,11 +1209,11 @@ sslinit(void) n = 1; for(e = encrypttab; e->name != nil; e++) - n += strlen(e->name) + 1; + n += jehanne_strlen(e->name) + 1; cp = encalgs = smalloc(n); for(e = encrypttab;;){ - strcpy(cp, e->name); - cp += strlen(e->name); + jehanne_strcpy(cp, e->name); + cp += jehanne_strlen(e->name); e++; if(e->name == nil) break; @@ -1223,11 +1223,11 @@ sslinit(void) n = 1; for(h = hashtab; h->name != nil; h++) - n += strlen(h->name) + 1; + n += jehanne_strlen(h->name) + 1; cp = hashalgs = smalloc(n); for(h = hashtab;;){ - strcpy(cp, h->name); - cp += strlen(h->name); + jehanne_strcpy(cp, h->name); + cp += jehanne_strlen(h->name); h++; if(h->name == nil) break; @@ -1279,7 +1279,7 @@ encryptb(Dstate *s, Block *b, int offset) for(eip = ip+8; ip < eip; ) *p2++ ^= *ip++; block_cipher(ds->expanded, p, 0); - memmove(ds->ivec, p, 8); + jehanne_memmove(ds->ivec, p, 8); } break; case RC4: @@ -1323,7 +1323,7 @@ decryptb(Dstate *s, Block *bin) ds = s->in.state; ep = b->rp + BLEN(b); for(p = b->rp; p < ep;){ - memmove(tmp, p, 8); + jehanne_memmove(tmp, p, 8); block_cipher(ds->expanded, p, 1); tp = tmp; ip = ds->ivec; @@ -1352,7 +1352,7 @@ digestb(Dstate *s, Block *b, int offset) w = &s->out; - memset(&ss, 0, sizeof(ss)); + jehanne_memset(&ss, 0, sizeof(ss)); h = s->diglen + offset; n = BLEN(b) - h; @@ -1385,7 +1385,7 @@ checkdigestb(Dstate *s, Block *bin) w = &s->in; - memset(&ss, 0, sizeof(ss)); + jehanne_memset(&ss, 0, sizeof(ss)); /* hash secret */ (*s->hf)(w->secret, w->slen, 0, &ss); @@ -1409,7 +1409,7 @@ checkdigestb(Dstate *s, Block *bin) *p = n; (*s->hf)(msgid, 4, digest, &ss); - if(memcmp(digest, bin->rp, s->diglen) != 0) + if(jehanne_memcmp(digest, bin->rp, s->diglen) != 0) error("bad digest"); } @@ -1422,7 +1422,7 @@ buftochan(char *p) if(p == 0) error(Ebadarg); - fd = strtoul(p, 0, 0); + fd = jehanne_strtoul(p, 0, 0); if(fd < 0) error(Ebadarg); c = fdtochan(fd, -1, 0, 1); /* error check and inc ref */ @@ -1482,12 +1482,12 @@ dsnew(Chan *ch, Dstate **pp) Dstate *s; int t; - *pp = s = malloc(sizeof(*s)); + *pp = s = jehanne_malloc(sizeof(*s)); if(!s) error(Enomem); if(pp - dstate >= dshiwat) dshiwat++; - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); s->state = Sincomplete; s->ref = 1; kstrdup(&s->user, up->user); diff --git a/sys/src/kern/port/devtab.c b/sys/src/kern/port/devtab.c index 69abbb0..31c267e 100644 --- a/sys/src/kern/port/devtab.c +++ b/sys/src/kern/port/devtab.c @@ -68,7 +68,7 @@ devbyname(char *name) int i; for(i = 0; devtab[i] != nil; i++) - if(strcmp(devtab[i]->name, name) == 0) + if(jehanne_strcmp(devtab[i]->name, name) == 0) return devtab[i]; return nil; } @@ -80,7 +80,7 @@ devtabread(Chan* _1, void* buf, long n, int64_t off) Dev *dev; char *alloc, *e, *p; - alloc = malloc(READSTR); + alloc = jehanne_malloc(READSTR); if(alloc == nil) error(Enomem); @@ -88,15 +88,15 @@ devtabread(Chan* _1, void* buf, long n, int64_t off) e = p + READSTR; for(i = 0; devtab[i] != nil; i++){ dev = devtab[i]; - p = seprint(p, e, "#%C %s\n", dev->dc, dev->name); + p = jehanne_seprint(p, e, "#%C %s\n", dev->dc, dev->name); } if(waserror()){ - free(alloc); + jehanne_free(alloc); nexterror(); } n = readstr(off, buf, n, alloc); - free(alloc); + jehanne_free(alloc); poperror(); return n; diff --git a/sys/src/kern/port/devtls.c b/sys/src/kern/port/devtls.c index dff663d..5f07e97 100644 --- a/sys/src/kern/port/devtls.c +++ b/sys/src/kern/port/devtls.c @@ -321,7 +321,7 @@ tlsgen(Chan *c, char* _1, Dirtab * _2, int _3, int s, Dir *dp) nm = tr->user; else nm = eve; - snprint(up->genbuf, sizeof(up->genbuf), "%d", s); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d", s); devdir(c, q, up->genbuf, 0, nm, 0555, dp); unlock(&tdlock); return 1; @@ -450,7 +450,7 @@ tlsopen(Chan *c, unsigned long omode) if(tr == nil) error("must open connection using clone"); if((perm & (tr->perm>>6)) != perm - && (strcmp(up->user, tr->user) != 0 + && (jehanne_strcmp(up->user, tr->user) != 0 || (perm & tr->perm) != perm)) error(Eperm); if(t == Qhand){ @@ -494,7 +494,7 @@ tlswstat(Chan *c, uint8_t *dp, long n) d = nil; if(waserror()){ - free(d); + jehanne_free(d); unlock(&tdlock); nexterror(); } @@ -503,11 +503,11 @@ tlswstat(Chan *c, uint8_t *dp, long n) tr = tlsdevs[CONV(c->qid)]; if(tr == nil) error(Ebadusefd); - if(strcmp(tr->user, up->user) != 0) + if(jehanne_strcmp(tr->user, up->user) != 0) error(Eperm); d = smalloc(n + sizeof *d); - rv = convM2D(dp, n, &d[0], (char*) &d[1]); + rv = jehanne_convM2D(dp, n, &d[0], (char*) &d[1]); if(rv == 0) error(Eshortstat); if(!emptystr(d->uid)) @@ -515,7 +515,7 @@ tlswstat(Chan *c, uint8_t *dp, long n) if(d->mode != (uint32_t)~0UL) tr->perm = d->mode; - free(d); + jehanne_free(d); poperror(); unlock(&tdlock); @@ -582,8 +582,8 @@ tlsclose(Chan *c) freeSec(tr->in.new); freeSec(tr->out.sec); freeSec(tr->out.new); - free(tr->user); - free(tr); + jehanne_free(tr->user); + jehanne_free(tr); break; } } @@ -637,7 +637,7 @@ consume(Block **l, uint8_t *p, int n) i = BLEN(b); if(i > n) i = n; - memmove(p, b->rp, i); + jehanne_memmove(p, b->rp, i); b->rp += i; p += i; if(BLEN(b) < 0) @@ -662,13 +662,13 @@ regurgitate(TlsRec *s, uint8_t *p, int n) b = s->unprocessed; if(s->unprocessed == nil || b->rp - b->base < n) { b = allocb(n); - memmove(b->wp, p, n); + jehanne_memmove(b->wp, p, n); b->wp += n; b->next = s->unprocessed; s->unprocessed = b; } else { b->rp -= n; - memmove(b->rp, p, n); + jehanne_memmove(b->rp, p, n); } } @@ -732,7 +732,7 @@ tlsrecread(TlsRec *tr) nconsumed = 0; if(waserror()){ - if(strcmp(up->errstr, Eintr) == 0 && !waserror()){ + if(jehanne_strcmp(up->errstr, Eintr) == 0 && !waserror()){ regurgitate(tr, header, nconsumed); poperror(); }else @@ -806,7 +806,7 @@ if(tr->debug) pdump(unpad_len, p, "decrypted:"); (*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac); if(unpad_len < in->sec->maclen) rcvError(tr, EBadRecordMac, "short record mac"); - if(memcmp(hmac, p+len, in->sec->maclen) != 0) + if(jehanne_memcmp(hmac, p+len, in->sec->maclen) != 0) rcvError(tr, EBadRecordMac, "record mac mismatch"); b->wp = b->rp + len; } @@ -965,7 +965,7 @@ rcvError(TlsRec *tr, int err, char *fmt, ...) va_list arg; va_start(arg, fmt); - vseprint(msg, msg+sizeof(msg), fmt, arg); + jehanne_vseprint(msg, msg+sizeof(msg), fmt, arg); va_end(arg); if(tr->debug) pprint("rcvError: %s\n", msg); @@ -993,14 +993,14 @@ alertHand(TlsRec *tr, char *msg) tr->hqref++; unlock(&tr->hqlock); - n = strlen(msg); + n = jehanne_strlen(msg); if(waserror()){ dechandq(tr); nexterror(); } b = allocb(n + 2); *b->wp++ = RAlert; - memmove(b->wp, msg, n + 1); + jehanne_memmove(b->wp, msg, n + 1); b->wp += n + 1; qbwrite(tr->handq, b); @@ -1136,37 +1136,37 @@ tlsread(Chan *c, void *a, long n, int64_t off) qlock(&tr->out.seclock); s = buf; e = buf + Statlen; - s = seprint(s, e, "State: %s\n", tlsstate(tr->state)); - s = seprint(s, e, "Version: %#x\n", tr->version); + s = jehanne_seprint(s, e, "State: %s\n", tlsstate(tr->state)); + s = jehanne_seprint(s, e, "Version: %#x\n", tr->version); if(tr->in.sec != nil) - s = seprint(s, e, "EncIn: %s\nHashIn: %s\n", tr->in.sec->encalg, tr->in.sec->hashalg); + s = jehanne_seprint(s, e, "EncIn: %s\nHashIn: %s\n", tr->in.sec->encalg, tr->in.sec->hashalg); if(tr->in.new != nil) - s = seprint(s, e, "NewEncIn: %s\nNewHashIn: %s\n", tr->in.new->encalg, tr->in.new->hashalg); + s = jehanne_seprint(s, e, "NewEncIn: %s\nNewHashIn: %s\n", tr->in.new->encalg, tr->in.new->hashalg); if(tr->out.sec != nil) - s = seprint(s, e, "EncOut: %s\nHashOut: %s\n", tr->out.sec->encalg, tr->out.sec->hashalg); + s = jehanne_seprint(s, e, "EncOut: %s\nHashOut: %s\n", tr->out.sec->encalg, tr->out.sec->hashalg); if(tr->out.new != nil) - seprint(s, e, "NewEncOut: %s\nNewHashOut: %s\n", tr->out.new->encalg, tr->out.new->hashalg); + jehanne_seprint(s, e, "NewEncOut: %s\nNewHashOut: %s\n", tr->out.new->encalg, tr->out.new->hashalg); qunlock(&tr->in.seclock); qunlock(&tr->out.seclock); n = readstr(offset, a, n, buf); - free(buf); + jehanne_free(buf); return n; case Qstats: buf = smalloc(Statlen); s = buf; e = buf + Statlen; - s = seprint(s, e, "DataIn: %lld\n", tr->datain); - s = seprint(s, e, "DataOut: %lld\n", tr->dataout); - s = seprint(s, e, "HandIn: %lld\n", tr->handin); - seprint(s, e, "HandOut: %lld\n", tr->handout); + s = jehanne_seprint(s, e, "DataIn: %lld\n", tr->datain); + s = jehanne_seprint(s, e, "DataOut: %lld\n", tr->dataout); + s = jehanne_seprint(s, e, "HandIn: %lld\n", tr->handin); + jehanne_seprint(s, e, "HandOut: %lld\n", tr->handout); n = readstr(offset, a, n, buf); - free(buf); + jehanne_free(buf); return n; case Qctl: buf = smalloc(Statlen); - snprint(buf, Statlen, "%llud", CONV(c->qid)); + jehanne_snprint(buf, Statlen, "%llud", CONV(c->qid)); n = readstr(offset, a, n, buf); - free(buf); + jehanne_free(buf); return n; case Qdata: case Qhand: @@ -1187,7 +1187,7 @@ tlsread(Chan *c, void *a, long n, int64_t off) va = a; for(nb = b; nb; nb = nb->next){ i = BLEN(nb); - memmove(va+n, nb->rp, i); + jehanne_memmove(va+n, nb->rp, i); n += i; } @@ -1248,7 +1248,7 @@ if(tr->debug)pdump(BLEN(b), b->rp, "sent:"); if(n > MaxRecLen){ n = MaxRecLen; nb = allocb(n + pad + RecHdrLen); - memmove(nb->wp + RecHdrLen, bb->rp, n); + jehanne_memmove(nb->wp + RecHdrLen, bb->rp, n); bb->rp += n; }else{ /* @@ -1296,7 +1296,7 @@ if(tr->debug)pdump(BLEN(b), b->rp, "sent:"); * if not, we're out of sync with the receiver and will not recover. */ if(waserror()){ - if(strcmp(up->errstr, "interrupted") != 0) + if(jehanne_strcmp(up->errstr, "interrupted") != 0) tlsError(tr, "channel error"); nexterror(); } @@ -1354,7 +1354,7 @@ initmd5key(Hashalg *ha, int version, Secret *s, uint8_t *p) s->mac = sslmac_md5; else s->mac = hmac_md5; - memmove(s->mackey, p, ha->maclen); + jehanne_memmove(s->mackey, p, ha->maclen); } static void @@ -1372,7 +1372,7 @@ initsha1key(Hashalg *ha, int version, Secret *s, uint8_t *p) s->mac = sslmac_sha1; else s->mac = hmac_sha1; - memmove(s->mackey, p, ha->maclen); + jehanne_memmove(s->mackey, p, ha->maclen); } static Hashalg hashtab[] = @@ -1389,7 +1389,7 @@ parsehashalg(char *p) Hashalg *ha; for(ha = hashtab; ha->name; ha++) - if(strcmp(p, ha->name) == 0) + if(jehanne_strcmp(p, ha->name) == 0) return ha; error("unsupported hash algorithm"); return nil; @@ -1458,7 +1458,7 @@ parseencalg(char *p) Encalg *ea; for(ea = encrypttab; ea->name; ea++) - if(strcmp(p, ea->name) == 0) + if(jehanne_strcmp(p, ea->name) == 0) return ea; error("unsupported encryption algorithm"); return nil; @@ -1498,7 +1498,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) freeb(b); nexterror(); } - memmove(b->wp, p, i); + jehanne_memmove(b->wp, p, i); poperror(); b->wp += i; @@ -1516,7 +1516,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } if(cb->nf < 1) @@ -1531,25 +1531,25 @@ tlswrite(Chan *c, void *a, long n, int64_t off) qlock(&tr->in.seclock); qlock(&tr->out.seclock); - if(strcmp(cb->f[0], "fd") == 0){ + if(jehanne_strcmp(cb->f[0], "fd") == 0){ if(cb->nf != 3) error("usage: fd open-fd version"); if(tr->c != nil) error(Einuse); - i = strtol(cb->f[2], nil, 0); + i = jehanne_strtol(cb->f[2], nil, 0); if(i < MinProtoVersion || i > MaxProtoVersion) error("unsupported version"); tr->c = buftochan(cb->f[1]); tr->version = i; tlsSetState(tr, SHandshake, SClosed); - }else if(strcmp(cb->f[0], "version") == 0){ + }else if(jehanne_strcmp(cb->f[0], "version") == 0){ if(cb->nf != 2) error("usage: version vers"); if(tr->c == nil) error("must set fd before version"); if(tr->verset) error("version already set"); - i = strtol(cb->f[1], nil, 0); + i = jehanne_strtol(cb->f[1], nil, 0); if(i == SSL3Version) tr->packMac = sslPackMac; else if(i == TLSVersion) @@ -1558,7 +1558,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) error("unsupported version"); tr->verset = 1; tr->version = i; - }else if(strcmp(cb->f[0], "secret") == 0){ + }else if(jehanne_strcmp(cb->f[0], "secret") == 0){ if(cb->nf != 5) error("usage: secret hashalg encalg isclient secretdata"); if(tr->c == nil || !tr->verset) @@ -1577,17 +1577,17 @@ tlswrite(Chan *c, void *a, long n, int64_t off) ea = parseencalg(cb->f[2]); p = cb->f[4]; - i = (strlen(p)*3)/2; + i = (jehanne_strlen(p)*3)/2; x = smalloc(i); tos = nil; toc = nil; if(waserror()){ freeSec(tos); freeSec(toc); - free(x); + jehanne_free(x); nexterror(); } - i = dec64(x, i, p, strlen(p)); + i = jehanne_dec64(x, i, p, jehanne_strlen(p)); if(i < 2 * ha->maclen + 2 * ea->keylen + 2 * ea->ivlen) error("not enough secret data provided"); @@ -1603,7 +1603,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) if(!tos->mac || !tos->enc || !tos->dec || !toc->mac || !toc->enc || !toc->dec) error("missing algorithm implementations"); - if(strtol(cb->f[3], nil, 0) == 0){ + if(jehanne_strtol(cb->f[3], nil, 0) == 0){ tr->in.new = tos; tr->out.new = toc; }else{ @@ -1622,9 +1622,9 @@ tlswrite(Chan *c, void *a, long n, int64_t off) tos->encalg = ea->name; tos->hashalg = ha->name; - free(x); + jehanne_free(x); poperror(); - }else if(strcmp(cb->f[0], "changecipher") == 0){ + }else if(jehanne_strcmp(cb->f[0], "changecipher") == 0){ if(cb->nf != 1) error("usage: changecipher"); if(tr->out.new == nil) @@ -1633,7 +1633,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) qunlock(&tr->in.seclock); qunlock(&tr->out.seclock); poperror(); - free(cb); + jehanne_free(cb); poperror(); /* @@ -1644,7 +1644,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) *b->wp++ = 1; tlsrecwrite(tr, RChangeCipherSpec, b); return n; - }else if(strcmp(cb->f[0], "opened") == 0){ + }else if(jehanne_strcmp(cb->f[0], "opened") == 0){ if(cb->nf != 1) error("usage: opened"); if(tr->in.sec == nil || tr->out.sec == nil) @@ -1657,17 +1657,17 @@ tlswrite(Chan *c, void *a, long n, int64_t off) tr->state = SOpen; unlock(&tr->statelk); tr->opened = 1; - }else if(strcmp(cb->f[0], "alert") == 0){ + }else if(jehanne_strcmp(cb->f[0], "alert") == 0){ if(cb->nf != 2) error("usage: alert n"); if(tr->c == nil) error("must set fd before sending alerts"); - i = strtol(cb->f[1], nil, 0); + i = jehanne_strtol(cb->f[1], nil, 0); qunlock(&tr->in.seclock); qunlock(&tr->out.seclock); poperror(); - free(cb); + jehanne_free(cb); poperror(); sendAlert(tr, i); @@ -1676,9 +1676,9 @@ tlswrite(Chan *c, void *a, long n, int64_t off) tlsclosed(tr, SLClose); return n; - } else if(strcmp(cb->f[0], "debug") == 0){ + } else if(jehanne_strcmp(cb->f[0], "debug") == 0){ if(cb->nf == 2){ - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) tr->debug = 1; else tr->debug = 0; @@ -1690,7 +1690,7 @@ tlswrite(Chan *c, void *a, long n, int64_t off) qunlock(&tr->in.seclock); qunlock(&tr->out.seclock); poperror(); - free(cb); + jehanne_free(cb); poperror(); return n; @@ -1706,7 +1706,7 @@ tlsinit(void) static int already; if(!already){ -// fmtinstall('H', encodefmt); +// jehanne_fmtinstall('H', encodefmt); already = 1; } @@ -1714,11 +1714,11 @@ tlsinit(void) n = 1; for(e = encrypttab; e->name != nil; e++) - n += strlen(e->name) + 1; + n += jehanne_strlen(e->name) + 1; cp = encalgs = smalloc(n); for(e = encrypttab;;){ - strcpy(cp, e->name); - cp += strlen(e->name); + jehanne_strcpy(cp, e->name); + cp += jehanne_strlen(e->name); e++; if(e->name == nil) break; @@ -1728,11 +1728,11 @@ tlsinit(void) n = 1; for(h = hashtab; h->name != nil; h++) - n += strlen(h->name) + 1; + n += jehanne_strlen(h->name) + 1; cp = hashalgs = smalloc(n); for(h = hashtab;;){ - strcpy(cp, h->name); - cp += strlen(h->name); + jehanne_strcpy(cp, h->name); + cp += jehanne_strlen(h->name); h++; if(h->name == nil) break; @@ -1771,7 +1771,7 @@ buftochan(char *p) if(p == 0) error(Ebadarg); - fd = strtoul(p, 0, 0); + fd = jehanne_strtoul(p, 0, 0); if(fd < 0) error(Ebadarg); c = fdtochan(fd, -1, 0, 1); /* error check and inc ref */ @@ -1823,7 +1823,7 @@ if(tr->debug)pprint("tleError %s\n", msg); s = tr->state; tr->state = SError; if(s != SError){ - strncpy(tr->err, msg, ERRMAX - 1); + jehanne_strncpy(tr->err, msg, ERRMAX - 1); tr->err[ERRMAX - 1] = '\0'; } unlock(&tr->statelk); @@ -1885,10 +1885,10 @@ newtls(Chan *ch) if(newmax > MaxTlsDevs) newmax = MaxTlsDevs; np = smalloc(sizeof(TlsRec*) * newmax); - memmove(np, tlsdevs, sizeof(TlsRec*) * maxtlsdevs); + jehanne_memmove(np, tlsdevs, sizeof(TlsRec*) * maxtlsdevs); tlsdevs = np; pp = &tlsdevs[maxtlsdevs]; - memset(pp, 0, sizeof(TlsRec*)*(newmax - maxtlsdevs)); + jehanne_memset(pp, 0, sizeof(TlsRec*)*(newmax - maxtlsdevs)); maxtlsdevs = newmax; } @@ -1910,7 +1910,7 @@ mktlsrec(void) { TlsRec *tr; - tr = mallocz(sizeof(*tr), 1); + tr = jehanne_mallocz(sizeof(*tr), 1); if(tr == nil) error(Enomem); tr->state = SClosed; @@ -1946,8 +1946,8 @@ static void freeSec(Secret *s) { if(s != nil){ - free(s->enckey); - free(s); + jehanne_free(s->enckey); + jehanne_free(s); } } @@ -2099,7 +2099,7 @@ sslPackMac(Secret *sec, uint8_t *mackey, uint8_t *seq, uint8_t *header, uint8_t DigestState *s; uint8_t buf[11]; - memmove(buf, seq, 8); + jehanne_memmove(buf, seq, 8); buf[8] = header[0]; buf[9] = header[3]; buf[10] = header[4]; @@ -2114,8 +2114,8 @@ tlsPackMac(Secret *sec, uint8_t *mackey, uint8_t *seq, uint8_t *header, uint8_t DigestState *s; uint8_t buf[13]; - memmove(buf, seq, 8); - memmove(&buf[8], header, 5); + jehanne_memmove(buf, seq, 8); + jehanne_memmove(&buf[8], header, 5); s = (*sec->mac)(buf, 13, mackey, sec->maclen, 0, 0); (*sec->mac)(body, len, mackey, sec->maclen, mac, s); @@ -2177,9 +2177,9 @@ pdump(int len, void *a, char *tag) char *q; p = a; - strcpy(buf, tag); + jehanne_strcpy(buf, tag); while(len > 0){ - q = buf + strlen(tag); + q = buf + jehanne_strlen(tag); for(i = 0; len > 0 && i < 32; i++){ if(*p >= ' ' && *p < 0x7f){ *q++ = ' '; diff --git a/sys/src/kern/port/devtrace.c b/sys/src/kern/port/devtrace.c index 882693e..d3f8a33 100644 --- a/sys/src/kern/port/devtrace.c +++ b/sys/src/kern/port/devtrace.c @@ -210,7 +210,7 @@ traceslot(void *pc, int dopanic) if (dopanic) panic("Bad PC %p", pc); - print("Invalid PC %p\n", pc); + jehanne_print("Invalid PC %p\n", pc); return nil; } index = (int)((uintptr_t)pc - KTZERO); @@ -219,7 +219,7 @@ traceslot(void *pc, int dopanic) panic("Bad PC %p", pc); while(1); } - print("Invalid PC %p\n", pc); + jehanne_print("Invalid PC %p\n", pc); return nil; } p = &tracemap[index]; @@ -283,7 +283,7 @@ removetrace(Trace *p) { } else { traces = nil; //this seems to work fine } - free(curr); + jehanne_free(curr); return; } @@ -436,7 +436,7 @@ static Trace * mktrace(void *func, void *start, void *end) { Trace *p; - p = mallocz(sizeof p[0], 1); + p = jehanne_mallocz(sizeof p[0], 1); p->func = func; p->start = start; p->end = end; @@ -448,7 +448,7 @@ mktrace(void *func, void *start, void *end) static void freetrace(Trace *p) { - free(p); + jehanne_free(p); } #endif @@ -480,17 +480,17 @@ traceopen(Chan *c, unsigned long omode) codesize = (uintptr_t)etext - (uintptr_t)KTZERO; if (! tracemap) - //tracemap = mallocz(sizeof(struct tracemap *)*codesize, 1); - tracemap = mallocz(sizeof(struct Trace *)*codesize, 1); + //tracemap = jehanne_mallocz(sizeof(struct tracemap *)*codesize, 1); + tracemap = jehanne_mallocz(sizeof(struct Trace *)*codesize, 1); if (! tracemap) error("tracemap malloc failed"); if (! tracelog) - tracelog = mallocz(sizeof(*tracelog)*logsize, 1); + tracelog = jehanne_mallocz(sizeof(*tracelog)*logsize, 1); /* I guess malloc doesn't toss an error */ if (! tracelog) error("tracelog malloc failed"); if (! pidwatch) - pidwatch = mallocz(sizeof(int)*PIDWATCHSIZE, 1); + pidwatch = jehanne_mallocz(sizeof(int)*PIDWATCHSIZE, 1); if (! pidwatch) error("pidwatch malloc failed"); c = devopen(c, omode, tracedir, nelem(tracedir), devgen); @@ -505,7 +505,7 @@ traceclose(Chan * _1) /* * Reading from the device, either the data or control files. * The data reading involves deep rminnich magic so we don't have - * to call print(), which is traced. + * to call jehanne_print(), which is traced. */ static long traceread(Chan *c, void *a, long n, int64_t offset) @@ -537,31 +537,31 @@ traceread(Chan *c, void *a, long n, int64_t offset) case Qctl: i = 0; qlock(&traceslock); - buf = malloc(READSTR); - i += snprint(buf + i, READSTR - i, "logsize %lud\n", logsize); + buf = jehanne_malloc(READSTR); + i += jehanne_snprint(buf + i, READSTR - i, "logsize %lud\n", logsize); for(p = traces; p != nil; p = p->next) - i += snprint(buf + i, READSTR - i, "trace %p %p new %s\n", + i += jehanne_snprint(buf + i, READSTR - i, "trace %p %p new %s\n", p->start, p->end, p->name); for(p = traces; p != nil; p = p->next) - i += snprint(buf + i, READSTR - i, "#trace %p traced? %p\n", + i += jehanne_snprint(buf + i, READSTR - i, "#trace %p traced? %p\n", p->func, traced(p->func, 0)); for(p = traces; p != nil; p = p->next) if (p->enabled) - i += snprint(buf + i, READSTR - i, "trace %s on\n", + i += jehanne_snprint(buf + i, READSTR - i, "trace %s on\n", p->name); - i += snprint(buf + i, READSTR - i, "#tracehits %d, in queue %d\n", + i += jehanne_snprint(buf + i, READSTR - i, "#tracehits %d, in queue %d\n", pw, pw-pr); - i += snprint(buf + i, READSTR - i, "#tracelog %p\n", tracelog); - i += snprint(buf + i, READSTR - i, "#traceactive %d\n", saveactive); - i += snprint(buf + i, READSTR - i, "#slothits %d\n", slothits); - i += snprint(buf + i, READSTR - i, "#traceinhits %d\n", traceinhits); + i += jehanne_snprint(buf + i, READSTR - i, "#tracelog %p\n", tracelog); + i += jehanne_snprint(buf + i, READSTR - i, "#traceactive %d\n", saveactive); + i += jehanne_snprint(buf + i, READSTR - i, "#slothits %d\n", slothits); + i += jehanne_snprint(buf + i, READSTR - i, "#traceinhits %d\n", traceinhits); for (j = 0; j < numpids - 1; j++) - i += snprint(buf + i, READSTR - i, "watch %d\n", pidwatch[j]); - snprint(buf + i, READSTR - i, "watch %d\n", pidwatch[numpids - 1]); + i += jehanne_snprint(buf + i, READSTR - i, "watch %d\n", pidwatch[j]); + jehanne_snprint(buf + i, READSTR - i, "watch %d\n", pidwatch[numpids - 1]); n = readstr(offset, a, n, buf); - free(buf); + jehanne_free(buf); qunlock(&traceslock); break; case Qdata: @@ -671,7 +671,7 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) qlock(&traceslock); if(waserror()){ qunlock(&traceslock); - if(s != nil) free(s); + if(s != nil) jehanne_free(s); traceactive = saveactive; nexterror(); } @@ -679,33 +679,33 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) default: error("tracewrite: bad qid"); case Qctl: - s = malloc(n + 1); - memmove(s, a, n); + s = jehanne_malloc(n + 1); + jehanne_memmove(s, a, n); s[n] = 0; - ntok = tokenize(s, tok, nelem(tok)); - if(!strcmp(tok[0], "trace")){ /* 'trace' ktextaddr 'on'|'off'|'mk'|'del' [name] */ + ntok = jehanne_tokenize(s, tok, nelem(tok)); + if(!jehanne_strcmp(tok[0], "trace")){ /* 'trace' ktextaddr 'on'|'off'|'mk'|'del' [name] */ if(ntok < 3) { error("devtrace: usage: 'trace' [ktextaddr|name] 'on'|'off'|'mk'|'del' [name]"); } for(pp = &traces; *pp != nil; pp = &(*pp)->next){ - if(!strcmp(tok[1], (*pp)->name)) + if(!jehanne_strcmp(tok[1], (*pp)->name)) break; } p = *pp; - if((ntok > 3) && (!strcmp(tok[3], "new"))){ + if((ntok > 3) && (!jehanne_strcmp(tok[3], "new"))){ uintptr_t addr; void *start, *end, *func; if (ntok != 5) { error("devtrace: usage: trace new "); } - addr = (uintptr_t)strtoul(tok[1], &ep, 16); + addr = (uintptr_t)jehanne_strtoul(tok[1], &ep, 16); if (addr < KTZERO) addr |= KTZERO; func = start = (void *)addr; if(*ep) { error("devtrace: start address not in recognized format"); } - addr = (uintptr_t)strtoul(tok[2], &ep, 16); + addr = (uintptr_t)jehanne_strtoul(tok[2], &ep, 16); if (addr < KTZERO) addr |= KTZERO; end = (void *)addr; @@ -725,28 +725,28 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) } p = mktrace(func, start, end); for (foo = traces; foo != nil; foo = foo->next) { - if (!strcmp(tok[4], foo->name)) + if (!jehanne_strcmp(tok[4], foo->name)) error("devtrace: trace with that name already exists"); } if (!overlapping(p)) { p->next = traces; if(ntok < 5) - snprint(p->name, sizeof p->name, "%p", func); + jehanne_snprint(p->name, sizeof p->name, "%p", func); else - strncpy(p->name, tok[4], sizeof p->name); + jehanne_strncpy(p->name, tok[4], sizeof p->name); traces = p; } else { error("devtrace: given range overlaps with existing trace"); } - } else if(!strcmp(tok[2], "remove")){ + } else if(!jehanne_strcmp(tok[2], "remove")){ if (ntok != 3) error("devtrace: usage: trace remove"); if (p == nil) { error("devtrace: trace not found"); } removetrace(p); - } else if(!strcmp(tok[2], "on")){ + } else if(!jehanne_strcmp(tok[2], "on")){ if (ntok != 3) error("devtrace: usage: trace on"); @@ -756,7 +756,7 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) if (! traced(p->func, 0)){ traceon(p); } - } else if(!strcmp(tok[2], "off")){ + } else if(!jehanne_strcmp(tok[2], "off")){ if (ntok != 3) error("devtrace: usage: trace off"); if(p == nil) { @@ -766,40 +766,40 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) traceoff(p); } } - } else if(!strcmp(tok[0], "query")){ + } else if(!jehanne_strcmp(tok[0], "query")){ /* See if addr is being traced */ Trace* p; uintptr_t addr; if (ntok != 2) { error("devtrace: usage: query "); } - addr = (uintptr_t)strtoul(tok[1], &ep, 16); + addr = (uintptr_t)jehanne_strtoul(tok[1], &ep, 16); if (addr < KTZERO) addr |= KTZERO; p = traced((void *)addr, 0); if (p) { - print("Probing is enabled\n"); + jehanne_print("Probing is enabled\n"); } else { - print("Probing is disabled\n"); + jehanne_print("Probing is disabled\n"); } - } else if(!strcmp(tok[0], "size")){ + } else if(!jehanne_strcmp(tok[0], "size")){ int l, size; struct Tracelog *newtracelog; if (ntok != 2) error("devtrace: usage: size "); - l = strtoul(tok[1], &ep, 0); + l = jehanne_strtoul(tok[1], &ep, 0); if(*ep) { error("devtrace: size not in recognized format"); } size = 1 << l; /* sort of foolish. Alloc new trace first, then free old. */ /* and too bad if there are unread traces */ - newtracelog = mallocz(sizeof(*newtracelog)*size, 1); + newtracelog = jehanne_mallocz(sizeof(*newtracelog)*size, 1); /* does malloc throw waserror? I don't know */ if (newtracelog){ - free(tracelog); + jehanne_free(tracelog); tracelog = newtracelog; logsize = size; logmask = size - 1; @@ -807,7 +807,7 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) } else { error("devtrace: can't allocate that much"); } - } else if (!strcmp(tok[0], "testtracein")) { + } else if (!jehanne_strcmp(tok[0], "testtracein")) { /* Manually jump to a certain bit of traced code */ uintptr_t pc, a1, a2, a3, a4; int x; @@ -815,13 +815,13 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) if (ntok != 6) error("devtrace: usage: testtracein "); - pc = (uintptr_t)strtoul(tok[1], &ep, 16); + pc = (uintptr_t)jehanne_strtoul(tok[1], &ep, 16); if (pc < KTZERO) pc |= KTZERO; - a1 = (uintptr_t)strtoul(tok[2], &ep, 16); - a2 = (uintptr_t)strtoul(tok[3], &ep, 16); - a3 = (uintptr_t)strtoul(tok[4], &ep, 16); - a4 = (uintptr_t)strtoul(tok[5], &ep, 16); + a1 = (uintptr_t)jehanne_strtoul(tok[2], &ep, 16); + a2 = (uintptr_t)jehanne_strtoul(tok[3], &ep, 16); + a3 = (uintptr_t)jehanne_strtoul(tok[4], &ep, 16); + a4 = (uintptr_t)jehanne_strtoul(tok[5], &ep, 16); if (traced((void *)pc, 0)) { x = splhi(); @@ -830,7 +830,7 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) watching = 0; splx(x); } - } else if (!strcmp(tok[0], "watch")) { + } else if (!jehanne_strcmp(tok[0], "watch")) { /* Watch a certain PID */ int pid; @@ -838,9 +838,9 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) error("devtrace: usage: watch [0|]"); } - pid = atoi(tok[1]); + pid = jehanne_atoi(tok[1]); if (pid == 0) { - pidwatch = mallocz(sizeof(int)*PIDWATCHSIZE, 1); + pidwatch = jehanne_mallocz(sizeof(int)*PIDWATCHSIZE, 1); numpids = 0; } else if (pid < 0) { error("PID must be greater than zero."); @@ -850,16 +850,16 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) } else { error("pidwatch array full!"); } - } else if (!strcmp(tok[0], "start")) { + } else if (!jehanne_strcmp(tok[0], "start")) { if (ntok != 1) error("devtrace: usage: start"); saveactive = 1; - } else if (!strcmp(tok[0], "stop")) { + } else if (!jehanne_strcmp(tok[0], "stop")) { if (ntok != 1) error("devtrace: usage: stop"); saveactive = 0; all = 0; - } else if (!strcmp(tok[0], "all")) { + } else if (!jehanne_strcmp(tok[0], "all")) { if (ntok != 1) error("devtrace: usage: all"); saveactive = 1; @@ -867,7 +867,7 @@ tracewrite(Chan *c, void *a, long n, int64_t _1) } else { error("devtrace: usage: 'trace' [ktextaddr|name] 'on'|'off'|'mk'|'del' [name] or: 'size' buffersize (power of 2)"); } - free(s); + jehanne_free(s); break; } poperror(); diff --git a/sys/src/kern/port/devuart.c b/sys/src/kern/port/devuart.c index 1cb42f5..2f64070 100644 --- a/sys/src/kern/port/devuart.c +++ b/sys/src/kern/port/devuart.c @@ -195,15 +195,15 @@ uartreset(void) } if(uartnuart) - uart = malloc(uartnuart*sizeof(Uart*)); + uart = jehanne_malloc(uartnuart*sizeof(Uart*)); uartndir = 1 + 3*uartnuart; - uartdir = malloc(uartndir * sizeof(Dirtab)); + uartdir = jehanne_malloc(uartndir * sizeof(Dirtab)); if(uartnuart && (uart == nil || uartdir == nil)){ panic("uartreset: no memory"); } dp = uartdir; - strcpy(dp->name, "."); + jehanne_strcpy(dp->name, "."); mkqid(&dp->qid, 0, 0, QTDIR); dp->length = 0; dp->perm = DMDIR|0555; @@ -211,15 +211,15 @@ uartreset(void) p = uartlist; for(i = 0; i < uartnuart; i++){ /* 3 directory entries per port */ - sprint(dp->name, "eia%d", i); + jehanne_sprint(dp->name, "eia%d", i); dp->qid.path = UARTQID(i, Qdata); dp->perm = 0660; dp++; - sprint(dp->name, "eia%dctl", i); + jehanne_sprint(dp->name, "eia%dctl", i); dp->qid.path = UARTQID(i, Qctl); dp->perm = 0660; dp++; - sprint(dp->name, "eia%dstatus", i); + jehanne_sprint(dp->name, "eia%dstatus", i); dp->qid.path = UARTQID(i, Qstat); dp->perm = 0444; dp++; @@ -388,14 +388,14 @@ uartctl(Uart *p, char *cmd) char *f[16]; int i, n, nf; - nf = tokenize(cmd, f, nelem(f)); + nf = jehanne_tokenize(cmd, f, nelem(f)); for(i = 0; i < nf; i++){ - if(strncmp(f[i], "break", 5) == 0){ + if(jehanne_strncmp(f[i], "break", 5) == 0){ (*p->phys->dobreak)(p, 0); continue; } - n = atoi(f[i]+1); + n = jehanne_atoi(f[i]+1); switch(*f[i]){ case 'B': case 'b': @@ -522,13 +522,13 @@ uartwrite(Chan *c, void *buf, long n, int64_t _1) poperror(); break; case Qctl: - cmd = malloc(n+1); - memmove(cmd, buf, n); + cmd = jehanne_malloc(n+1); + jehanne_memmove(cmd, buf, n); cmd[n] = 0; qlock(&p->ql); if(waserror()){ qunlock(&p->ql); - free(cmd); + jehanne_free(cmd); nexterror(); } @@ -538,7 +538,7 @@ uartwrite(Chan *c, void *buf, long n, int64_t _1) qunlock(&p->ql); poperror(); - free(cmd); + jehanne_free(cmd); break; } @@ -559,7 +559,7 @@ uartwstat(Chan *c, uint8_t *dp, long n) error(Eperm); dt = &uartdir[1 + 3 * UARTID(c->qid.path)]; - n = convM2D(dp, n, &d, nil); + n = jehanne_convM2D(dp, n, &d, nil); if(n == 0) error(Eshortstat); if(d.mode != (uint32_t)~0UL) diff --git a/sys/src/kern/port/devusb.c b/sys/src/kern/port/devusb.c index 87c82cd..46322d5 100644 --- a/sys/src/kern/port/devusb.c +++ b/sys/src/kern/port/devusb.c @@ -181,9 +181,9 @@ char* seprintdata(char *s, char *se, uint8_t *d, int n) { if(n > 10) - return seprint(s, se, " %#p[%d]: %.10H...", d, n, d); + return jehanne_seprint(s, se, " %#p[%d]: %.10H...", d, n, d); else - return seprint(s, se, " %#p[%d]: %.*H", d, n, n, d); + return jehanne_seprint(s, se, " %#p[%d]: %.*H", d, n, n, d); } static int @@ -192,7 +192,7 @@ name2speed(char *name) int i; for(i = 0; i < nelem(spname); i++) - if(strcmp(name, spname[i]) == 0) + if(jehanne_strcmp(name, spname[i]) == 0) return i; return Nospeed; } @@ -203,10 +203,10 @@ name2ttype(char *name) int i; for(i = 0; i < nelem(ttname); i++) - if(strcmp(name, ttname[i]) == 0) + if(jehanne_strcmp(name, ttname[i]) == 0) return i; /* may be a std. USB ep. type */ - i = strtol(name, nil, 0); + i = jehanne_strtol(name, nil, 0); switch(i+1){ case Tctl: case Tiso: @@ -224,7 +224,7 @@ name2mode(char *mode) int i; for(i = OREAD; i < nelem(usbmodename); i++) - if(strcmp(mode, usbmodename[i]) == 0) + if(jehanne_strcmp(mode, usbmodename[i]) == 0) return i; return -1; } @@ -276,42 +276,42 @@ seprintep(char *s, char *se, Ep *ep, int all) } di = ep->dev->nb; if(all) - s = seprint(s, se, "dev %d ep %d ", di, ep->nb); - s = seprint(s, se, "%s", dsnames[ep->dev->state]); - s = seprint(s, se, " %s", ttname[ep->ttype]); + s = jehanne_seprint(s, se, "dev %d ep %d ", di, ep->nb); + s = jehanne_seprint(s, se, "%s", dsnames[ep->dev->state]); + s = jehanne_seprint(s, se, " %s", ttname[ep->ttype]); assert(ep->mode == OREAD || ep->mode == OWRITE || ep->mode == ORDWR); - s = seprint(s, se, " %s", usbmodename[ep->mode]); - s = seprint(s, se, " speed %s", spname[d->speed]); - s = seprint(s, se, " maxpkt %ld", ep->maxpkt); - s = seprint(s, se, " pollival %ld", ep->pollival); - s = seprint(s, se, " samplesz %ld", ep->samplesz); - s = seprint(s, se, " hz %ld", ep->hz); - s = seprint(s, se, " hub %d", ep->dev->hub); - s = seprint(s, se, " port %d", ep->dev->port); + s = jehanne_seprint(s, se, " %s", usbmodename[ep->mode]); + s = jehanne_seprint(s, se, " speed %s", spname[d->speed]); + s = jehanne_seprint(s, se, " maxpkt %ld", ep->maxpkt); + s = jehanne_seprint(s, se, " pollival %ld", ep->pollival); + s = jehanne_seprint(s, se, " samplesz %ld", ep->samplesz); + s = jehanne_seprint(s, se, " hz %ld", ep->hz); + s = jehanne_seprint(s, se, " hub %d", ep->dev->hub); + s = jehanne_seprint(s, se, " port %d", ep->dev->port); if(ep->inuse) - s = seprint(s, se, " busy"); + s = jehanne_seprint(s, se, " busy"); else - s = seprint(s, se, " idle"); + s = jehanne_seprint(s, se, " idle"); if(all){ - s = seprint(s, se, " load %uld", ep->load); - s = seprint(s, se, " ref %d addr %#p", ep->ref, ep); - s = seprint(s, se, " idx %d", ep->idx); + s = jehanne_seprint(s, se, " load %uld", ep->load); + s = jehanne_seprint(s, se, " ref %d addr %#p", ep->ref, ep); + s = jehanne_seprint(s, se, " idx %d", ep->idx); if(ep->name != nil) - s = seprint(s, se, " name '%s'", ep->name); + s = jehanne_seprint(s, se, " name '%s'", ep->name); if(ep->tmout != 0) - s = seprint(s, se, " tmout"); + s = jehanne_seprint(s, se, " tmout"); if(ep == ep->ep0){ - s = seprint(s, se, " ctlrno %#x", ep->hp->ctlrno); - s = seprint(s, se, " eps:"); + s = jehanne_seprint(s, se, " ctlrno %#x", ep->hp->ctlrno); + s = jehanne_seprint(s, se, " eps:"); for(i = 0; i < nelem(d->eps); i++) if(d->eps[i] != nil) - s = seprint(s, se, " ep%d.%d", di, i); + s = jehanne_seprint(s, se, " ep%d.%d", di, i); } } if(ep->info != nil) - s = seprint(s, se, "\n%s %s\n", ep->info, ep->hp->type); + s = jehanne_seprint(s, se, "\n%s %s\n", ep->info, ep->hp->type); else - s = seprint(s, se, "\n"); + s = jehanne_seprint(s, se, "\n"); qunlock(ep); poperror(); return s; @@ -331,8 +331,8 @@ epalloc(Hci *hp) break; if(i == Neps){ qunlock(&epslck); - free(ep); - print("usb: bug: too few endpoints.\n"); + jehanne_free(ep); + jehanne_print("usb: bug: too few endpoints.\n"); return nil; } ep->idx = i; @@ -386,9 +386,9 @@ putep(Ep *ep) putep(ep->ep0); ep->ep0 = nil; } - free(ep->info); - free(ep->name); - free(ep); + jehanne_free(ep->info); + jehanne_free(ep->name); + jehanne_free(ep); } } @@ -401,7 +401,7 @@ dumpeps(void) char *e; Ep *ep; - print("usb dump eps: epmax %d Neps %d (ref=1+ for dump):\n", epmax, Neps); + jehanne_print("usb dump eps: epmax %d Neps %d (ref=1+ for dump):\n", epmax, Neps); for(i = 0; i < epmax; i++){ s = buf; e = buf+sizeof(buf); @@ -411,18 +411,18 @@ dumpeps(void) putep(ep); nexterror(); } - s = seprint(s, e, "ep%d.%d ", ep->dev->nb, ep->nb); + s = jehanne_seprint(s, e, "ep%d.%d ", ep->dev->nb, ep->nb); seprintep(s, e, ep, 1); - print("%s", buf); + jehanne_print("%s", buf); if(ep->hp->seprintep != nil){ ep->hp->seprintep(buf, e, ep); - print("%s", buf); + jehanne_print("%s", buf); } poperror(); putep(ep); } } - print("usb dump hcis:\n"); + jehanne_print("usb dump hcis:\n"); for(i = 0; i < Nhcis; i++) if(hcis[i] != nil && hcis[i]->dump != nil) hcis[i]->dump(hcis[i]); @@ -436,7 +436,7 @@ newusbid(Hci * _) qlock(&epslck); id = ++usbidgen; if(id >= 0x7F) - print("#u: too many device addresses; reuse them more\n"); + jehanne_print("#u: too many device addresses; reuse them more\n"); qunlock(&epslck); return id; } @@ -605,7 +605,7 @@ usbgen(Chan *c, char * _, Dirtab* __, int ___, int s, Dir *dp) nexterror(); } se = up->genbuf+sizeof(up->genbuf); - seprint(up->genbuf, se, "ep%d.%d", ep->dev->nb, ep->nb); + jehanne_seprint(up->genbuf, se, "ep%d.%d", ep->dev->nb, ep->nb); mkqid(&q, Qep0dir+4*s, 0, QTDIR); putep(ep); poperror(); @@ -670,7 +670,7 @@ hciprobe(int cardno, int ctlrno) if(cardno < 0){ // if(pciconfig("usb", ctlrno, hp) == 0){ if(1){ - free(hp); + jehanne_free(hp); return nil; } for(cardno = 0; cardno < Nhcis; cardno++){ @@ -679,18 +679,18 @@ hciprobe(int cardno, int ctlrno) type = hp->type; if(type==nil || *type==0) type = "uhci"; - if(cistrcmp(hcitypes[cardno].type, type) == 0) + if(jehanne_cistrcmp(hcitypes[cardno].type, type) == 0) break; } } if(cardno >= Nhcis || hcitypes[cardno].type == nil){ - free(hp); + jehanne_free(hp); return nil; } dprint("%s...", hcitypes[cardno].type); if(hcitypes[cardno].reset(hp) < 0){ - free(hp); + jehanne_free(hp); return nil; } @@ -701,7 +701,7 @@ hciprobe(int cardno, int ctlrno) */ /*port*/ if(hp->irq == 2) /*port*/ hp->irq = 9; - snprint(name, sizeof(name), "usb%s", hcitypes[cardno].type); + jehanne_snprint(name, sizeof(name), "usb%s", hcitypes[cardno].type); intrenable(hp->irq, hp->interrupt, hp, hp->tbdf, name); /* @@ -738,7 +738,7 @@ usbreset(void) hcis[ctlrno++] = hp; } if(hcis[Nhcis-1] != nil) - print("usbreset: bug: Nhcis (%d) too small\n", Nhcis); + jehanne_print("usbreset: bug: Nhcis (%d) too small\n", Nhcis); } static void @@ -758,7 +758,7 @@ usbinit(void) d = newdev(hp, 1, 1); /* new root hub */ d->dev->state = Denabled; /* although addr == 0 */ d->maxpkt = 64; - snprint(info, sizeof(info), "ports %d", hp->nports); + jehanne_snprint(info, sizeof(info), "ports %d", hp->nports); kstrdup(&d->info, info); } } @@ -810,7 +810,7 @@ usbload(int speed, int maxpkt) l = 64107 + 2 * Hubns + 667 * (3 + bs) + Hostns; break; default: - print("usbload: bad speed %d\n", speed); + jehanne_print("usbload: bad speed %d\n", speed); /* let it run */ } return l / 1000UL; /* in microseconds */ @@ -907,7 +907,7 @@ usbclose(Chan *c) nexterror(); } if(c->flag & COPEN){ - free(c->aux); + jehanne_free(c->aux); c->aux = nil; epclose(ep); putep(ep); /* release ref kept since usbopen */ @@ -931,7 +931,7 @@ ctlread(Chan *c, void *a, long n, int64_t offset) us = s = smalloc(READSTR); se = s + READSTR; if(waserror()){ - free(us); + jehanne_free(us); nexterror(); } if(q == Qctl) @@ -942,7 +942,7 @@ ctlread(Chan *c, void *a, long n, int64_t offset) putep(ep); nexterror(); } - s = seprint(s, se, "ep%d.%d ", ep->dev->nb, ep->nb); + s = jehanne_seprint(s, se, "ep%d.%d ", ep->dev->nb, ep->nb); s = seprintep(s, se, ep, 0); poperror(); } @@ -960,8 +960,8 @@ ctlread(Chan *c, void *a, long n, int64_t offset) /* After a new endpoint request we read * the new endpoint name back. */ - strecpy(s, se, c->aux); - free(c->aux); + jehanne_strecpy(s, se, c->aux); + jehanne_free(c->aux); c->aux = nil; }else seprintep(s, se, ep, 0); @@ -970,7 +970,7 @@ ctlread(Chan *c, void *a, long n, int64_t offset) } n = readstr(offset, a, n, us); poperror(); - free(us); + jehanne_free(us); return n; } @@ -988,7 +988,7 @@ rhubread(Ep *ep, void *a, long n) return -1; b = a; - memset(b, 0, n); + jehanne_memset(b, 0, n); PUT2(b, ep->rhrepl); ep->rhrepl = -1; return n; @@ -1100,7 +1100,7 @@ setmaxpkt(Ep *ep, char* s) ep->hz, ep->pollival, ep->ntds, spname[ep->dev->speed], spp, ep->maxpkt); if(ep->maxpkt > 1024){ - print("usb: %s: maxpkt %ld > 1024. truncating\n", s, ep->maxpkt); + jehanne_print("usb: %s: maxpkt %ld > 1024. truncating\n", s, ep->maxpkt); ep->maxpkt = 1024; } } @@ -1125,7 +1125,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, epctls, nelem(epctls)); @@ -1141,7 +1141,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) switch(i){ case CMnew: deprint("usb epctl %s\n", cb->f[0]); - nb = strtol(cb->f[1], nil, 0); + nb = jehanne_strtol(cb->f[1], nil, 0); if(nb < 0 || nb >= Ndeveps) error("bad endpoint number"); tt = name2ttype(cb->f[2]); @@ -1164,12 +1164,12 @@ epctl(Ep *ep, Chan *c, void *a, long n) if(nep->dev->speed != Lowspeed) nep->maxpkt = 64; /* assume full speed */ nep->dev->hub = d->nb; - nep->dev->port = atoi(cb->f[2]); + nep->dev->port = jehanne_atoi(cb->f[2]); /* next read request will read * the name for the new endpoint */ l = sizeof(up->genbuf); - snprint(up->genbuf, l, "ep%d.%d", nep->dev->nb, nep->nb); + jehanne_snprint(up->genbuf, l, "ep%d.%d", nep->dev->nb, nep->nb); kstrdup((char**)&c->aux, up->genbuf); break; case CMhub: @@ -1186,7 +1186,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) qunlock(ep->ep0); break; case CMmaxpkt: - l = strtoul(cb->f[1], nil, 0); + l = jehanne_strtoul(cb->f[1], nil, 0); deprint("usb epctl %s %d\n", cb->f[0], l); if(l < 1 || l > 1024) error("maxpkt not in [1:1024]"); @@ -1195,7 +1195,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) qunlock(ep); break; case CMntds: - l = strtoul(cb->f[1], nil, 0); + l = jehanne_strtoul(cb->f[1], nil, 0); deprint("usb epctl %s %d\n", cb->f[0], l); if(l < 1 || l > 3) error("ntds not in [1:3]"); @@ -1206,7 +1206,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) case CMpollival: if(ep->ttype != Tintr && ep->ttype != Tiso) error("not an intr or iso endpoint"); - l = strtoul(cb->f[1], nil, 0); + l = jehanne_strtoul(cb->f[1], nil, 0); deprint("usb epctl %s %d\n", cb->f[0], l); if(ep->ttype == Tiso || (ep->ttype == Tintr && ep->dev->speed == Highspeed)){ @@ -1225,7 +1225,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) case CMsamplesz: if(ep->ttype != Tiso) error("not an iso endpoint"); - l = strtoul(cb->f[1], nil, 0); + l = jehanne_strtoul(cb->f[1], nil, 0); deprint("usb epctl %s %d\n", cb->f[0], l); if(l <= 0 || l > 8) error("samplesz not in [1:8]"); @@ -1237,7 +1237,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) case CMhz: if(ep->ttype != Tiso) error("not an iso endpoint"); - l = strtoul(cb->f[1], nil, 0); + l = jehanne_strtoul(cb->f[1], nil, 0); deprint("usb epctl %s %d\n", cb->f[0], l); if(l <= 0 || l > 100000) error("hz not in [1:100000]"); @@ -1254,19 +1254,19 @@ epctl(Ep *ep, Chan *c, void *a, long n) break; case CMinfo: deprint("usb epctl %s\n", cb->f[0]); - l = strlen(Info); + l = jehanne_strlen(Info); s = a; - if(n < l+2 || strncmp(Info, s, l) != 0) + if(n < l+2 || jehanne_strncmp(Info, s, l) != 0) error(Ebadctl); if(n > 1024) n = 1024; b = smalloc(n); - memmove(b, s+l, n-l); + jehanne_memmove(b, s+l, n-l); b[n-l] = 0; if(b[n-l-1] == '\n') b[n-l-1] = 0; qlock(ep); - free(ep->info); + jehanne_free(ep->info); ep->info = b; qunlock(ep); break; @@ -1285,13 +1285,13 @@ epctl(Ep *ep, Chan *c, void *a, long n) putep(ep->dev->eps[i]); break; case CMdebugep: - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) ep->debug = 1; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) ep->debug = 0; else - ep->debug = strtoul(cb->f[1], nil, 0); - print("usb: ep%d.%d debug %d\n", + ep->debug = jehanne_strtoul(cb->f[1], nil, 0); + jehanne_print("usb: ep%d.%d debug %d\n", ep->dev->nb, ep->nb, ep->debug); break; case CMname: @@ -1303,14 +1303,14 @@ epctl(Ep *ep, Chan *c, void *a, long n) deprint("usb epctl %s\n", cb->f[0]); if(ep->ttype == Tiso || ep->ttype == Tctl) error("ctl ignored for this endpoint type"); - ep->tmout = strtoul(cb->f[1], nil, 0); + ep->tmout = jehanne_strtoul(cb->f[1], nil, 0); if(ep->tmout != 0 && ep->tmout < Xfertmout) ep->tmout = Xfertmout; break; case CMsampledelay: if(ep->ttype != Tiso) error("ctl ignored for this endpoint type"); - ep->sampledelay = strtoul(cb->f[1], nil, 0); + ep->sampledelay = jehanne_strtoul(cb->f[1], nil, 0); break; case CMpreset: deprint("usb epctl %s\n", cb->f[0]); @@ -1323,7 +1323,7 @@ epctl(Ep *ep, Chan *c, void *a, long n) default: panic("usb: unknown epctl %d", ct->index); } - free(cb); + jehanne_free(cb); poperror(); return n; } @@ -1338,20 +1338,20 @@ usbctl(void *a, long n) cb = parsecmd(a, n); if(waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } ct = lookupcmd(cb, usbctls, nelem(usbctls)); dprint("usb ctl %s\n", cb->f[0]); switch(ct->index){ case CMdebug: - if(strcmp(cb->f[1], "on") == 0) + if(jehanne_strcmp(cb->f[1], "on") == 0) debug = 1; - else if(strcmp(cb->f[1], "off") == 0) + else if(jehanne_strcmp(cb->f[1], "off") == 0) debug = 0; else - debug = strtol(cb->f[1], nil, 0); - print("usb: debug %d\n", debug); + debug = jehanne_strtol(cb->f[1], nil, 0); + jehanne_print("usb: debug %d\n", debug); for(i = 0; i < epmax; i++) if((ep = getep(i)) != nil){ if(ep->hp->debug != nil) @@ -1363,7 +1363,7 @@ usbctl(void *a, long n) dumpeps(); break; } - free(cb); + jehanne_free(cb); poperror(); return n; } @@ -1389,7 +1389,7 @@ ctlwrite(Chan *c, void *a, long n) error(Edetach); if(isqtype(q, Qepctl) && c->aux != nil){ /* Be sure we don't keep a cloned ep name */ - free(c->aux); + jehanne_free(c->aux); c->aux = nil; error("read, not write, expected"); } @@ -1455,7 +1455,7 @@ usbshutdown(void) if(hp == nil) continue; if(hp->shutdown == nil) - print("#u: no shutdown function for %s\n", hp->type); + jehanne_print("#u: no shutdown function for %s\n", hp->type); else hp->shutdown(hp); } diff --git a/sys/src/kern/port/devwd.c b/sys/src/kern/port/devwd.c index e9d0d41..8a10015 100644 --- a/sys/src/kern/port/devwd.c +++ b/sys/src/kern/port/devwd.c @@ -35,7 +35,7 @@ void addwatchdog(Watchdog *wdog) { if(wd){ - print("addwatchdog: watchdog already installed\n"); + jehanne_print("addwatchdog: watchdog already installed\n"); return; } wd = watchdog = wdog; @@ -77,7 +77,7 @@ wdautostart(void) if (wdautopet || !wd || !wdallowed()) return; if (waserror()) { - print("watchdog: automatic enable failed\n"); + jehanne_print("watchdog: automatic enable failed\n"); return; } wd->enable(); @@ -162,17 +162,17 @@ wdread(Chan* c, void* a, long n, int64_t off) if(wd == nil || wd->stat == nil) return 0; - p = malloc(READSTR); + p = jehanne_malloc(READSTR); if(p == nil) error(Enomem); if(waserror()){ - free(p); + jehanne_free(p); nexterror(); } wd->stat(p, p + READSTR); n = readstr(offset, a, n, p); - free(p); + jehanne_free(p); poperror(); return n; @@ -200,20 +200,20 @@ wdwrite(Chan* c, void* a, long n, int64_t off) if(offset || n >= READSTR) error(Ebadarg); - if((p = strchr(a, '\n')) != nil) + if((p = jehanne_strchr(a, '\n')) != nil) *p = 0; - if(strncmp(a, "enable", n) == 0) { + if(jehanne_strncmp(a, "enable", n) == 0) { if (waserror()) { - print("watchdog: enable failed\n"); + jehanne_print("watchdog: enable failed\n"); nexterror(); } wd->enable(); poperror(); watchdogon = 1; - } else if(strncmp(a, "disable", n) == 0) + } else if(jehanne_strncmp(a, "disable", n) == 0) wdshutdown(); - else if(strncmp(a, "restart", n) == 0) + else if(jehanne_strncmp(a, "restart", n) == 0) wd->restart(); else error(Ebadarg); diff --git a/sys/src/kern/port/elf64.c b/sys/src/kern/port/elf64.c index 327e733..826e4fc 100644 --- a/sys/src/kern/port/elf64.c +++ b/sys/src/kern/port/elf64.c @@ -308,9 +308,9 @@ elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz) if(waserror()){ if(ldseg != nil) - free(ldseg); + jehanne_free(ldseg); if(phbuf != nil) - free(phbuf); + jehanne_free(phbuf); nexterror(); } @@ -342,7 +342,7 @@ elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz) e_machine = get16(ehdr.e_machine); if(mach != nil){ for(i = 0; i < nelem(elfmachs); i++) - if(elfmachs[i].e_machine == e_machine && !strcmp(mach, elfmachs[i].mach)) + if(elfmachs[i].e_machine == e_machine && !jehanne_strcmp(mach, elfmachs[i].mach)) break; if(i == nelem(elfmachs)){ pprint("elf64ldseg: e_machine %d incorrect for host %s\n", e_machine, mach); @@ -359,7 +359,7 @@ elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz) error(Ebadexec); } - phbuf = malloc(phentsize*phnum); + phbuf = jehanne_malloc(phentsize*phnum); if(phbuf == nil){ pprint("elf64ldseg: malloc fail\n"); error(Ebadexec); @@ -378,7 +378,7 @@ elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz) if(get32(phdr->p_type) == PT_LOAD) si++; } - ldseg = malloc(si * sizeof ldseg[0]); + ldseg = jehanne_malloc(si * sizeof ldseg[0]); if(ldseg == nil){ pprint("elf64ldseg: malloc fail\n"); error(Ebadexec); @@ -469,11 +469,11 @@ elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz) done: if(phbuf != nil) - free(phbuf); + jehanne_free(phbuf); if(rp != nil){ *rp = ldseg; } else if(ldseg != nil){ - free(ldseg); + jehanne_free(ldseg); } if(entryp != nil) *entryp = entry; diff --git a/sys/src/kern/port/fault.c b/sys/src/kern/port/fault.c index 54fef62..4e0b222 100644 --- a/sys/src/kern/port/fault.c +++ b/sys/src/kern/port/fault.c @@ -114,7 +114,7 @@ vmemchr(void *s, int c, int n) while(ROUNDUP(a, PGSZ) != ROUNDUP(a+n-1, PGSZ)){ /* spans pages; handle this page */ np = PGSZ - (a & (PGSZ-1)); - t = memchr(UINT2PTR(a), c, np); + t = jehanne_memchr(UINT2PTR(a), c, np); if(t) return t; a += np; @@ -124,5 +124,5 @@ vmemchr(void *s, int c, int n) } /* fits in one page */ - return memchr(UINT2PTR(a), c, n); + return jehanne_memchr(UINT2PTR(a), c, n); } diff --git a/sys/src/kern/port/imagmem.c b/sys/src/kern/port/imagmem.c index 5854de4..b5d7565 100644 --- a/sys/src/kern/port/imagmem.c +++ b/sys/src/kern/port/imagmem.c @@ -58,7 +58,7 @@ poolprint(Pool *p, char *fmt, ...) pv = p->private; va_start(v, fmt); - pv->end = vseprint(pv->end, &pv->msg[sizeof pv->msg], fmt, v); + pv->end = jehanne_vseprint(pv->end, &pv->msg[sizeof pv->msg], fmt, v); va_end(v); } @@ -71,9 +71,9 @@ ppanic(Pool *p, char *fmt, ...) pv = p->private; va_start(v, fmt); - vseprint(pv->end, &pv->msg[sizeof pv->msg], fmt, v); + jehanne_vseprint(pv->end, &pv->msg[sizeof pv->msg], fmt, v); va_end(v); - memmove(msg, pv->msg, sizeof msg); + jehanne_memmove(msg, pv->msg, sizeof msg); iunlock(&pv->lk); panic("%s", msg); } @@ -101,7 +101,7 @@ punlock(Pool *p) return; } - memmove(msg, pv->msg, sizeof msg); + jehanne_memmove(msg, pv->msg, sizeof msg); pv->end = pv->msg; iunlock(&pv->lk); iprint("%.*s", sizeof pv->msg, msg); diff --git a/sys/src/kern/port/initcode.c b/sys/src/kern/port/initcode.c index 45881ee..5346c8d 100644 --- a/sys/src/kern/port/initcode.c +++ b/sys/src/kern/port/initcode.c @@ -1,7 +1,7 @@ /* * This file is part of Jehanne. * - * Copyright (C) 2016 Giacomo Tesio + * Copyright (C) 2016-2017 Giacomo Tesio * * Jehanne is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,9 @@ #include #include +extern void **_privates; +extern int _nprivates; + char boot[] = "/boot/boot"; char bootdir[] = "/boot"; char bootname[] = "boot"; @@ -52,11 +55,11 @@ initboot(void) 0 }; - if (access(boot, AEXEC) == 0) + if (jehanne_access(boot, AEXEC) == 0) return 0; - if (access(rofs, AEXEC) < 0) + if (jehanne_access(rofs, AEXEC) < 0) return -1; - if (access(initrd, AREAD) < 0) + if (jehanne_access(initrd, AREAD) < 0) return -1; switch(pid = rfork(RFFDG|RFREND|RFPROC)){ @@ -64,12 +67,12 @@ initboot(void) return -1; case 0: exec(rofs, (const char**)args); - exits("initcode: exec: rofs"); + jehanne_exits("initcode: exec: rofs"); default: /* wait for agent to really be there */ i = 0; - while(access(bootfs, AREAD) < 0){ - sleep(250); + while(jehanne_access(bootfs, AREAD) < 0){ + jehanne_sleep(250); i += 250; if(i > 30000) // 30 seconds are enough return -1; @@ -81,18 +84,29 @@ initboot(void) if(mount(i, -1, bootdir, MREPL, "", '9') < 0) return -1; remove(bootfs); - return access(boot, AEXEC); + return jehanne_access(boot, AEXEC); } void startboot(char *argv0, char **argv) { + /* Initialize per process structures on the stack */ int i; char buf[200]; char * const args[2] = { bootname, nil }; + + void *privates[NPRIVATES]; + NativeTypes sysargs[6]; + + _nprivates = NPRIVATES; + for(_nprivates = 0; _nprivates < NPRIVATES; ++_nprivates) + privates[_nprivates] = nil; + _privates = privates; + _sysargs = &sysargs[0]; + for(i = 0; i < sizeof buf; ++i) buf[i] = '\0'; diff --git a/sys/src/kern/port/latin1.c b/sys/src/kern/port/latin1.c index 89118b8..b982c3e 100644 --- a/sys/src/kern/port/latin1.c +++ b/sys/src/kern/port/latin1.c @@ -2,7 +2,7 @@ #include "../port/lib.h" /* - * The code makes two assumptions: strlen(ld) is 1 or 2; latintab[i].ld can be a + * The code makes two assumptions: jehanne_strlen(ld) is 1 or 2; latintab[i].ld can be a * prefix of latintab[j].ld only when jled)); + jehanne_snprint(buf, sizeof buf, "%s\n", ledname(p->led)); return readstr(off, a, n, buf); } @@ -54,7 +54,7 @@ ledw(Ledport *p, Chan* _, void *a, int32_t n, int64_t __) cb = parsecmd(a, n); i = cb->nf < 1 ? -1 : name2led(cb->f[0]); - free(cb); + jehanne_free(cb); if(i == -1) error(Ebadarg); p->led = i; diff --git a/sys/src/kern/port/lib.h b/sys/src/kern/port/lib.h index f5923c1..6e2460d 100644 --- a/sys/src/kern/port/lib.h +++ b/sys/src/kern/port/lib.h @@ -8,29 +8,29 @@ /* * mem routines */ -extern void* memccpy(void*, void*, int, uint32_t); -extern void* memset(void*, int, uint32_t); -extern int memcmp(void*, void*, uint32_t); -extern void* memmove(void*, void*, uint32_t); -extern void* memchr(void*, int, uint32_t); +extern void* jehanne_memccpy(void*, void*, int, uint32_t); +extern void* jehanne_memset(void*, int, uint32_t); +extern int jehanne_memcmp(void*, void*, uint32_t); +extern void* jehanne_memmove(void*, void*, uint32_t); +extern void* jehanne_memchr(void*, int, uint32_t); /* * string routines */ -extern char* strcat(char*, char*); -extern char* strchr(char*, int); -extern int strcmp(char*, char*); -extern char* strcpy(char*, char*); -extern char* strecpy(char*, char*, char*); -extern char* strncat(char*, char*, long); -extern char* strncpy(char*, char*, long); -extern int strncmp(char*, char*, long); -extern char* strrchr(char*, int); -extern long strlen(char*); -extern char* strstr(char*, char*); -extern int cistrncmp(char*, char*, int); -extern int cistrcmp(char*, char*); -extern int tokenize(char*, char**, int); +extern char* jehanne_strcat(char*, char*); +extern char* jehanne_strchr(char*, int); +extern int jehanne_strcmp(char*, char*); +extern char* jehanne_strcpy(char*, char*); +extern char* jehanne_strecpy(char*, char*, char*); +extern char* jehanne_strncat(char*, char*, long); +extern char* jehanne_strncpy(char*, char*, long); +extern int jehanne_strncmp(char*, char*, long); +extern char* jehanne_strrchr(char*, int); +extern long jehanne_strlen(char*); +extern char* jehanne_strstr(char*, char*); +extern int jehanne_cistrncmp(char*, char*, int); +extern int jehanne_cistrcmp(char*, char*); +extern int jehanne_tokenize(char*, char**, int); enum { @@ -45,27 +45,25 @@ enum /* * rune routines */ -extern int runetochar(char*, Rune*); -extern int chartorune(Rune*, char*); -extern int runelen(long); -extern int fullrune(char*, int); -extern int utflen(char*); -extern int utfnlen(char*, long); -extern char* utfrune(char*, long); +extern int jehanne_runetochar(char*, Rune*); +extern int jehanne_chartorune(Rune*, char*); +extern int jehanne_runelen(long); +extern int jehanne_fullrune(char*, int); +extern int jehanne_utflen(char*); +extern int jehanne_utfnlen(char*, long); +extern char* jehanne_utfrune(char*, long); /* * malloc */ -extern void* malloc(usize); -extern void* mallocz(usize, int); -extern void free(void*); -extern uint32_t msize(void*); -extern void* mallocalign(usize, uint32_t, long, uint32_t); -extern void* realloc(void*, usize); -extern void setmalloctag(void*, uint32_t); -extern void setrealloctag(void*, uint32_t); -extern uint32_t getmalloctag(void*); -extern uint32_t getrealloctag(void*); +extern void* jehanne_malloc(usize); +extern void* jehanne_mallocz(usize, int); +extern void jehanne_free(void*); +extern uint32_t jehanne_msize(void*); +extern void* jehanne_mallocalign(usize, uint32_t, long, uint32_t); +extern void* jehanne_realloc(void*, usize); +extern void jehanne_setmalloctag(void*, uint32_t); +extern uint32_t jehanne_getmalloctag(void*); /* * print routines @@ -104,12 +102,12 @@ enum { FmtFlag = FmtByte<<1 }; -extern int print(char*, ...); -extern char* seprint(char*, char*, char*, ...); -extern char* vseprint(char*, char*, char*, va_list); -extern int snprint(char*, int, char*, ...); -extern int vsnprint(char*, int, char*, va_list); -extern int sprint(char*, char*, ...); +extern int jehanne_print(char*, ...); +extern char* jehanne_seprint(char*, char*, char*, ...); +extern char* jehanne_vseprint(char*, char*, char*, va_list); +extern int jehanne_snprint(char*, int, char*, ...); +extern int jehanne_vsnprint(char*, int, char*, va_list); +extern int jehanne_sprint(char*, char*, ...); #pragma varargck argpos fmtprint 2 #pragma varargck argpos print 1 @@ -145,16 +143,16 @@ extern int sprint(char*, char*, ...); #pragma varargck type "H" void* #pragma varargck type "lH" void* -extern int fmtinstall(int, int (*)(Fmt*)); -extern int fmtprint(Fmt*, char*, ...); -extern int fmtstrcpy(Fmt*, char*); -extern char* fmtstrflush(Fmt*); -extern int fmtstrinit(Fmt*); +extern int jehanne_fmtinstall(int, int (*)(Fmt*)); +extern int jehanne_fmtprint(Fmt*, char*, ...); +extern int jehanne_fmtstrcpy(Fmt*, char*); +extern char* jehanne_fmtstrflush(Fmt*); +extern int jehanne_fmtstrinit(Fmt*); /* * quoted strings */ -extern void quotefmtinstall(void); +extern void jehanne_quotefmtinstall(void); /* * Time-of-day @@ -164,22 +162,21 @@ extern void cycles(uint64_t*); /* 64-bit value of the cycle counter if there is /* * one-of-a-kind */ -extern int abs(int); -extern int atoi(char*); -extern char* cleanname(char*); -extern int dec16(uint8_t*, int, char*, int); -extern int enc16(char*, int, uint8_t*, int); -extern int encodefmt(Fmt*); -extern int dec64(uint8_t*, int, char*, int); -//extern uintptr_t getcallerpc(void); +extern int jehanne_abs(int); +extern int jehanne_atoi(char*); +extern char* jehanne_cleanname(char*); +extern int jehanne_dec16(uint8_t*, int, char*, int); +extern int jehanne_enc16(char*, int, uint8_t*, int); +extern int jehanne_encodefmt(Fmt*); +extern int jehanne_dec64(uint8_t*, int, char*, int); #define getcallerpc() ((uintptr_t)__builtin_return_address(0)) -extern int getfields(char*, char**, int, int, char*); -extern int gettokens(char *, char **, int, char *); -extern void qsort(void*, long, long, int (*)(void*, void*)); -extern long strtol(char*, char**, int); -extern uint32_t strtoul(char*, char**, int); -extern int64_t strtoll(char*, char**, int); -extern uint64_t strtoull(char*, char**, int); +extern int jehanne_getfields(char*, char**, int, int, char*); +extern int jehanne_gettokens(char *, char **, int, char *); +extern void jehanne_qsort(void*, long, long, int (*)(void*, void*)); +extern long jehanne_strtol(char*, char**, int); +extern uint32_t jehanne_strtoul(char*, char**, int); +extern int64_t jehanne_strtoll(char*, char**, int); +extern uint64_t jehanne_strtoull(char*, char**, int); /* * Syscall data structures @@ -283,13 +280,13 @@ extern char etext[]; extern char edata[]; extern char end[]; -extern char* smprint(char*, ...); -extern char* strdup(char*); +extern char* jehanne_smprint(char*, ...); +extern char* jehanne_strdup(char*); -extern unsigned int convM2D(uint8_t*, uint, Dir*, char*); -extern unsigned int convD2M(Dir*, uint8_t*, uint); -extern unsigned int sizeD2M(Dir*); +extern unsigned int jehanne_convM2D(uint8_t*, uint, Dir*, char*); +extern unsigned int jehanne_convD2M(Dir*, uint8_t*, uint); +extern unsigned int jehanne_sizeD2M(Dir*); extern int dirfmt(Fmt*); -extern int dirmodefmt(Fmt*); +extern int jehanne_dirmodefmt(Fmt*); #pragma varargck type "D" Dir* diff --git a/sys/src/kern/port/log.c b/sys/src/kern/port/log.c index f75febc..7ecc867 100644 --- a/sys/src/kern/port/log.c +++ b/sys/src/kern/port/log.c @@ -37,7 +37,7 @@ logclose(Log *alog) lock(&alog->l); alog->opens--; if(alog->opens == 0){ - free(alog->buf); + jehanne_free(alog->buf); alog->buf = nil; } unlock(&alog->l); @@ -80,8 +80,8 @@ logread(Log *alog, void *a, uint32_t _1, long n) i = n-d; p = a; - memmove(p, rptr, i); - memmove(p+i, alog->buf, d); + jehanne_memmove(p, rptr, i); + jehanne_memmove(p+i, alog->buf, d); break; } else @@ -105,16 +105,16 @@ logctl(Log *alog, int argc, char *argv[], Logflag *flags) if(argc < 2) return Ebadlogctl; - if(strcmp("set", argv[0]) == 0) + if(jehanne_strcmp("set", argv[0]) == 0) set = 1; - else if(strcmp("clear", argv[0]) == 0) + else if(jehanne_strcmp("clear", argv[0]) == 0) set = 0; else return Ebadlogctl; for(i = 1; i < argc; i++){ for(fp = flags; fp->name; fp++) - if(strcmp(fp->name, argv[i]) == 0) + if(jehanne_strcmp(fp->name, argv[i]) == 0) break; if(fp->name == nil) continue; @@ -179,7 +179,7 @@ log(Log *alog, int mask, char *fmt, ...) return; va_start(arg, fmt); - n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; + n = jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); logn(alog, mask, buf, n); diff --git a/sys/src/kern/port/mcslock.c b/sys/src/kern/port/mcslock.c index 2144c56..8461af9 100644 --- a/sys/src/kern/port/mcslock.c +++ b/sys/src/kern/port/mcslock.c @@ -120,7 +120,7 @@ unlock(Lock *l) LockEntry *ql; if(l->head == nil){ - print("unlock: not locked: pc %#p\n", getcallerpc()); + jehanne_print("unlock: not locked: pc %#p\n", getcallerpc()); return; } ql = findle(l); diff --git a/sys/src/kern/port/netif.c b/sys/src/kern/port/netif.c index 03001ed..30b83de 100644 --- a/sys/src/kern/port/netif.c +++ b/sys/src/kern/port/netif.c @@ -21,13 +21,13 @@ netifinit(Netif *nif, char *name, int nfile, uint32_t limit) { if(nif->inited) return; - strncpy(nif->name, name, KNAMELEN-1); + jehanne_strncpy(nif->name, name, KNAMELEN-1); nif->name[KNAMELEN-1] = 0; nif->nfile = nfile; - nif->f = malloc(nfile*sizeof(Netfile*)); + nif->f = jehanne_malloc(nfile*sizeof(Netfile*)); if(nif->f == nil) panic("netifinit: %s: out of memory", name); - memset(nif->f, 0, nfile*sizeof(Netfile*)); + jehanne_memset(nif->f, 0, nfile*sizeof(Netfile*)); nif->limit = limit; nif->inited = 1; } @@ -59,7 +59,7 @@ netifgen(Chan *c, char* _1, Dirtab *vp, int _2, int i, Dir *dp) case 0: q.path = N2ndqid; q.type = QTDIR; - strcpy(up->genbuf, nif->name); + jehanne_strcpy(up->genbuf, nif->name); devdir(c, q, up->genbuf, 0, eve, 0555, dp); break; default: @@ -110,7 +110,7 @@ netifgen(Chan *c, char* _1, Dirtab *vp, int _2, int i, Dir *dp) return 0; q.type = QTDIR; q.path = NETQID(i, N3rdqid); - sprint(up->genbuf, "%d", i); + jehanne_sprint(up->genbuf, "%d", i); devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp); break; } @@ -132,7 +132,7 @@ netifgen(Chan *c, char* _1, Dirtab *vp, int _2, int i, Dir *dp) case DEVDOTDOT: q.type = QTDIR; q.path = N2ndqid; - strcpy(up->genbuf, nif->name); + jehanne_strcpy(up->genbuf, nif->name); devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp); break; case 0: @@ -229,52 +229,52 @@ netifread(Netif *nif, Chan *c, void *a, long n, int64_t off) case Nctlqid: return readnum(offset, a, n, NETID(c->qid.path), NUMSIZE); case Nstatqid: - p = op = malloc(READSTR); + p = op = jehanne_malloc(READSTR); if(p == nil) return 0; e = p + READSTR; - p = seprint(p, e, "in: %llud\n", nif->inpackets); - p = seprint(p, e, "link: %d\n", nif->link); - p = seprint(p, e, "out: %llud\n", nif->outpackets); - p = seprint(p, e, "crc errs: %d\n", nif->crcs); - p = seprint(p, e, "overflows: %d\n", nif->overflows); - p = seprint(p, e, "input overflows: %d\n", nif->inoverflows); - p = seprint(p, e, "output overflows: %d\n", nif->outoverflows); - p = seprint(p, e, "loopback frames: %d\n", nif->loopbacks); - p = seprint(p, e, "framing errs: %d\n", nif->frames); - p = seprint(p, e, "buffer errs: %d\n", nif->buffs); - p = seprint(p, e, "output errs: %d\n", nif->oerrs); - p = seprint(p, e, "prom: %d\n", nif->prom); - p = seprint(p, e, "mbps: %d\n", nif->mbps); - p = seprint(p, e, "limit: %d\n", nif->limit); - p = seprint(p, e, "addr: "); + p = jehanne_seprint(p, e, "in: %llud\n", nif->inpackets); + p = jehanne_seprint(p, e, "link: %d\n", nif->link); + p = jehanne_seprint(p, e, "out: %llud\n", nif->outpackets); + p = jehanne_seprint(p, e, "crc errs: %d\n", nif->crcs); + p = jehanne_seprint(p, e, "overflows: %d\n", nif->overflows); + p = jehanne_seprint(p, e, "input overflows: %d\n", nif->inoverflows); + p = jehanne_seprint(p, e, "output overflows: %d\n", nif->outoverflows); + p = jehanne_seprint(p, e, "loopback frames: %d\n", nif->loopbacks); + p = jehanne_seprint(p, e, "framing errs: %d\n", nif->frames); + p = jehanne_seprint(p, e, "buffer errs: %d\n", nif->buffs); + p = jehanne_seprint(p, e, "output errs: %d\n", nif->oerrs); + p = jehanne_seprint(p, e, "prom: %d\n", nif->prom); + p = jehanne_seprint(p, e, "mbps: %d\n", nif->mbps); + p = jehanne_seprint(p, e, "limit: %d\n", nif->limit); + p = jehanne_seprint(p, e, "addr: "); for(i = 0; i < nif->alen; i++) - p = seprint(p, e, "%2.2ux", nif->addr[i]); - p = seprint(p, e, "\n"); - seprint(p, e, "oq len: %d\n", qblen(nif->oq)); + p = jehanne_seprint(p, e, "%2.2ux", nif->addr[i]); + p = jehanne_seprint(p, e, "\n"); + jehanne_seprint(p, e, "oq len: %d\n", qblen(nif->oq)); n = readstr(offset, a, n, op); - free(op); + jehanne_free(op); return n; case N3statqid: f = nif->f[NETID(c->qid.path)]; - p = op = malloc(READSTR); + p = op = jehanne_malloc(READSTR); if(p == nil) return 0; e = p + READSTR; - p = seprint(p, e, "in qlen: %ud\n", qblen(f->iq)); - seprint(p, e, "input overflows: %ud\n", f->inoverflows); + p = jehanne_seprint(p, e, "in qlen: %ud\n", qblen(f->iq)); + jehanne_seprint(p, e, "input overflows: %ud\n", f->inoverflows); n = readstr(offset, a, n, op); - free(op); + jehanne_free(op); return n; case Naddrqid: - p = op = malloc(READSTR); + p = op = jehanne_malloc(READSTR); if(p == nil) return 0; e = p + READSTR; for(i = 0; i < nif->alen; i++) - p = seprint(p, e, "%2.2ux", nif->addr[i]); + p = jehanne_seprint(p, e, "%2.2ux", nif->addr[i]); n = readstr(offset, a, n, op); - free(op); + jehanne_free(op); return n; case Ntypeqid: f = nif->f[NETID(c->qid.path)]; @@ -282,10 +282,10 @@ netifread(Netif *nif, Chan *c, void *a, long n, int64_t off) case Nifstatqid: return 0; case Nmtuqid: - snprint(up->genbuf, sizeof(up->genbuf), "%11.ud %11.ud %11.ud\n", nif->minmtu, nif->mtu, nif->maxmtu); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%11.ud %11.ud %11.ud\n", nif->minmtu, nif->mtu, nif->maxmtu); return readstr(offset, a, n, up->genbuf); case Nmaxmtuqid: - snprint(up->genbuf, sizeof(up->genbuf), "%d", nif->maxmtu); + jehanne_snprint(up->genbuf, sizeof(up->genbuf), "%d", nif->maxmtu); return readstr(offset, a, n, up->genbuf); } error(Ebadarg); @@ -361,7 +361,7 @@ netifwrite(Netif *nif, Chan *c, void *a, long n) if(n >= sizeof(buf)) n = sizeof(buf)-1; - memmove(buf, a, n); + jehanne_memmove(buf, a, n); buf[n] = 0; if(waserror()){ @@ -373,7 +373,7 @@ netifwrite(Netif *nif, Chan *c, void *a, long n) f = nif->f[NETID(c->qid.path)]; if((p = matchtoken(buf, "connect")) != 0){ qclose(f->iq); - type = atoi(p); + type = jehanne_atoi(p); if(typeinuse(nif, type)) error(Einuse); f->type = type; @@ -390,7 +390,7 @@ netifwrite(Netif *nif, Chan *c, void *a, long n) } else if((p = matchtoken(buf, "scanbs")) != 0){ /* scan for base stations */ if(f->scan == 0){ - type = atoi(p); + type = jehanne_atoi(p); if(type < 5) type = 5; if(nif->scanbs != nil) @@ -399,7 +399,7 @@ netifwrite(Netif *nif, Chan *c, void *a, long n) nif->scan++; } } else if((p = matchtoken(buf, "mtu")) != 0){ - mtu = atoi(p); + mtu = jehanne_atoi(p); /* zero resets default. */ if(mtu != 0) if(mtu < nif->minmtu || mtu > nif->maxmtu) @@ -430,7 +430,7 @@ netifwrite(Netif *nif, Chan *c, void *a, long n) if(*p == 0) onoff = 1; else - onoff = atoi(p); + onoff = jehanne_atoi(p); f->fat = onoff; } else n = -1; @@ -454,16 +454,16 @@ netifwstat(Netif *nif, Chan *c, uint8_t *db, long n) error(Eperm); dir = smalloc(sizeof(Dir)+n); - l = convM2D(db, n, &dir[0], (char*)&dir[1]); + l = jehanne_convM2D(db, n, &dir[0], (char*)&dir[1]); if(l == 0){ - free(dir); + jehanne_free(dir); error(Eshortstat); } if(!emptystr(dir[0].uid)) - strncpy(f->owner, dir[0].uid, KNAMELEN); + jehanne_strncpy(f->owner, dir[0].uid, KNAMELEN); if(dir[0].mode != (uint32_t)~0UL) f->mode = dir[0].mode; - free(dir); + jehanne_free(dir); return l; } @@ -540,9 +540,9 @@ netown(Netfile *p, char *o, int omode) lock(&netlock); if(*p->owner){ - if(strncmp(o, p->owner, KNAMELEN) == 0) /* User */ + if(jehanne_strncmp(o, p->owner, KNAMELEN) == 0) /* User */ mode = p->mode; - else if(strncmp(o, eve, KNAMELEN) == 0) /* Bootes is group */ + else if(jehanne_strncmp(o, eve, KNAMELEN) == 0) /* Bootes is group */ mode = p->mode<<3; else mode = p->mode<<6; /* Other */ @@ -556,7 +556,7 @@ netown(Netfile *p, char *o, int omode) return -1; } } - strncpy(p->owner, o, KNAMELEN); + jehanne_strncpy(p->owner, o, KNAMELEN); p->mode = 0660; unlock(&netlock); return 0; @@ -591,12 +591,12 @@ openfile(Netif *nif, int id) for(fp = nif->f; fp < efp; fp++){ f = *fp; if(f == 0){ - f = malloc(sizeof(Netfile)); + f = jehanne_malloc(sizeof(Netfile)); if(f == 0) exhausted("memory"); f->iq = qopen(nif->limit, Qmsg, 0, 0); if(f->iq == nil){ - free(f); + jehanne_free(f); exhausted("memory"); } qlock(f); @@ -629,8 +629,8 @@ matchtoken(char *p, char *token) { int n; - n = strlen(token); - if(strncmp(p, token, n)) + n = jehanne_strlen(token); + if(jehanne_strncmp(p, token, n)) return 0; p += n; if(*p == 0) @@ -658,7 +658,7 @@ activemulti(Netif *nif, uint8_t *addr, int alen) Netaddr *hp; for(hp = nif->mhash[hash(addr, alen)]; hp; hp = hp->hnext) - if(memcmp(addr, hp->addr, alen) == 0){ + if(jehanne_memcmp(addr, hp->addr, alen) == 0){ if(hp->ref) return 1; else @@ -683,7 +683,7 @@ parseaddr(uint8_t *to, char *from, int alen) return -1; nip[1] = *p++; nip[2] = 0; - to[i] = strtoul(nip, 0, 16); + to[i] = jehanne_strtoul(nip, 0, 16); if(*p == ':') p++; } @@ -706,7 +706,7 @@ netmulti(Netif *nif, Netfile *f, uint8_t *addr, int add) l = &nif->maddr; i = 0; for(ap = *l; ap; ap = *l){ - if(memcmp(addr, ap->addr, nif->alen) == 0) + if(jehanne_memcmp(addr, ap->addr, nif->alen) == 0) break; i++; l = &ap->next; @@ -715,7 +715,7 @@ netmulti(Netif *nif, Netfile *f, uint8_t *addr, int add) if(add){ if(ap == 0){ *l = ap = smalloc(sizeof(*ap)); - memmove(ap->addr, addr, nif->alen); + jehanne_memmove(ap->addr, addr, nif->alen); ap->next = 0; ap->ref = 1; h = hash(addr, nif->alen); diff --git a/sys/src/kern/port/parse.c b/sys/src/kern/port/parse.c index 9d59b56..ccb0118 100644 --- a/sys/src/kern/port/parse.c +++ b/sys/src/kern/port/parse.c @@ -22,7 +22,7 @@ ncmdfield(char *p, int n) ep = p+n; white = 1; /* first text will start field */ while(p < ep){ - nwhite = (strchr(" \t\r\n", *p++ & 0xFF) != 0); /* UTF is irrelevant */ + nwhite = (jehanne_strchr(" \t\r\n", *p++ & 0xFF) != 0); /* UTF is irrelevant */ if(white && !nwhite) /* beginning of field */ nf++; white = nwhite; @@ -49,10 +49,10 @@ parsecmd(char *p, int n) cb->buf = (char*)(&cb->f[nf]); if(up!=nil && waserror()){ - free(cb); + jehanne_free(cb); nexterror(); } - memmove(cb->buf, p, n); + jehanne_memmove(cb->buf, p, n); if(up != nil) poperror(); @@ -61,7 +61,7 @@ parsecmd(char *p, int n) n--; cb->buf[n] = '\0'; - cb->nf = tokenize(cb->buf, cb->f, nf-1); + cb->nf = jehanne_tokenize(cb->buf, cb->f, nf-1); cb->f[cb->nf] = nil; return cb; @@ -78,13 +78,13 @@ cmderror(Cmdbuf *cb, char *s) p = up->genbuf; e = p+ERRMAX-10; - p = seprint(p, e, "%s \"", s); + p = jehanne_seprint(p, e, "%s \"", s); for(i=0; inf; i++){ if(i > 0) - p = seprint(p, e, " "); - p = seprint(p, e, "%q", cb->f[i]); + p = jehanne_seprint(p, e, " "); + p = jehanne_seprint(p, e, "%q", cb->f[i]); } - strcpy(p, "\""); + jehanne_strcpy(p, "\""); error(up->genbuf); } @@ -101,8 +101,8 @@ lookupcmd(Cmdbuf *cb, Cmdtab *ctab, int nctab) error("empty control message"); for(ct = ctab, i=0; icmd, "*") !=0) /* wildcard always matches */ - if(strcmp(ct->cmd, cb->f[0]) != 0) + if(jehanne_strcmp(ct->cmd, "*") !=0) /* wildcard always matches */ + if(jehanne_strcmp(ct->cmd, cb->f[0]) != 0) continue; if(ct->narg != 0 && ct->narg != cb->nf) cmderror(cb, Ecmdargs); diff --git a/sys/src/kern/port/pgrp.c b/sys/src/kern/port/pgrp.c index 1d0b51c..ada6039 100644 --- a/sys/src/kern/port/pgrp.c +++ b/sys/src/kern/port/pgrp.c @@ -25,7 +25,7 @@ pgrpnote(uint32_t noteid, char *a, long n, int flag) if(n >= ERRMAX-1) error(Etoobig); - memmove(buf, a, n); + jehanne_memmove(buf, a, n); buf[n] = 0; for(i = 0; (p = psincref(i)) != nil; i++){ if(p == up || p->state == Dead || p->noteid != noteid || p->kp){ @@ -72,7 +72,7 @@ void closergrp(Rgrp *r) { if(decref(&r->r) == 0) - free(r); + jehanne_free(r); } void @@ -101,7 +101,7 @@ closepgrp(Pgrp *p) } wunlock(&p->ns); qunlock(&p->debug); - free(p); + jehanne_free(p); } void @@ -187,10 +187,10 @@ dupfgrp(Fgrp *f) i = new->nfd%DELTAFD; if(i != 0) new->nfd += DELTAFD - i; - new->fd = malloc(new->nfd*sizeof(Chan*)); + new->fd = jehanne_malloc(new->nfd*sizeof(Chan*)); if(new->fd == nil){ unlock(&f->l); - free(new); + jehanne_free(new); error("no memory for fgrp"); } new->r.ref = 1; @@ -232,8 +232,8 @@ closefgrp(Fgrp *f) } up->closingfgrp = nil; - free(f->fd); - free(f); + jehanne_free(f->fd); + jehanne_free(f); } /* @@ -254,7 +254,7 @@ forceclosefgrp(void) Fgrp *f; if(up->procctl != Proc_exitme || up->closingfgrp == nil){ - print("bad forceclosefgrp call"); + jehanne_print("bad forceclosefgrp call"); return; } @@ -295,8 +295,8 @@ mountfree(Mount *mount) f = mount->next; cclose(mount->to); mount->mountid = 0; - free(mount->spec); - free(mount); + jehanne_free(mount->spec); + jehanne_free(mount); mount = f; } } @@ -322,7 +322,7 @@ resrcwait(char *reason, char *pstag) /* don't tie up the console with complaints */ if(now - lastwhine > Whinesecs) { lastwhine = now; - print("%s\n", reason); + jehanne_print("%s\n", reason); } } diff --git a/sys/src/kern/port/physalloc.c b/sys/src/kern/port/physalloc.c index 29cb018..ca0d968 100644 --- a/sys/src/kern/port/physalloc.c +++ b/sys/src/kern/port/physalloc.c @@ -25,7 +25,7 @@ alloc0(usize nb, int clr) p = basealloc(nb, 0, nil); if(clr && p != nil) - memset(p, 0, nb); + jehanne_memset(p, 0, nb); return p; } @@ -136,10 +136,10 @@ physallocinit(void) void physdump(void) { - print("bpooldump phys: "); + jehanne_print("bpooldump phys: "); bpooldump(phys); if(physgig != nil){ - print("bpooldump physgig: "); + jehanne_print("bpooldump physgig: "); bpooldump(physgig); } } diff --git a/sys/src/kern/port/portclock.c b/sys/src/kern/port/portclock.c index 38fc88d..022ca35 100644 --- a/sys/src/kern/port/portclock.c +++ b/sys/src/kern/port/portclock.c @@ -223,7 +223,7 @@ timersinit(void) * T->tf == nil means the HZ clock for this processor. */ todinit(); - t = malloc(sizeof(*t)); + t = jehanne_malloc(sizeof(*t)); if(t == nil) panic("timersinit: no memory for Timer"); t->tmode = Tperiodic; @@ -240,7 +240,7 @@ addclock0link(void (*f)(void), int ms) int64_t when; /* Synchronize to hztimer if ms is 0 */ - nt = malloc(sizeof(Timer)); + nt = jehanne_malloc(sizeof(Timer)); if(nt == nil) panic("addclock0link: no memory for Timer"); if(ms == 0) diff --git a/sys/src/kern/port/print.c b/sys/src/kern/port/print.c index d16aa57..8982639 100644 --- a/sys/src/kern/port/print.c +++ b/sys/src/kern/port/print.c @@ -31,13 +31,13 @@ mregfmt(Fmt* f) mreg = va_arg(f->args, Mreg); if(sizeof(Mreg) == sizeof(uint64_t)) - return fmtprint(f, "%#16.16llux", (uint64_t)mreg); - return fmtprint(f, "%#8.8ux", (uint32_t)mreg); + return jehanne_fmtprint(f, "%#16.16llux", (uint64_t)mreg); + return jehanne_fmtprint(f, "%#8.8ux", (uint32_t)mreg); } void fmtinit(void) { - quotefmtinstall(); + jehanne_quotefmtinstall(); archfmtinstall(); } diff --git a/sys/src/kern/port/proc.c b/sys/src/kern/port/proc.c index 44ccb19..f3317c4 100644 --- a/sys/src/kern/port/proc.c +++ b/sys/src/kern/port/proc.c @@ -383,7 +383,7 @@ dequeueproc(Schedq *rq, Proc *tp) rq->n--; nrdy--; if(p->state != Ready) - print("dequeueproc %s %d %s\n", p->text, p->pid, statename[p->state]); + jehanne_print("dequeueproc %s %d %s\n", p->text, p->pid, statename[p->state]); unlock(&runq->l); return p; @@ -603,7 +603,7 @@ newproc(void) p->args = nil; p->nargs = 0; p->setargs = 0; - memset(p->seg, 0, sizeof p->seg); + jehanne_memset(p->seg, 0, sizeof p->seg); p->pid = incref(&pidalloc); pshash(p); p->noteid = incref(¬eidalloc); @@ -635,7 +635,7 @@ procwired(Proc *p, int bm) if(bm < 0){ /* pick a machine to wire to */ - memset(nwired, 0, sizeof(nwired)); + jehanne_memset(nwired, 0, sizeof(nwired)); p->wired = 0; for(i=0; (pp = psincref(i)) != nil; i++){ wm = pp->wired; @@ -692,12 +692,12 @@ sleep(Rendez *r, int (*f)(void*), void *arg) s = splhi(); if(up->nlocks) - print("process %d sleeps with %d locks held, last lock %#p locked at pc %#p, sleep called from %#p\n", + jehanne_print("process %d sleeps with %d locks held, last lock %#p locked at pc %#p, sleep called from %#p\n", up->pid, up->nlocks, up->lastlock, lockgetpc(up->lastlock), getcallerpc()); lock(&r->l); lock(&up->rlock); if(r->p){ - print("double sleep called from %#p, %d %d\n", + jehanne_print("double sleep called from %#p, %d %d\n", getcallerpc(), r->p->pid, up->pid); dumpstack(); } @@ -795,7 +795,7 @@ void tsleep(Rendez *r, int (*fn)(void*), void *arg, int64_t ms) { if (up->tt){ - print("%s %lud: tsleep timer active: mode %d, tf %#p, pc %#p\n", + jehanne_print("%s %lud: tsleep timer active: mode %d, tf %#p, pc %#p\n", up->text, up->pid, up->tmode, up->tf, __builtin_return_address(0)); timerdel(up); } @@ -872,7 +872,7 @@ postnote(Proc *p, int dolock, char *n, int flag) ret = 0; if(p->nnote < NNOTE) { - strcpy(p->note[p->nnote].msg, n); + jehanne_strcpy(p->note[p->nnote].msg, n); p->note[p->nnote++].flag = flag; ret = 1; } @@ -981,7 +981,7 @@ addbroken(Proc *p) qlock(&broken); if(broken.n == NBROKEN) { ready(broken.p[0]); - memmove(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1)); + jehanne_memmove(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1)); --broken.n; } broken.p[broken.n++] = p; @@ -1001,7 +1001,7 @@ unbreak(Proc *p) for(b=0; b < broken.n; b++) if(broken.p[b] == p) { broken.n--; - memmove(&broken.p[b], &broken.p[b+1], + jehanne_memmove(&broken.p[b], &broken.p[b+1], sizeof(Proc*)*(NBROKEN-(b+1))); ready(p); break; @@ -1098,7 +1098,7 @@ pexit(char *exitstr, int freemem) wq->w.time[TSys] = tk2ms(stime); wq->w.time[TReal] = tk2ms(sys->ticks - up->time[TReal]); if(exitstr && exitstr[0]) - snprint(wq->w.msg, sizeof(wq->w.msg), "%s %d: %s", + jehanne_snprint(wq->w.msg, sizeof(wq->w.msg), "%s %d: %s", up->text, up->pid, exitstr); else wq->w.msg[0] = '\0'; @@ -1128,7 +1128,7 @@ pexit(char *exitstr, int freemem) } unlock(&p->exl); if(wq) - free(wq); + jehanne_free(wq); } if(!freemem) @@ -1150,7 +1150,7 @@ pexit(char *exitstr, int freemem) while((wq = up->waitq) != nil){ up->waitq = wq->next; - free(wq); + jehanne_free(wq); } /* release debuggers */ @@ -1215,9 +1215,9 @@ pwait(Waitmsg *w) poperror(); if(w) - memmove(w, &wq->w, sizeof(Waitmsg)); + jehanne_memmove(w, &wq->w, sizeof(Waitmsg)); cpid = wq->w.pid; - free(wq); + jehanne_free(wq); return cpid; } @@ -1240,7 +1240,7 @@ dumpaproc(Proc *p) s = p->psstate; if(s == 0) s = statename[p->state]; - print("%3d:%10s pc %#p dbgpc %#p %8s (%s) ut %ld st %ld bss %#p qpc %#p nl %d nd %lud lpc %#p pri %lud\n", + jehanne_print("%3d:%10s pc %#p dbgpc %#p %8s (%s) ut %ld st %ld bss %#p qpc %#p nl %d nd %lud lpc %#p pri %lud\n", p->pid, p->text, p->pc, dbgpc(p), s, statename[p->state], p->time[0], p->time[1], bss, p->qpc, p->nlocks, p->delaysched, p->lastlock ? lockgetpc(p->lastlock) : 0, p->priority); @@ -1253,9 +1253,9 @@ procdump(void) Proc *p; if(up) - print("up %d\n", up->pid); + jehanne_print("up %d\n", up->pid); else - print("no current process\n"); + jehanne_print("no current process\n"); for(i=0; (p = psincref(i)) != nil; i++) { if(p->state != Dead) dumpaproc(p); @@ -1343,13 +1343,13 @@ scheddump(void) for(rq = &runq[Npriq-1]; rq >= runq; rq--){ if(rq->head == 0) continue; - print("rq%ld:", rq-runq); + jehanne_print("rq%ld:", rq-runq); for(p = rq->head; p; p = p->rnext) - print(" %d(%llud)", p->pid, m->ticks - p->readytime); - print("\n"); + jehanne_print(" %d(%llud)", p->pid, m->ticks - p->readytime); + jehanne_print("\n"); delay(150); } - print("nrdy %d\n", nrdy); + jehanne_print("nrdy %d\n", nrdy); } void @@ -1368,14 +1368,14 @@ kproc(char *name, void (*func)(void *), void *arg) p->kp = 1; p->scallnr = up->scallnr; - memmove(p->arg, up->arg, sizeof(up->arg)); + jehanne_memmove(p->arg, up->arg, sizeof(up->arg)); p->nerrlab = 0; p->slash = up->slash; p->dot = up->dot; if(p->dot) incref(&p->dot->r); - memmove(p->note, up->note, sizeof(p->note)); + jehanne_memmove(p->note, up->note, sizeof(p->note)); p->nnote = up->nnote; p->notified = 0; p->lastnote = up->lastnote; @@ -1394,7 +1394,7 @@ kproc(char *name, void (*func)(void *), void *arg) p->pgrp = kpgrp; incref(&kpgrp->r); - memset(p->time, 0, sizeof(p->time)); + jehanne_memset(p->time, 0, sizeof(p->time)); p->time[TReal] = sys->ticks; // pickmach(p); ready(p); @@ -1452,7 +1452,7 @@ errorf(char *fmt, ...) char buf[PRINTSIZE]; va_start(arg, fmt); - vseprint(buf, buf+sizeof(buf), fmt, arg); + jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg); va_end(arg); error(buf); } @@ -1494,10 +1494,10 @@ labtrap(char *source) int i; ilock(&l); - print("labtrap (%s):\n", source); + jehanne_print("labtrap (%s):\n", source); for (i=NERR-1; i>=0; i--) if (up->errlab[i].pc) - print("%d: sp=%#p pc=%#p\n", i, up->errlab[i].sp, up->errlab[i].pc); + jehanne_print("%d: sp=%#p pc=%#p\n", i, up->errlab[i].sp, up->errlab[i].pc); iunlock(&l); delay(3*1000); /* delay to let cons queue drain */ panic(source); @@ -1516,7 +1516,7 @@ exhausted(char *resource) { char buf[ERRMAX]; - sprint(buf, "no free %s", resource); + jehanne_sprint(buf, "no free %s", resource); iprint("%s\n", buf); error(buf); } @@ -1555,7 +1555,7 @@ cankillproc(Proc *p) return 0; if(p->procctl == Proc_exitbig || p->procctl == Proc_exitme) return 0; - return strcmp(p->user, eve) != 0 || (p->procmode&0222) != 0; + return jehanne_strcmp(p->user, eve) != 0 || (p->procmode&0222) != 0; } enum{ @@ -1570,8 +1570,8 @@ findbignoteid(void) Proc *p; int j; - memset(sizes, 0, sizeof(sizes)); - memset(noteids, 0, sizeof(noteids)); + jehanne_memset(sizes, 0, sizeof(sizes)); + jehanne_memset(noteids, 0, sizeof(noteids)); nbig = 0; for(j = 0; (p = psincref(j)) != nil; j++){ if(cankillproc(p)){ @@ -1622,7 +1622,7 @@ killbig(char *why) for(i = 0; (p = psincref(i)) != nil; i++){ if(p->noteid == noteid && canqlock(&p->debug)){ if(p->noteid == noteid && cankillproc(p)){ - print("%ud: %s killed: %s\n", p->pid, p->text, why); + jehanne_print("%ud: %s killed: %s\n", p->pid, p->text, why); prockill(p, Proc_exitbig, why); } qunlock(&p->debug); @@ -1664,7 +1664,7 @@ renameuser(char *old, char *new) Proc *p; for(i = 0; (p = psincref(i)) != nil; i++){ - if(p->user!=nil && strcmp(old, p->user)==0) + if(p->user!=nil && jehanne_strcmp(old, p->user)==0) kstrdup(&p->user, new); psdecref(p); } diff --git a/sys/src/kern/port/ps.c b/sys/src/kern/port/ps.c index 50e4091..691168c 100644 --- a/sys/src/kern/port/ps.c +++ b/sys/src/kern/port/ps.c @@ -90,7 +90,7 @@ psalloc(void) break; unlock(&procalloc.l); - snprint(msg, sizeof msg, "no procs; %s forking", + jehanne_snprint(msg, sizeof msg, "no procs; %s forking", up? up->text: "kernel"); resrcwait(msg, "Noprocs"); lock(&procalloc.l); @@ -111,7 +111,7 @@ psinit(int nproc) int i; procalloc.nproc = nproc; - procalloc.free = malloc(nproc*sizeof(Proc)); + procalloc.free = jehanne_malloc(nproc*sizeof(Proc)); if(procalloc.free == nil) panic("cannot allocate %ud procs (%udMB)\n", nproc, nproc*sizeof(Proc)/(1024*1024)); procalloc.arena = procalloc.free; diff --git a/sys/src/kern/port/qio.c b/sys/src/kern/port/qio.c index 8db328e..41e85fc 100644 --- a/sys/src/kern/port/qio.c +++ b/sys/src/kern/port/qio.c @@ -61,9 +61,9 @@ ixsummary(void) { debugging ^= 1; iallocsummary(); - print("pad %lud, concat %lud, pullup %lud, copy %lud\n", + jehanne_print("pad %lud, concat %lud, pullup %lud, copy %lud\n", padblockcnt, concatblockcnt, pullupblockcnt, copyblockcnt); - print("consume %lud, produce %lud, qcopy %lud\n", + jehanne_print("consume %lud, produce %lud, qcopy %lud\n", consumecnt, producecnt, qcopycnt); } @@ -105,7 +105,7 @@ padblock(Block *bp, int size) nbp = allocb(size+n); nbp->rp += size; nbp->wp = nbp->rp; - memmove(nbp->wp, bp->rp, n); + jehanne_memmove(nbp->wp, bp->rp, n); nbp->wp += n; freeb(bp); nbp->rp -= size; @@ -121,7 +121,7 @@ padblock(Block *bp, int size) n = BLEN(bp); padblockcnt++; nbp = allocb(size+n); - memmove(nbp->wp, bp->rp, n); + jehanne_memmove(nbp->wp, bp->rp, n); nbp->wp += n; freeb(bp); } @@ -177,7 +177,7 @@ concatblock(Block *bp) nb = allocb(blocklen(bp)); for(f = bp; f; f = f->next) { len = BLEN(f); - memmove(nb->wp, f->rp, len); + jehanne_memmove(nb->wp, f->rp, len); nb->wp += len; } concatblockcnt += BLEN(nb); @@ -219,7 +219,7 @@ pullupblock(Block *bp, int n) while(nbp = bp->next){ i = BLEN(nbp); if(i > n) { - memmove(bp->wp, nbp->rp, n); + jehanne_memmove(bp->wp, nbp->rp, n); pullupblockcnt++; bp->wp += n; nbp->rp += n; @@ -228,11 +228,11 @@ pullupblock(Block *bp, int n) } else { /* shouldn't happen but why crash if it does */ if(i < 0){ - print("pullupblock -ve length, from %#p\n", + jehanne_print("pullupblock -ve length, from %#p\n", getcallerpc()); i = 0; } - memmove(bp->wp, nbp->rp, i); + jehanne_memmove(bp->wp, nbp->rp, i); pullupblockcnt++; bp->wp += i; bp->next = nbp->next; @@ -327,12 +327,12 @@ copyblock(Block *bp, int count) l = BLEN(bp); if(l > count) l = count; - memmove(nbp->wp, bp->rp, l); + jehanne_memmove(nbp->wp, bp->rp, l); nbp->wp += l; count -= l; } if(count > 0){ - memset(nbp->wp, 0, count); + jehanne_memset(nbp->wp, 0, count); nbp->wp += count; } copyblockcnt++; @@ -362,7 +362,7 @@ adjustblock(Block* bp, int len) n = BLEN(bp); if(len > n) - memset(bp->wp, 0, len-n); + jehanne_memset(bp->wp, 0, len-n); bp->wp = bp->rp+len; QDEBUG checkb(bp, "adjustblock 2"); @@ -533,7 +533,7 @@ qconsume(Queue *q, void *vp, int len) if(n < len) len = n; - memmove(p, b->rp, len); + jehanne_memmove(p, b->rp, len); consumecnt += n; b->rp += len; q->dlen -= len; @@ -685,7 +685,7 @@ packblock(Block *bp) n = BLEN(nbp); if((n<<2) < BALLOC(nbp)){ *l = allocb(n); - memmove((*l)->wp, nbp->rp, n); + jehanne_memmove((*l)->wp, nbp->rp, n); (*l)->wp += n; (*l)->next = nbp->next; freeb(nbp); @@ -719,7 +719,7 @@ qproduce(Queue *q, void *vp, int len) iunlock(q); return 0; } - memmove(b->wp, p, len); + jehanne_memmove(b->wp, p, len); producecnt += len; b->wp += len; if(q->bfirst) @@ -783,7 +783,7 @@ qcopy(Queue *q, int len, uint32_t offset) for(sofar = 0; sofar < len;){ if(n > len - sofar) n = len - sofar; - memmove(nb->wp, p, n); + jehanne_memmove(nb->wp, p, n); qcopycnt += n; sofar += n; nb->wp += n; @@ -806,7 +806,7 @@ qopen(int limit, int msg, void (*kick)(void*), void *arg) { Queue *q; - q = malloc(sizeof(Queue)); + q = jehanne_malloc(sizeof(Queue)); if(q == 0) return 0; @@ -828,7 +828,7 @@ qbypass(void (*bypass)(void*, Block*), void *arg) { Queue *q; - q = malloc(sizeof(Queue)); + q = jehanne_malloc(sizeof(Queue)); if(q == 0) return 0; @@ -863,7 +863,7 @@ qwait(Queue *q) if(q->state & Qclosed){ if(++q->eof > 3) return -1; - if(*q->err && strcmp(q->err, Ehungup) != 0) + if(*q->err && jehanne_strcmp(q->err, Ehungup) != 0) return -1; return 0; } @@ -955,11 +955,11 @@ bl2mem(uint8_t *p, Block *b, int n) for(; b != nil; b = next){ i = BLEN(b); if(i > n){ - memmove(p, b->rp, n); + jehanne_memmove(p, b->rp, n); b->rp += n; return b; } - memmove(p, b->rp, i); + jehanne_memmove(p, b->rp, i); n -= i; p += i; b->rp += i; @@ -991,8 +991,8 @@ mem2bl(uint8_t *p, int len) n = Maxatomic; *l = b = allocb(n); - setmalloctag(b->base, getcallerpc()); - memmove(b->wp, p, n); + jehanne_setmalloctag(b->base, getcallerpc()); + jehanne_memmove(b->wp, p, n); b->wp += n; p += n; len -= n; @@ -1082,7 +1082,7 @@ qbread(Queue *q, int len) if((q->state&Qmsg) == 0){ n -= len; b = allocb(n); - memmove(b->wp, nb->rp+len, n); + jehanne_memmove(b->wp, nb->rp+len, n); b->wp += n; qputback(q, b); } @@ -1310,7 +1310,7 @@ qwrite(Queue *q, void *vp, int len) uint8_t *p = vp; QDEBUG if(!islo()) - print("qwrite hi %#p\n", getcallerpc()); + jehanne_print("qwrite hi %#p\n", getcallerpc()); sofar = 0; do { @@ -1319,12 +1319,12 @@ qwrite(Queue *q, void *vp, int len) n = Maxatomic; b = allocb(n); - setmalloctag(b->base, getcallerpc()); + jehanne_setmalloctag(b->base, getcallerpc()); if(waserror()){ freeb(b); nexterror(); } - memmove(b->wp, p+sofar, n); + jehanne_memmove(b->wp, p+sofar, n); poperror(); b->wp += n; @@ -1337,7 +1337,7 @@ qwrite(Queue *q, void *vp, int len) } /* - * used by print() to write to a queue. Since we may be splhi or not in + * used by jehanne_print() to write to a queue. Since we may be splhi or not in * a process, don't qlock. * * this routine merges adjacent blocks if block n+1 will fit into @@ -1361,7 +1361,7 @@ qiwrite(Queue *q, void *vp, int len) b = iallocb(n); if(b == nil) break; - memmove(b->wp, p+sofar, n); + jehanne_memmove(b->wp, p+sofar, n); b->wp += n; ilock(q); @@ -1411,7 +1411,7 @@ void qfree(Queue *q) { qclose(q); - free(q); + jehanne_free(q); } /* @@ -1430,7 +1430,7 @@ qclose(Queue *q) ilock(q); q->state |= Qclosed; q->state &= ~(Qflow|Qstarve); - strcpy(q->err, Ehungup); + jehanne_strcpy(q->err, Ehungup); bfirst = q->bfirst; q->bfirst = 0; q->len = 0; @@ -1457,9 +1457,9 @@ qhangup(Queue *q, char *msg) ilock(q); q->state |= Qclosed; if(msg == 0 || *msg == 0) - strcpy(q->err, Ehungup); + jehanne_strcpy(q->err, Ehungup); else - strncpy(q->err, msg, ERRMAX-1); + jehanne_strncpy(q->err, msg, ERRMAX-1); iunlock(q); /* wake up readers/writers */ diff --git a/sys/src/kern/port/qlock.c b/sys/src/kern/port/qlock.c index 3d93042..c56e2c5 100644 --- a/sys/src/kern/port/qlock.c +++ b/sys/src/kern/port/qlock.c @@ -39,9 +39,9 @@ qlock(QLock *q) void (*pt)(Proc*, int, int64_t, int64_t); if(m->ilockdepth != 0) - print("qlock: %#p: ilockdepth %d", getcallerpc(), m->ilockdepth); + jehanne_print("qlock: %#p: ilockdepth %d", getcallerpc(), m->ilockdepth); if(up != nil && up->nlocks) - print("qlock: %#p: nlocks %d", getcallerpc(), up->nlocks); + jehanne_print("qlock: %#p: nlocks %d", getcallerpc(), up->nlocks); lock(&q->use); rwstats.qlock++; @@ -92,7 +92,7 @@ qunlock(QLock *q) lock(&q->use); if (q->locked == 0) - print("qunlock called with qlock not held, from %#p\n", + jehanne_print("qunlock called with qlock not held, from %#p\n", getcallerpc()); p = q->head; if(p){ @@ -115,9 +115,9 @@ priqlock(QLock *q) void (*pt)(Proc*, int, int64_t, int64_t); if(m->ilockdepth != 0) - print("priqlock: %#p: ilockdepth %d\n", getcallerpc(), m->ilockdepth); + jehanne_print("priqlock: %#p: ilockdepth %d\n", getcallerpc(), m->ilockdepth); if(up != nil && up->nlocks) - print("priqlock: %#p: nlocks %d\n", getcallerpc(), up->nlocks); + jehanne_print("priqlock: %#p: nlocks %d\n", getcallerpc(), up->nlocks); lock(&q->use); if(!q->locked) { diff --git a/sys/src/kern/port/qmalloc.c b/sys/src/kern/port/qmalloc.c index aad0ab9..b5539fa 100644 --- a/sys/src/kern/port/qmalloc.c +++ b/sys/src/kern/port/qmalloc.c @@ -62,7 +62,6 @@ enum{ struct Qlist { - Lock lk; Header* first; uint32_t nalloc; @@ -70,7 +69,6 @@ struct Qlist struct Region { - Lock lk; Region* down; /* run as a stack */ Header* start; Header* tail; /* next available, if any */ @@ -206,16 +204,13 @@ static int freetail(Header *h) { if(h+h->s.size == tail->tail) { /* worthwhile locking? */ - MLOCK; if(h+h->s.size == tail->tail){ /* block before tail */ tail->tail = h; tail->size += h->s.size; qstats[QSfreetail]++; - MUNLOCK; return 1; } - MUNLOCK; } return 0; } @@ -226,10 +221,8 @@ freequick(Header *t) Qlist *ql; ql = &quicklist[t->s.size]; - ilock(&ql->lk); t->s.next = ql->first; ql->first = t; - iunlock(&ql->lk); qstats[QSfreequick]++; } @@ -258,14 +251,14 @@ showchain(Header *p) static void badchain(char *tag, char *why, Header *p, Header *q, Header *r, void *h, Header *split) { - showchain(&misclist); + if(0)showchain(&misclist); if(split != nil) - panic("%s: %s: %#p %#ux %#ux -> %#p %#ux %#ux [%#p -| %#p]%s %#p %#ux %#ux\n", tag, why, + panic("badchain %s: %s: %#p %#ux %#ux -> %#p %#ux %#ux [%#p -| %#p]%s %#p %#ux %#ux\n", tag, why, q, q->s.size, q->s.tag, r, r->s.size, r->s.tag, p, h, " split", split, split->s.size, split->s.tag); else - panic("%s: %s: %#p %#ux %#ux -> %#p %#ux %#ux [%#p -| %#p]\n", tag, why, + panic("badchain %s: %s: %#p %#ux %#ux -> %#p %#ux %#ux [%#p -| %#p]\n", tag, why, q, q->s.size, q->s.tag, r, r->s.size, r->s.tag, p, h); @@ -286,7 +279,7 @@ contained(Header *b, Header *chain) return q; }while((q = q->s.next) != chain && ++i < 100000); if(i >= 100000) - print("long check chain\n"); + jehanne_print("long check chain\n"); return 0; } @@ -307,7 +300,7 @@ checkchain(Header *p, char *tag, void *h, Header *split) badchain(tag, "mentioned", p, q, r, h, split); }while((q = q->s.next) != p && ++i < 100000); if(i >= 100000) - print("long chain\n"); + jehanne_print("long chain\n"); } static void* @@ -334,19 +327,19 @@ qallocalign(usize nbytes, uintptr_t align, long offset, usize span, uintptr_t pc * Look for a conveniently aligned block * on one of the quicklists. */ + MLOCK; qlist = &quicklist[nunits]; - ilock(&qlist->lk); for(pp = &qlist->first; (p = *pp) != nil; pp = &p->s.next){ if(ALIGNED(p+1, align)){ *pp = p->s.next; p->s.size |= Busy; - qstats[QSmalignquick]++; - iunlock(&qlist->lk); + MUNLOCK; p->s.tag = pc; + qstats[QSmalignquick]++; return H2D(p); } } - iunlock(&qlist->lk); + MUNLOCK; } alunits = HOWMANY(align, Unitsz); @@ -402,9 +395,9 @@ qallocalign(usize nbytes, uintptr_t align, long offset, usize span, uintptr_t pc } p->s.size |= Busy; + p->s.next = nil; MUNLOCK; - p->s.next = nil; p->s.tag = pc; return H2D(p); } @@ -442,9 +435,9 @@ qallocalign(usize nbytes, uintptr_t align, long offset, usize span, uintptr_t pc qstats[QSmalignnottail]++; freemisc(r); /* put on misc list to allow combining if this block is freed */ } + p->s.next = nil; MUNLOCK; - p->s.next = nil; p->s.tag = pc; return H2D(p); } @@ -460,35 +453,37 @@ qalloc(usize nbytes, uintptr_t pc) if(nbytes == 0) return nil; + split = 0; nunits = NUNITS(nbytes); for(u = nunits; u <= NQUICK; u++){ + MLOCK; qlist = &quicklist[u]; - ilock(&qlist->lk); if((p = qlist->first) != nil){ qlist->first = p->s.next; qlist->nalloc++; - iunlock(&qlist->lk); - p->s.next = nil; if(p->s.size >= nunits+2*MinUnits){ /* don't make blocks pointlessly small */ t = p; t->s.size -= nunits; p += t->s.size; p->s.size = nunits; freequick(t); - qstats[QSsplitquick]++; + split = 1; } + p->s.next = nil; p->s.size |= Busy; + MUNLOCK; p->s.tag = pc; + if(split) + qstats[QSsplitquick]++; return H2D(p); } - iunlock(&qlist->lk); + MUNLOCK; } MLOCK; if(nunits > tail->size) { /* hard way */ q = rover; - split = 0; checkchain(q, "qalloc-1", rover, 0); do { p = q->s.next; @@ -575,7 +570,7 @@ freemisc(Header *p) } uint32_t -msize(void* ap) +jehanne_msize(void* ap) { BigAlloc *b; Header *h; @@ -613,29 +608,29 @@ mallocreadfmt(char* s, char* e) n = 0; u = 0; for(r = tail; r != nil; r = r->down){ - p = seprint(p, e, "reg%d: %#p %#p %#p : %#p %#p\n", n, r, r->base, r->limit, r->start, r->tail); + p = jehanne_seprint(p, e, "reg%d: %#p %#p %#p : %#p %#p\n", n, r, r->base, r->limit, r->start, r->tail); t += r->limit - r->base; u += (r->tail - r->start)*Unitsz; n++; } MUNLOCK; - p = seprint(p, e, "%P kernel malloc %P used %d regions\n", t, u, n); - p = seprint(p, e, "0/0 kernel draw\n"); // keep scripts happy + p = jehanne_seprint(p, e, "%P kernel malloc %P used %d regions\n", t, u, n); + p = jehanne_seprint(p, e, "0/0 kernel draw\n"); // keep scripts happy t = 0; for(i = 0; i <= NQUICK; i++) { n = 0; + MLOCK; qlist = &quicklist[i]; - ilock(&qlist->lk); for(q = qlist->first; q != nil; q = q->s.next) n++; - iunlock(&qlist->lk); + MUNLOCK; if(n != 0) - p = seprint(p, e, "q%d %ud %ud %ud\n", i, n, n*i*Unitsz, qlist->nalloc); + p = jehanne_seprint(p, e, "q%d %ud %ud %ud\n", i, n, n*i*Unitsz, qlist->nalloc); t += n * i*Unitsz; } - p = seprint(p, e, "quick: %P bytes total\n", t); + p = jehanne_seprint(p, e, "quick: %P bytes total\n", t); MLOCK; if((q = rover) != nil){ @@ -643,17 +638,17 @@ mallocreadfmt(char* s, char* e) do { t += q->s.size; i++; -// p = seprint(p, e, "m%d\t%#p\n", q->s.size, q); +// p = jehanne_seprint(p, e, "m%d\t%#p\n", q->s.size, q); } while((q = q->s.next) != rover); - p = seprint(p, e, "rover: %d blocks %P bytes total\n", + p = jehanne_seprint(p, e, "rover: %d blocks %P bytes total\n", i, t*Unitsz); } MUNLOCK; for(i = 0; i < nelem(qstats); i++) if(qstats[i] != 0) - p = seprint(p, e, "%s: %ud\n", qstatname[i], qstats[i]); + p = jehanne_seprint(p, e, "%s: %ud\n", qstatname[i], qstats[i]); USED(p); } @@ -662,15 +657,15 @@ mallocreadsummary(Chan* _1, void *a, long n, long offset) { char *alloc; - alloc = malloc(READSTR); + alloc = jehanne_malloc(READSTR); if(waserror()){ - free(alloc); + jehanne_free(alloc); nexterror(); } mallocreadfmt(alloc, alloc+READSTR); n = readstr(offset, a, n, alloc); poperror(); - free(alloc); + jehanne_free(alloc); return n; } @@ -786,18 +781,18 @@ mallocsummary(void) t = 0; for(i = 0; i <= NQUICK; i++) { n = 0; + MLOCK; qlist = &quicklist[i]; - ilock(&qlist->lk); for(q = qlist->first; q != nil; q = q->s.next){ if(q->s.size != i) DBG("q%d\t%#p\t%ud\n", i, q, q->s.size); n++; } - iunlock(&qlist->lk); + MUNLOCK; t += n * i*Unitsz; } - print("quick: %ud bytes total\n", t); + jehanne_print("quick: %ud bytes total\n", t); MLOCK; if((q = rover) != nil){ @@ -814,22 +809,22 @@ mallocsummary(void) MUNLOCK; if(i != 0){ - print("rover: %d blocks %ud bytes total\n", + jehanne_print("rover: %d blocks %ud bytes total\n", i, t*Unitsz); while(--i >= 0) if(i < nelem(rovers) && rovers[i].size != 0) - print("R%d: %#8.8ux %ud\n", i, rovers[i].tag, rovers[i].size); + jehanne_print("R%d: %#8.8ux %ud\n", i, rovers[i].tag, rovers[i].size); } for(i = 0; i < nelem(qstats); i++){ if(qstats[i] == 0) continue; - print("%s: %ud\n", qstatname[i], qstats[i]); + jehanne_print("%s: %ud\n", qstatname[i], qstats[i]); } } void -free(void* ap) +jehanne_free(void* ap) { Header *h; BigAlloc *b; @@ -856,15 +851,15 @@ free(void* ap) if(memprof != nil) memprof(ap, h->s.tag, (nunits-1)*Unitsz, -1); if(Poisoning) - memset(h+1, 0xAA, (nunits-1)*Unitsz); + jehanne_memset(h+1, 0xAA, (nunits-1)*Unitsz); + MLOCK; if(!freetail(h)){ if(nunits > NQUICK){ - MLOCK; freemisc(h); - MUNLOCK; }else freequick(h); } + MUNLOCK; } void* @@ -873,7 +868,7 @@ qmalloc(uint32_t size) void* v; qstats[QSmalloc]++; -if(size > 1536*1024)print("qmalloc %lud %#p\n", size, getcallerpc()); +if(size > 1536*1024)jehanne_print("qmalloc %lud %#p\n", size, getcallerpc()); if(size >= BigThreshold) v = bigalloc(size, 0, getcallerpc()); else @@ -882,28 +877,28 @@ if(size > 1536*1024)print("qmalloc %lud %#p\n", size, getcallerpc()); } void* -malloc(uint32_t size) +jehanne_malloc(uint32_t size) { void* v; qstats[QSmalloc]++; -if(size > 1536*1024)print("malloc %lud %#p\n", size, getcallerpc()); +if(size > 1536*1024)jehanne_print("malloc %lud %#p\n", size, getcallerpc()); if(size >= BigThreshold) v = bigalloc(size, 0, getcallerpc()); else v = qalloc(size, getcallerpc()); if(v != nil) - memset(v, 0, size); + jehanne_memset(v, 0, size); return v; } void* -mallocz(uint32_t size, int clr) +jehanne_mallocz(uint32_t size, int clr) { void *v; qstats[QSmalloc]++; -if(size > 1900*1024)print("mallocz %lud %#p\n", size, getcallerpc()); +if(size > 1900*1024)jehanne_print("mallocz %lud %#p\n", size, getcallerpc()); if(size >= BigThreshold) v = bigalloc(size, 0, getcallerpc()); else @@ -911,12 +906,12 @@ if(size > 1900*1024)print("mallocz %lud %#p\n", size, getcallerpc()); if(v == nil) return nil; if(clr) - memset(v, 0, size); + jehanne_memset(v, 0, size); return v; } void* -mallocalign(uint32_t nbytes, uint32_t align, long offset, uint32_t span) +jehanne_mallocalign(uint32_t nbytes, uint32_t align, long offset, uint32_t span) { void *v; @@ -928,9 +923,9 @@ mallocalign(uint32_t nbytes, uint32_t align, long offset, uint32_t span) span = 0; } if(align <= Align) - return mallocz(nbytes, 1); + return jehanne_mallocz(nbytes, 1); -if(nbytes > 1900*1024)print("mallocalign %lud %lud %#p\n", nbytes, align, getcallerpc()); +if(nbytes > 1900*1024)jehanne_print("mallocalign %lud %lud %#p\n", nbytes, align, getcallerpc()); if(nbytes >= BigThreshold) v = bigalloc(nbytes, align, getcallerpc()); @@ -939,7 +934,7 @@ if(nbytes > 1900*1024)print("mallocalign %lud %lud %#p\n", nbytes, align, getcal if(v != nil){ if(align && (uintptr_t)v & (align-1)) panic("mallocalign %#p %#lux", v, align); - memset(v, 0, nbytes); /* leave it to caller? */ + jehanne_memset(v, 0, nbytes); /* leave it to caller? */ } return v; } @@ -949,9 +944,9 @@ sqmalloc(uint32_t size) { void *v; - while((v = malloc(size)) == nil) + while((v = jehanne_malloc(size)) == nil) tsleep(&up->sleep, return0, 0, 100); - setmalloctag(v, getcallerpc()); + jehanne_setmalloctag(v, getcallerpc()); return v; } @@ -961,16 +956,16 @@ smalloc(uint32_t size) { void *v; - while((v = malloc(size)) == nil) + while((v = jehanne_malloc(size)) == nil) tsleep(&up->sleep, return0, 0, 100); - setmalloctag(v, getcallerpc()); - memset(v, 0, size); + jehanne_setmalloctag(v, getcallerpc()); + jehanne_memset(v, 0, size); return v; } void* -realloc(void* ap, uint32_t size) +jehanne_realloc(void* ap, uint32_t size) { void *v; Header *h; @@ -989,13 +984,13 @@ realloc(void* ap, uint32_t size) * do nothing if units are the same. */ if(size == 0){ - free(ap); + jehanne_free(ap); return nil; } if(ap == nil){ - v = malloc(size); + v = jehanne_malloc(size); if(v != nil) - setmalloctag(v, getcallerpc()); + jehanne_setmalloctag(v, getcallerpc()); return v; } @@ -1035,19 +1030,19 @@ realloc(void* ap, uint32_t size) * allocate, copy and free. * The original block must be unchanged on failure. */ - if((v = malloc(size)) != nil){ - setmalloctag(v, getcallerpc()); + if((v = jehanne_malloc(size)) != nil){ + jehanne_setmalloctag(v, getcallerpc()); if(size < osize) osize = size; - memmove(v, ap, osize); - free(ap); + jehanne_memmove(v, ap, osize); + jehanne_free(ap); } return v; } void -setmalloctag(void *a, uint32_t tag) +jehanne_setmalloctag(void *a, uint32_t tag) { Header *h; BigAlloc *b; @@ -1067,7 +1062,7 @@ setmalloctag(void *a, uint32_t tag) } uint32_t -getmalloctag(void *a) +jehanne_getmalloctag(void *a) { BigAlloc *b; @@ -1095,7 +1090,7 @@ mallocinit(void) p->next = nil; if(!morecore(BigThreshold/Unitsz)) panic("mallocinit"); - print("base %#p bound %#p nunits %lud\n", tail->start, tail->end, tail->end - tail->start); + jehanne_print("base %#p bound %#p nunits %lud\n", tail->start, tail->end, tail->end - tail->start); } /* diff --git a/sys/src/kern/port/rmap.c b/sys/src/kern/port/rmap.c index afc3f17..d300cfa 100644 --- a/sys/src/kern/port/rmap.c +++ b/sys/src/kern/port/rmap.c @@ -45,7 +45,7 @@ rmapfree(RMap* rmap, uintmem addr, uintmem size) if(p != nil && p->addr+p->size > addr || n != nil && addr+size > n->addr){ iunlock(&rmap->l); - print("rmapfree: overlap: %#P %#P (%lld)\n", addr, size, (uint64_t)size); + jehanne_print("rmapfree: overlap: %#P %#P (%lld)\n", addr, size, (uint64_t)size); return; } @@ -70,7 +70,7 @@ rmapfree(RMap* rmap, uintmem addr, uintmem size) p->next = n; *lp = p; }else - print("rmapfree: %s: losing 0x%llux, %llud\n", rmap->name, (uint64_t)addr, (uint64_t)size); + jehanne_print("rmapfree: %s: losing 0x%llux, %llud\n", rmap->name, (uint64_t)addr, (uint64_t)size); } } iunlock(&rmap->l); @@ -207,7 +207,7 @@ rmapprint(RMap *r) { RMapel *e; - print("%s:\n", r->name); + jehanne_print("%s:\n", r->name); for(e = r->map; e != nil; e = e->next) - print("\t%#P %#P (%llud)\n", e->addr, e->addr+e->size, (uint64_t)e->size); + jehanne_print("\t%#P %#P (%llud)\n", e->addr, e->addr+e->size, (uint64_t)e->size); } diff --git a/sys/src/kern/port/sd.h b/sys/src/kern/port/sd.h index 1f7f2c8..4668c7a 100644 --- a/sys/src/kern/port/sd.h +++ b/sys/src/kern/port/sd.h @@ -142,8 +142,8 @@ enum { * page-aligned (xen) for DMA. */ #ifndef sdmalloc -#define sdmalloc(n) malloc(n) -#define sdfree(p) free(p) +#define sdmalloc(n) jehanne_malloc(n) +#define sdfree(p) jehanne_free(p) #endif /* diff --git a/sys/src/kern/port/sysauth.c b/sys/src/kern/port/sysauth.c index 290a7b4..73b6b5a 100644 --- a/sys/src/kern/port/sysauth.c +++ b/sys/src/kern/port/sysauth.c @@ -33,7 +33,7 @@ char hostdomain[DOMLEN]; int iseve(void) { - return strcmp(eve, up->user) == 0; + return jehanne_strcmp(eve, up->user) == 0; } int @@ -50,7 +50,7 @@ sysfversion(int fd, int msize, char *version, int nversion) version = validaddr(version, nversion, 1); /* check there's a NUL in the version string */ - if(nversion == 0 || memchr(version, 0, nversion) == nil) + if(nversion == 0 || jehanne_memchr(version, 0, nversion) == nil) error(Ebadarg); c = fdtochan(fd, ORDWR, 0, 1); @@ -75,7 +75,7 @@ sysfauth(int fd, char *aname) aname = validaddr(aname, 1, 0); aname = validnamedup(aname, 1); if(waserror()){ - free(aname); + jehanne_free(aname); nexterror(); } c = fdtochan(fd, ORDWR, 0, 1); @@ -88,7 +88,7 @@ sysfauth(int fd, char *aname) /* at this point ac is responsible for keeping c alive */ cclose(c); poperror(); /* c */ - free(aname); + jehanne_free(aname); poperror(); /* aname */ if(waserror()){ @@ -115,7 +115,7 @@ sysfauth(int fd, char *aname) long userwrite(char* a, long n) { - if(n != 4 || strncmp(a, "none", 4) != 0) + if(n != 4 || jehanne_strncmp(a, "none", 4) != 0) error(Eperm); kstrdup(&up->user, "none"); up->basepri = PriNormal; @@ -137,7 +137,7 @@ hostownerwrite(char* a, long n) error(Eperm); if(n <= 0 || n >= sizeof buf) error(Ebadarg); - memmove(buf, a, n); + jehanne_memmove(buf, a, n); buf[n] = 0; renameuser(eve, buf); @@ -159,11 +159,11 @@ hostdomainwrite(char* a, long n) error(Eperm); if(n >= DOMLEN) error(Ebadarg); - memset(buf, 0, DOMLEN); - strncpy(buf, a, n); + jehanne_memset(buf, 0, DOMLEN); + jehanne_strncpy(buf, a, n); if(buf[0] == 0) error(Ebadarg); - memmove(hostdomain, buf, DOMLEN); + jehanne_memmove(hostdomain, buf, DOMLEN); return n; } diff --git a/sys/src/kern/port/syscallfmt.c b/sys/src/kern/port/syscallfmt.c index 5457d6e..a057074 100644 --- a/sys/src/kern/port/syscallfmt.c +++ b/sys/src/kern/port/syscallfmt.c @@ -31,7 +31,7 @@ fmtrwdata(Fmt* f, char* a, int n) char *t; if(a == nil){ - fmtprint(f, " 0x0%s"); + jehanne_fmtprint(f, " 0x0%s"); return; } a = validaddr(a, n, 0); @@ -44,8 +44,8 @@ fmtrwdata(Fmt* f, char* a, int n) } t[n] = 0; - fmtprint(f, " %#p/\"%s\"", a, t); - free(t); + jehanne_fmtprint(f, " %#p/\"%s\"", a, t); + jehanne_free(t); } void @@ -55,16 +55,16 @@ fmtuserstring(Fmt* f, const char* a) char *t; if(a == nil){ - fmtprint(f, " 0/\"\""); + jehanne_fmtprint(f, " 0/\"\""); return; } a = validaddr((void*)a, 1, 0); n = ((char*)vmemchr((char*)a, 0, 0x7fffffff) - a) + 1; t = smalloc(n+1); - memmove(t, (char*)a, n); + jehanne_memmove(t, (char*)a, n); t[n] = 0; - fmtprint(f, " %#p/\"%s\"", a, t); - free(t); + jehanne_fmtprint(f, " %#p/\"%s\"", a, t); + jehanne_free(t); } void @@ -76,7 +76,7 @@ fmtuserstringlist(Fmt* fmt, const char** argv) a = *(char**)validaddr((char**)argv, sizeof(char**), 0); if(a == nil) break; - fmtprint(fmt, " "); + jehanne_fmtprint(fmt, " "); fmtuserstring(fmt, a); argv++; } diff --git a/sys/src/kern/port/sysfile.c b/sys/src/kern/port/sysfile.c index 62c4bcb..47ed922 100644 --- a/sys/src/kern/port/sysfile.c +++ b/sys/src/kern/port/sysfile.c @@ -52,16 +52,16 @@ growfd(Fgrp *f, int fd) /* fd is always >= 0 */ */ if(f->nfd >= 5000){ Exhausted: - print("no free file descriptors\n"); + jehanne_print("no free file descriptors\n"); return -1; } - newfd = malloc((f->nfd+DELTAFD)*sizeof(Chan*)); + newfd = jehanne_malloc((f->nfd+DELTAFD)*sizeof(Chan*)); if(newfd == nil) goto Exhausted; oldfd = f->fd; - memmove(newfd, oldfd, f->nfd*sizeof(Chan*)); + jehanne_memmove(newfd, oldfd, f->nfd*sizeof(Chan*)); f->fd = newfd; - free(oldfd); + jehanne_free(oldfd); f->nfd += DELTAFD; if(fd > f->maxfd){ if(fd/100 > f->maxfd/100) @@ -173,7 +173,7 @@ sysfd2path(int fd, char* buf, int nbuf) buf = validaddr(buf, nbuf, 1); c = fdtochan(fd, -1, 0, 1); - snprint(buf, nbuf, "%s", chanpath(c)); + jehanne_snprint(buf, nbuf, "%s", chanpath(c)); cclose(c); return 0; @@ -405,9 +405,9 @@ dirsetname(char *name, usize len, uint8_t *p, usize n, usize maxn) return BIT16SZ; if(len != olen) - memmove(oname+len, oname+olen, p+n-(uint8_t*)(oname+olen)); + jehanne_memmove(oname+len, oname+olen, p+n-(uint8_t*)(oname+olen)); PBIT16((uint8_t*)(oname-2), len); - memmove(oname, name, len); + jehanne_memmove(oname, name, len); return nn; } @@ -437,12 +437,12 @@ mountrock(Chan *c, uint8_t *p, uint8_t **pe) if(c->nrock+len > c->mrock){ n = ROUNDUP(c->nrock+len, 1024); r = smalloc(n); - memmove(r, c->dirrock, c->nrock); - free(c->dirrock); + jehanne_memmove(r, c->dirrock, c->nrock); + jehanne_free(c->dirrock); c->dirrock = r; c->mrock = n; } - memmove(c->dirrock+c->nrock, p, len); + jehanne_memmove(c->dirrock+c->nrock, p, len); c->nrock += len; qunlock(&c->rockqlock); @@ -473,7 +473,7 @@ mountrockread(Chan *c, uint8_t *op, int32_t n, int32_t *nn) dirlen = BIT16SZ+GBIT16(rp); if(p+dirlen > ep) break; - memmove(p, rp, dirlen); + jehanne_memmove(p, rp, dirlen); p += dirlen; rp += dirlen; } @@ -485,7 +485,7 @@ mountrockread(Chan *c, uint8_t *op, int32_t n, int32_t *nn) /* shift the rest */ if(rp != erp) - memmove(c->dirrock, rp, erp-rp); + jehanne_memmove(c->dirrock, rp, erp-rp); c->nrock = erp - rp; *nn = p - op; @@ -572,7 +572,7 @@ mountfix(Chan *c, uint8_t *op, int32_t n, int32_t maxn) } } if(r != dirlen){ - memmove(p+r, p+dirlen, rest); + jehanne_memmove(p+r, p+dirlen, rest); dirlen = r; e = p+dirlen+rest; } @@ -580,7 +580,7 @@ mountfix(Chan *c, uint8_t *op, int32_t n, int32_t maxn) /* * Rewrite directory entry. */ - memmove(p, buf, r); + jehanne_memmove(p, buf, r); Norewrite: cclose(nc); @@ -588,7 +588,7 @@ mountfix(Chan *c, uint8_t *op, int32_t n, int32_t maxn) } } if(buf) - free(buf); + jehanne_free(buf); if(p != e) error("oops in mountfix"); @@ -792,7 +792,7 @@ sseek(int fd, int64_t offset, int whence) if(c->qid.type & QTDIR) error(Eisdir); n = c->dev->stat(c, buf, sizeof buf); - if(convM2D(buf, n, &dir, nil) == 0) + if(jehanne_convM2D(buf, n, &dir, nil) == 0) error("internal error: stat error in seek"); offset += dir.length; c->offset = offset; @@ -835,10 +835,10 @@ validstat(uint8_t *s, usize n) s += BIT16SZ; if(m+1 > sizeof buf) return; - memmove(buf, s, m); + jehanne_memmove(buf, s, m); buf[m] = '\0'; /* name could be '/' */ - if(strcmp(buf, "/") != 0) + if(jehanne_strcmp(buf, "/") != 0) validname(buf, 0); } @@ -852,7 +852,7 @@ pathlast(Path *p) return nil; if(p->len == 0) return nil; - s = strrchr(p->s, '/'); + s = jehanne_strrchr(p->s, '/'); if(s) return s+1; return p->s; @@ -915,7 +915,7 @@ bindmount(int dc, int fd, int afd, char* arg0, char* arg1, int flag, char* spec) validaddr(spec, 1, 0); spec = validnamedup(spec, 1); if(waserror()){ - free(spec); + jehanne_free(spec); nexterror(); } if (! checkdc(dc)) @@ -968,7 +968,7 @@ bindmount(int dc, int fd, int afd, char* arg0, char* arg1, int flag, char* spec) if(dc){ fdclose(fd, 0); poperror(); - free(spec); + jehanne_free(spec); } return i; } diff --git a/sys/src/kern/port/sysproc.c b/sys/src/kern/port/sysproc.c index 5a864e5..cdbbd1f 100644 --- a/sys/src/kern/port/sysproc.c +++ b/sys/src/kern/port/sysproc.c @@ -101,13 +101,13 @@ sysrfork(uint32_t flag) p->trace = up->trace; p->scallnr = up->scallnr; - memmove(p->arg, up->arg, sizeof(up->arg)); + jehanne_memmove(p->arg, up->arg, sizeof(up->arg)); p->nerrlab = 0; p->slash = up->slash; p->dot = up->dot; incref(&p->dot->r); - memmove(p->note, up->note, sizeof(p->note)); + jehanne_memmove(p->note, up->note, sizeof(p->note)); p->privatemem = up->privatemem; p->nnote = up->nnote; p->notified = 0; @@ -127,11 +127,11 @@ sysrfork(uint32_t flag) } --i; } - memset(p->seg, 0, NSEG*sizeof(ProcSegment*)); + jehanne_memset(p->seg, 0, NSEG*sizeof(ProcSegment*)); runlock(&up->seglock); nexterror(); } - memmove(p->seg, up->seg, NSEG*sizeof(ProcSegment*)); + jehanne_memmove(p->seg, up->seg, NSEG*sizeof(ProcSegment*)); if(flag & RFMEM){ for(i = 0; i < NSEG; i++){ s = p->seg[i]; @@ -218,7 +218,7 @@ sysrfork(uint32_t flag) p->noteid = up->noteid; pid = p->pid; - memset(p->time, 0, sizeof(p->time)); + jehanne_memset(p->time, 0, sizeof(p->time)); p->time[TReal] = sys->ticks; kstrdup(&p->text, up->text); @@ -237,7 +237,7 @@ sysrfork(uint32_t flag) if(wm) procwired(p, wm->machno); if(p->trace && (pt = proctrace) != nil){ - strncpy((char*)&ptarg, p->text, sizeof ptarg); + jehanne_strncpy((char*)&ptarg, p->text, sizeof ptarg); pt(p, SName, 0, ptarg); } ready(p); @@ -272,7 +272,7 @@ sysexec(char* p, char **argv) file = validnamedup(p, 1); MLG("file %d", file); if(waserror()){ - free(file); + jehanne_free(file); nexterror(); } chan = namec(file, Aopen, OEXEC, 0); @@ -280,7 +280,7 @@ sysexec(char* p, char **argv) if(chan) cclose(chan); if(elem != nil) - free(elem); + jehanne_free(elem); nexterror(); } kstrdup(&elem, up->genbuf); @@ -298,11 +298,11 @@ sysexec(char* p, char **argv) argc = 0; progargc = 0; if(line[0] == '#' && line[1] == '!'){ - p = memchr(line, '\n', MIN(sizeof line, hdrsz)); + p = jehanne_memchr(line, '\n', MIN(sizeof line, hdrsz)); if(p == nil) error(Ebadexec); *p = '\0'; - argc = tokenize(line+2, progarg, nelem(progarg)); + argc = jehanne_tokenize(line+2, progarg, nelem(progarg)); if(argc == 0) error(Ebadexec); @@ -331,7 +331,7 @@ sysexec(char* p, char **argv) */ nldseg = elf64ldseg(chan, &entry, &ldseg, cputype, PGSZ); if(nldseg != 2){ -// print("exec: elf64ldseg returned %d segs!\n", nldseg); +// jehanne_print("exec: elf64ldseg returned %d segs!\n", nldseg); error(Ebadexec); } @@ -363,7 +363,7 @@ sysexec(char* p, char **argv) /* start with arguments found from a #! header. */ for(i = 0; i < argc; i++) - argsize += strlen(progarg[i]) + 1 + sizeof(char*); + argsize += jehanne_strlen(progarg[i]) + 1 + sizeof(char*); /* then size strings pointed to by the syscall argument * argv verifing that both argv and the strings it @@ -385,7 +385,7 @@ sysexec(char* p, char **argv) if(argc > 0 && i == 0) continue; argsize += n + sizeof(char*); -//print("argv[%d] = %s, argsize %d, n %d\n", argc, a, argsize, n); +//jehanne_print("argv[%d] = %s, argsize %d, n %d\n", argc, a, argsize, n); argc++; } if(argc < 1) @@ -412,7 +412,7 @@ sysexec(char* p, char **argv) error(Enovmem); } -//print("argsize %d, first stack page %d\n", argsize, stack); +//jehanne_print("argsize %d, first stack page %d\n", argsize, stack); /* Step 2: Copy arguments into pages in descending order */ @@ -444,17 +444,17 @@ sysexec(char* p, char **argv) * from a #! header. */ for(i = 0; i < progargc; i++){ - n = strlen(progarg[i])+1; + n = jehanne_strlen(progarg[i])+1; CopyProgArgument: if(sbottom <= stack-n){ a = pmem+((stack-n)&(PGSZ-1)); - memmove(a, progarg[i], n); + jehanne_memmove(a, progarg[i], n); stack -= n; } else { /* the current argument cross multiple pages */ if(stack&(PGSZ-1)){ /* fill the rest of the current page */ - memmove(pmem, progarg[i]+n-1-(stack&(PGSZ-1)), (stack&(PGSZ-1))-1); + jehanne_memmove(pmem, progarg[i]+n-1-(stack&(PGSZ-1)), (stack&(PGSZ-1))-1); *(pmem+(stack&(PGSZ-1))-1) = 0; n -= (stack&(PGSZ-1)); stack -= (stack&(PGSZ-1)); @@ -468,7 +468,7 @@ CopyProgArgument: pmem = page_kmap(page); if(n > PGSZ){ /* fill one full page */ - memmove(pmem, progarg[i]+n-PGSZ, PGSZ); + jehanne_memmove(pmem, progarg[i]+n-PGSZ, PGSZ); n -= PGSZ; stack -= PGSZ; } @@ -491,18 +491,18 @@ CopyProgArgument: */ for(; i < argc; i++){ j = i - progargc; - n = strlen(argv[j])+1; + n = jehanne_strlen(argv[j])+1; CopyExecArgument: if(sbottom <= stack-n){ a = pmem+((stack-n)&(PGSZ-1)); - memmove(a, argv[j], n); + jehanne_memmove(a, argv[j], n); stack -= n; } else { /* the current argument cross multiple pages */ if(stack&(PGSZ-1)){ /* fill the rest of the current page */ - memmove(pmem, argv[j]+n-1-(stack&(PGSZ-1)), (stack&(PGSZ-1))-1); + jehanne_memmove(pmem, argv[j]+n-1-(stack&(PGSZ-1)), (stack&(PGSZ-1))-1); *(pmem+(stack&(PGSZ-1))-1) = 0; n -= (stack&(PGSZ-1)); stack -= (stack&(PGSZ-1)); @@ -516,7 +516,7 @@ CopyExecArgument: pmem = page_kmap(page); if(n > PGSZ){ /* fill one full page */ - memmove(pmem, argv[j]+n-PGSZ, PGSZ); + jehanne_memmove(pmem, argv[j]+n-PGSZ, PGSZ); n -= PGSZ; stack -= PGSZ; } @@ -574,7 +574,7 @@ CopyExecArgument: tmp)) error(Enovmem); - free(ldseg); /* free elf segments */ + jehanne_free(ldseg); /* free elf segments */ /* * Close on exec @@ -604,7 +604,7 @@ CopyExecArgument: } if(up->trace && (pt = proctrace) != nil){ - strncpy((char*)&ptarg, elem, sizeof ptarg); + jehanne_strncpy((char*)&ptarg, elem, sizeof ptarg); pt(up, SName, 0, ptarg); } @@ -624,11 +624,11 @@ CopyExecArgument: poperror(); /* img */ image_release(img); - free(up->text); + jehanne_free(up->text); up->text = elem; elem = nil; if(up->setargs) /* setargs == 0 => args in stack from sysexec */ - free(up->args); + jehanne_free(up->args); up->args = argvcopy; up->nargs = argc; up->setargs = 0; @@ -656,7 +656,7 @@ CopyExecArgument: poperror(); /* chan, elem */ cclose(chan); poperror(); /* file */ - free(file); + jehanne_free(file); qlock(&up->debug); up->nnote = 0; @@ -701,7 +701,7 @@ sys_exits(char *status) else{ status = validaddr(status, 1, 0); if(vmemchr(status, 0, ERRMAX) == 0){ - memmove(buf, status, ERRMAX); + jehanne_memmove(buf, status, ERRMAX); buf[ERRMAX-1] = 0; status = buf; } @@ -730,7 +730,7 @@ sysawait(char *p, int n) if(pid < 0) return -1; - i = snprint(p, n, "%d %lud %lud %lud %q", + i = jehanne_snprint(p, n, "%d %lud %lud %lud %q", w.pid, w.time[TUser], w.time[TSys], w.time[TReal], w.msg); @@ -739,7 +739,7 @@ sysawait(char *p, int n) } void -werrstr(char *fmt, ...) +jehanne_werrstr(char *fmt, ...) { va_list va; @@ -747,7 +747,7 @@ werrstr(char *fmt, ...) return; va_start(va, fmt); - vseprint(up->syserrstr, up->syserrstr+ERRMAX, fmt, va); + jehanne_vseprint(up->syserrstr, up->syserrstr+ERRMAX, fmt, va); va_end(va); } @@ -761,13 +761,13 @@ generrstr(char *buf, int n) p = validaddr(buf, n, 1); if(n > sizeof tmp) n = sizeof tmp; - memmove(tmp, p, n); + jehanne_memmove(tmp, p, n); /* make sure it's NUL-terminated */ tmp[n-1] = '\0'; - memmove(p, up->syserrstr, n); + jehanne_memmove(p, up->syserrstr, n); p[n-1] = '\0'; - memmove(up->syserrstr, tmp, n); + jehanne_memmove(up->syserrstr, tmp, n); } int @@ -950,7 +950,7 @@ rendezvousDone: static void semqueue(ProcSegment* s, int* addr, Sema* p) { - memset(p, 0, sizeof *p); + jehanne_memset(p, 0, sizeof *p); p->addr = addr; lock(&s->sema.rend.l); /* uses s->sema.Rendez.Lock, but no one else is */ diff --git a/sys/src/kern/port/tod.c b/sys/src/kern/port/tod.c index da8b018..cb4f29f 100644 --- a/sys/src/kern/port/tod.c +++ b/sys/src/kern/port/tod.c @@ -198,7 +198,7 @@ todfix(void) /* convert to epoch */ mul64fract(&x, diff, tod.multiplier); -if(x > 30000000000ULL) print("todfix %llud\n", x); +if(x > 30000000000ULL) jehanne_print("todfix %llud\n", x); x += tod.off; /* protect against overflows */ diff --git a/sys/src/kern/port/uidgid.c b/sys/src/kern/port/uidgid.c index 7c13520..bbcb42d 100644 --- a/sys/src/kern/port/uidgid.c +++ b/sys/src/kern/port/uidgid.c @@ -37,10 +37,10 @@ checkname(char *s) while((r = *s) != 0){ if(r < Runeself){ s++; - if(r < 0x20 || r >= 0x7F && r < 0xA0 || strchr(invalid, r) != nil) + if(r < 0x20 || r >= 0x7F && r < 0xA0 || jehanne_strchr(invalid, r) != nil) r = Runeerror; }else - s += chartorune(&r, s); + s += jehanne_chartorune(&r, s); if(r == Runeerror) error("invalid character in name"); } @@ -69,7 +69,7 @@ lookuser(char *name) h = hashpjw(name) & Umask; for(l = &users.hash[h]; (u = *l) != nil; l = &u->next) - if(strcmp(u->name, name) == 0) + if(jehanne_strcmp(u->name, name) == 0) break; return l; } @@ -80,8 +80,8 @@ tack(char **p, char *s) char *o; o = *p; - strcpy(o, s); - *p += strlen(o)+1; + jehanne_strcpy(o, s); + *p += jehanne_strlen(o)+1; return o; } @@ -95,27 +95,27 @@ adduser(char *uid, char *leader, int nm, char **mem) if(leader != nil){ if(*leader == '\0') leader = nil; - else if(strcmp(leader, uid) == 0) + else if(jehanne_strcmp(leader, uid) == 0) leader = uid; } checkname(uid); - nc = strlen(uid)+1; + nc = jehanne_strlen(uid)+1; if(leader != nil && leader != uid){ checkname(leader); - nc += strlen(leader)+1; + nc += jehanne_strlen(leader)+1; } for(i = 0; i < nm; i++){ checkname(mem[i]); - nc += strlen(mem[i])+1; + nc += jehanne_strlen(mem[i])+1; } - v = mallocz(sizeof(User)+nm*sizeof(v->mem[0])+nc, 1); + v = jehanne_mallocz(sizeof(User)+nm*sizeof(v->mem[0])+nc, 1); if(v == nil) error(Enomem); o = (char*)(v+1)+nm*sizeof(v->mem[0]); v->name = tack(&o, uid); if(leader == nil) v->leader = nil; - else if(strcmp(v->name, leader) != 0) + else if(jehanne_strcmp(v->name, leader) != 0) v->leader = tack(&o, leader); else v->leader = v->name; @@ -128,7 +128,7 @@ adduser(char *uid, char *leader, int nm, char **mem) if(u != nil){ /* replace */ v->next = u->next; - free(u); + jehanne_free(u); } *l = v; unlock(&users); @@ -148,7 +148,7 @@ deluser(char *name) } *l = u->next; unlock(&users); - free(u); + jehanne_free(u); return 1; } @@ -158,7 +158,7 @@ ismember(char *s, int n, char **mem) int i; for(i = 0; i < n; i++) - if(strcmp(s, mem[i]) == 0) + if(jehanne_strcmp(s, mem[i]) == 0) return 1; return 0; } @@ -168,7 +168,7 @@ ingroup(char *uid, char *gid) { User *g; - if(strcmp(uid, gid) == 0) + if(jehanne_strcmp(uid, gid) == 0) return 1; lock(&users); g = *lookuser(gid); @@ -188,14 +188,14 @@ leadsgroup(char *uid, char *gid) lock(&users); g = *lookuser(gid); if(g != nil){ - if(g->leader != nil && strcmp(uid, g->leader) == 0 || + if(g->leader != nil && jehanne_strcmp(uid, g->leader) == 0 || g->leader == nil && ismember(uid, g->n, g->mem)){ unlock(&users); return 1; } } unlock(&users); - return g == nil && strcmp(uid, gid) == 0; + return g == nil && jehanne_strcmp(uid, gid) == 0; } char* @@ -205,21 +205,21 @@ usersread(void) User *u; Fmt fmt; - fmtstrinit(&fmt); + jehanne_fmtstrinit(&fmt); for(i = 0; i < nelem(users.hash); i++){ lock(&users); for(u = users.hash[i]; u != nil; u = u->next){ - fmtprint(&fmt, "%q", u->name); + jehanne_fmtprint(&fmt, "%q", u->name); if(u->leader != nil || u->n != 0){ - fmtprint(&fmt, " %q", u->leader != nil? u->leader: ""); + jehanne_fmtprint(&fmt, " %q", u->leader != nil? u->leader: ""); for(m = 0; m < u->n; m++) - fmtprint(&fmt, " %q", u->mem[m]); + jehanne_fmtprint(&fmt, " %q", u->mem[m]); } - fmtprint(&fmt, "\n"); + jehanne_fmtprint(&fmt, "\n"); } unlock(&users); } - return fmtstrflush(&fmt); + return jehanne_fmtstrflush(&fmt); } long @@ -232,25 +232,25 @@ userswrite(void *buf, long n) return n; if(n > 16*1024) error(Etoobig); - p = malloc(n+1); + p = jehanne_malloc(n+1); if(p == nil) error(Enomem); if(waserror()){ - free(p); + jehanne_free(p); nexterror(); } - memmove(p, buf, n); + jehanne_memmove(p, buf, n); p[n] = '\0'; if(p[n-1] != '\n') error("incomplete line"); - for(s = p; (e = strchr(s, '\n')) != nil; s = e){ + for(s = p; (e = jehanne_strchr(s, '\n')) != nil; s = e){ *e++ = '\0'; if(*s == '#') continue; - nf = tokenize(s, flds, nelem(flds)); + nf = jehanne_tokenize(s, flds, nelem(flds)); if(nf == nelem(flds)) error("too many group members"); - if(strcmp(flds[0], "-") == 0){ + if(jehanne_strcmp(flds[0], "-") == 0){ for(i = 1; i < nf; i++) deluser(flds[i]); }else if(nf > 1) @@ -259,6 +259,6 @@ userswrite(void *buf, long n) adduser(flds[0], nil, 0, nil); } poperror(); - free(p); + jehanne_free(p); return n; } diff --git a/sys/src/kern/port/umem/images.c b/sys/src/kern/port/umem/images.c index a542ad5..74797d1 100644 --- a/sys/src/kern/port/umem/images.c +++ b/sys/src/kern/port/umem/images.c @@ -92,10 +92,10 @@ static ImagePool pool; void imagepool_init(void) { - pool.chunks = malloc(sizeof(ImgPoolChunk*)); + pool.chunks = jehanne_malloc(sizeof(ImgPoolChunk*)); if(pool.chunks == nil) panic("image_init: out of memory"); - pool.chunks[0] = mallocz(sizeof(ImgPoolChunk), 1); + pool.chunks[0] = jehanne_mallocz(sizeof(ImgPoolChunk), 1); if(pool.chunks[0] == nil) panic("image_init: out of memory"); pool.allocated = PSTEP; @@ -120,16 +120,16 @@ imagepool_grow(void) initially_allocated = pool.allocated; size = pool.allocated/PSTEP; - chunks = malloc(sizeof(ImgPoolChunk*)*(size+1)); + chunks = jehanne_malloc(sizeof(ImgPoolChunk*)*(size+1)); if(chunks == nil) goto Fail; - chunks[size] = mallocz(sizeof(ImgPoolChunk), 1); + chunks[size] = jehanne_mallocz(sizeof(ImgPoolChunk), 1); if(chunks[size] == nil){ goto FreeChunksAndFail; } - chunks = memmove(chunks, pool.chunks, size); + chunks = jehanne_memmove(chunks, pool.chunks, size); - free(pool.chunks); + jehanne_free(pool.chunks); pool.chunks = chunks; pool.allocated += PSTEP; pool.blanks += PSTEP; @@ -156,7 +156,7 @@ imagepool_grow(void) return 1; FreeChunksAndFail: - free(chunks); + jehanne_free(chunks); Fail: /* reset blanks requests: the requesters will fail anyway */ if(pool.blanks < 0) @@ -178,6 +178,16 @@ image_initialize(ElfImage* new, Chan *c) new->hnext = 0; } +static void +dispose_segment_pages(PagePointer* pages, unsigned int npages) +{ + if(pages == nil) + return; + while(npages){ + page_dispose(&pages[--npages]); + } +} + static int segments_fill(ElfSegment* segments, Ldseg *infos) { @@ -189,12 +199,15 @@ segments_fill(ElfSegment* segments, Ldseg *infos) if(text->pgsz != PGSZ || data->pgsz != PGSZ) return 0; + dispose_segment_pages(segments[0].pages, segments[0].npages); + dispose_segment_pages(segments[1].pages, segments[1].npages); + segments[0].npages = HOWMANY(text->pg0off+text->memsz, PGSZ); if(segments[0].npages > (SEGMAPSIZE*PTEPERTAB)) return 0; if(segments[0].pages != nil) - free(segments[0].pages); - segments[0].pages = mallocz(sizeof(PagePointer)*segments[0].npages, 1); + jehanne_free(segments[0].pages); + segments[0].pages = jehanne_mallocz(sizeof(PagePointer)*segments[0].npages, 1); if(segments[0].pages == nil) return 0; segments[0].pg0addr = text->pg0vaddr; @@ -206,10 +219,10 @@ segments_fill(ElfSegment* segments, Ldseg *infos) if(segments[1].npages > (SEGMAPSIZE*PTEPERTAB)) return 0; if(segments[1].pages != nil) - free(segments[1].pages); - segments[1].pages = mallocz(sizeof(PagePointer)*segments[1].npages, 1); + jehanne_free(segments[1].pages); + segments[1].pages = jehanne_mallocz(sizeof(PagePointer)*segments[1].npages, 1); if(segments[1].pages == nil){ - free(segments[0].pages); + jehanne_free(segments[0].pages); segments[0].pages = nil; return 0; } @@ -511,9 +524,9 @@ faultio_error(Chan *c) char buf[ERRMAX]; if(c && c->path && c->path->s) - snprint(buf, sizeof buf, "%s accessing %s: %s", Eioload, c->path->s, up->errstr); + jehanne_snprint(buf, sizeof buf, "%s accessing %s: %s", Eioload, c->path->s, up->errstr); else - snprint(buf, sizeof buf, "sys: %s", Eioload); + jehanne_snprint(buf, sizeof buf, "sys: %s", Eioload); if(up->nerrlab) { postnote(up, 1, buf, NDebug); @@ -592,7 +605,7 @@ image_fill(PagePointer* page, ElfSegPointer segment, uintptr_t va) * - the last page of the segment, if partial (rend & (PGSZ-1)) */ if ((rend & (PGSZ-1)) || (rstart & (PGSZ-1))) - memset(kaddr, 0, PGSZ); + jehanne_memset(kaddr, 0, PGSZ); c = img->c; @@ -607,7 +620,7 @@ image_fill(PagePointer* page, ElfSegPointer segment, uintptr_t va) /* ok, so we really have to read the file */ while(waserror()){ - if(strcmp(up->errstr, Eintr) == 0) + if(jehanne_strcmp(up->errstr, Eintr) == 0) continue; qunlock(&seg->l); page_kunmap(new, &kaddr); diff --git a/sys/src/kern/port/umem/pages.c b/sys/src/kern/port/umem/pages.c index 8ffb3ac..1c077d3 100644 --- a/sys/src/kern/port/umem/pages.c +++ b/sys/src/kern/port/umem/pages.c @@ -77,7 +77,7 @@ umem_init(void) avail = sys->pmpaged; /* could include a portion of unassigned memory */ pool.npages = avail/PGSZ; pool.npages -= (pool.npages*sizeof(UserPage)) / PGSZ; /* little overestimate of the space occupied by the paging structures */ - pool.pages = mallocz(pool.npages*sizeof(UserPage), 1); + pool.pages = jehanne_mallocz(pool.npages*sizeof(UserPage), 1); if(pool.pages == nil) panic("umem_init: out of memory"); pool.freepages = 0; @@ -93,7 +93,7 @@ umem_init(void) rawmem_init(); imagepool_init(); - print("%lldM memory: %lldK+%lldM kernel," + jehanne_print("%lldM memory: %lldK+%lldM kernel," " %lldM user, %lldM uncommitted\n", mkb/KiB, kkb, kmkb/KiB, pkb/KiB, (mkb-kkb-kmkb-pkb)/KiB ); @@ -177,7 +177,7 @@ page_new(PagePointer *slot, int clear) if(clear) { k = kmap2(p); - memset(VA(k), 0, PGSZ); + jehanne_memset(VA(k), 0, PGSZ); kunmap(k); } @@ -312,7 +312,7 @@ page_duplicate(PagePointer *slot) o = kmap2(original); d = kmap2(duplicate); - memmove(VA(d), VA(o), PGSZ); + jehanne_memmove(VA(d), VA(o), PGSZ); kunmap(d); kunmap(o); @@ -402,7 +402,7 @@ table_new(PageTable** table, uintptr_t base, uintptr_t top) if(npages > (SEGMAPSIZE*PTEPERTAB)) return 0; mapsize = HOWMANY(npages, PTEPERTAB); - new = mallocz(sizeof(PageTable) + mapsize*sizeof(PageTableEntry*), 1); + new = jehanne_mallocz(sizeof(PageTable) + mapsize*sizeof(PageTableEntry*), 1); if(new == nil) return 0; new->base = base; @@ -436,7 +436,7 @@ table_lookup(PageTable* table, uintptr_t va) pte->first = PTEPERTAB-1; pte->last = 0; if(!CASV(&table->map[pteindex], nil, pte)){ - free(pte); + jehanne_free(pte); pte = table->map[pteindex]; } } @@ -482,7 +482,7 @@ table_clone(PageTable* target, PageTable* original) opte = original->map[entry]; if(opte == nil) continue; - pte = mallocz(sizeof(PageTableEntry), 1); + pte = jehanne_mallocz(sizeof(PageTableEntry), 1); if(pte == nil) goto FreePageTableEntries; pte->first = opte->first; @@ -499,14 +499,14 @@ table_clone(PageTable* target, PageTable* original) return 1; FreePageTableEntries: - for(--entry; entry > 0; --entry){ + for(--entry; entry >= 0; --entry){ pte = target->map[entry]; if(pte == nil) continue; for(page = pte->first; page <= pte->last; ++page) page_dispose(&pte->pages[page]); - free(pte); - /* no need to zero new->map[entry]: it dies on free(new) */ + jehanne_free(pte); + /* no need to zero new->map[entry]: it dies on jehanne_free(new) */ } return 0; } @@ -521,11 +521,11 @@ table_free_pages(PageTable* table) MLG("target %#p", table); if(table->base == 0) panic("table_free_pages: uninitialized target, pc %#p", getcallerpc()); - for(entry = table->mapsize - 1; entry > 0; --entry){ + for(entry = table->mapsize - 1; entry >= 0; --entry){ pte = table->map[entry]; if(pte == nil) continue; - for(page = pte->last; page > pte->first; --page){ + for(page = pte->last; page >= pte->first; --page){ if(pte->pages[page] == 0) continue; if(!page_dispose(&pte->pages[page])) @@ -545,7 +545,7 @@ table_walk_pages(PageTable* table, void (*func)(uintptr_t, UserPage*)) pte = table->map[entry]; if(pte == nil) continue; - for(page = pte->first; page < pte->last; ++page){ + for(page = pte->first; page <= pte->last; ++page){ if(pte->pages[page] == 0) continue; func( @@ -571,19 +571,19 @@ table_free(PageTable** target) panic("table_free: empty target, pc %#p", getcallerpc()); if(table->base == 0) panic("table_free: uninitialized target, pc %#p", getcallerpc()); - for(entry = table->mapsize - 1; entry > 0; --entry){ + for(entry = table->mapsize - 1; entry >= 0; --entry){ pte = table->map[entry]; if(pte == nil) continue; - for(page = pte->last; page > pte->first; --page){ + for(page = pte->last; page >= pte->first; --page){ if(pte->pages[page] == 0) continue; if(!page_dispose(&pte->pages[page])) panic("table_free: concurrent disposition of a page, pc %#p", getcallerpc()); } - free(pte); /* this is why we don't simply call table_free_pages */ + jehanne_free(pte); /* this is why we don't simply call table_free_pages */ } - free(table); + jehanne_free(table); } int @@ -614,22 +614,22 @@ table_resize(PageTable** target, uintptr_t top) return 0; copy = MIN(new->mapsize, old->mapsize); - memmove(new->map, old->map, copy*sizeof(PageTableEntry*)); + jehanne_memmove(new->map, old->map, copy*sizeof(PageTableEntry*)); if(!CASV(target, old, new)) panic("table_resize: concurrent resize, pc %#p", getcallerpc()); while(copy < old->mapsize){ pte = old->map[copy++]; if(pte == nil) continue; - for(page = pte->last; page > pte->first; --page){ + for(page = pte->last; page >= pte->first; --page){ if(pte->pages[page] == 0) continue; if(!page_dispose(&pte->pages[page])) panic("table_resize: concurrent disposition of a page, pc %#p", getcallerpc()); } - free(pte); - /* no need to zero old->map[copy-1]: it dies on free(old) */ + jehanne_free(pte); + /* no need to zero old->map[copy-1]: it dies on jehanne_free(old) */ } - free(old); + jehanne_free(old); return 1; } diff --git a/sys/src/kern/port/umem/raw.c b/sys/src/kern/port/umem/raw.c index 4a95a98..f99061a 100644 --- a/sys/src/kern/port/umem/raw.c +++ b/sys/src/kern/port/umem/raw.c @@ -52,7 +52,7 @@ void rawmem_init(void) { areas_allocated = 8; - memory_areas = malloc(areas_allocated*sizeof(RawMemory)); + memory_areas = jehanne_malloc(areas_allocated*sizeof(RawMemory)); if(memory_areas == nil) panic("rawmem_init: out of memory"); rawmem_register("shared", 0, SgShared, -1); @@ -110,7 +110,7 @@ LookupArea: } if(areas_used == areas_allocated){ areas_allocated += 8; - tmp = realloc(memory_areas, areas_allocated*sizeof(RawMemory)); + tmp = jehanne_realloc(memory_areas, areas_allocated*sizeof(RawMemory)); if(tmp == nil) goto RegisterFailed; memory_areas = tmp; @@ -119,11 +119,11 @@ LookupArea: if(pa == 0){ tmp = memory_areas+areas_used-virtual_areas; while(tmp < memory_areas+areas_used){ - if(strcmp(tmp->name, name) > 0) + if(jehanne_strcmp(tmp->name, name) > 0) break; ++tmp; } - memmove(tmp+1, tmp, sizeof(RawMemory)*(memory_areas+areas_used-tmp)); + jehanne_memmove(tmp+1, tmp, sizeof(RawMemory)*(memory_areas+areas_used-tmp)); ++virtual_areas; } else { tmp = memory_areas; @@ -137,7 +137,7 @@ LookupArea: panic("rawmem_register: '%s' overlaps with '%s', pc %#p", name, tmp->name, getcallerpc()); ++tmp; } - memmove(tmp+1, tmp, sizeof(RawMemory)*(memory_areas+areas_used-tmp)); + jehanne_memmove(tmp+1, tmp, sizeof(RawMemory)*(memory_areas+areas_used-tmp)); } tmp->name = name; /* TODO: ensure this is a readonly constant */ @@ -179,7 +179,7 @@ rawmem_find(char** name, uintptr_t *pa, unsigned int *attr, uintptr_t *size) while(result == nil && b < t) { i = b + ((t - b)/2); - if((c = strcmp(memory_areas[i].name, *name)) == 0) + if((c = jehanne_strcmp(memory_areas[i].name, *name)) == 0) result = &memory_areas[i]; else if(c < 0) b = i + 1; @@ -188,7 +188,7 @@ rawmem_find(char** name, uintptr_t *pa, unsigned int *attr, uintptr_t *size) } t = areas_used - virtual_areas; for(i = 0; result == nil && i < t; ++i) - if(strcmp(*name, memory_areas[i].name) == 0) + if(jehanne_strcmp(*name, memory_areas[i].name) == 0) result = &memory_areas[i]; if(result != nil){ *name = memory_areas[i].name; diff --git a/sys/src/kern/port/umem/segments.c b/sys/src/kern/port/umem/segments.c index da8dc13..7bcb343 100644 --- a/sys/src/kern/port/umem/segments.c +++ b/sys/src/kern/port/umem/segments.c @@ -74,7 +74,7 @@ static ProcSegment* segment_alloc(SegmentType type, SegPermission permissions, SegFlag flags, uintptr_t base, uintptr_t top) { ProcSegment* s; - s = mallocz(sizeof(ProcSegment), 1); + s = jehanne_mallocz(sizeof(ProcSegment), 1); if(s == nil) return nil; s->r.ref = 1; @@ -85,7 +85,7 @@ segment_alloc(SegmentType type, SegPermission permissions, SegFlag flags, uintpt s->top = top; if(type != SgPhysical /* Physical segments do not need pages */ && !table_new(&s->table, base, top)){ - free(s); + jehanne_free(s); return nil; } @@ -146,7 +146,7 @@ segment_userinit(ProcSegment** slot, int data) if(!page_new(page, i == (shared-1))) panic("segment_userinit: out of memory, pc %#p", getcallerpc()); tmp = page_kmap(*page); - memmove(tmp, content+i*PGSZ, MIN(PGSZ, top-base-i*PGSZ)); + jehanne_memmove(tmp, content+i*PGSZ, MIN(PGSZ, top-base-i*PGSZ)); page_kunmap(*page, &tmp); } new->image = data; @@ -453,7 +453,7 @@ segment_release(ProcSegment** s) case SgPhysical: break; } - free(segment); + jehanne_free(segment); } /* replaces the segment in s with a copy with debug enabled/disabled @@ -701,7 +701,7 @@ static void check_single_page(uintptr_t va, UserPage* page) { if(!iskaddr(page)) - print("%d %s: invalid page off %#p pg %#p\n", up->pid, up->text, va, page); + jehanne_print("%d %s: invalid page off %#p pg %#p\n", up->pid, up->text, va, page); else checkmmu(va, page->pa); } diff --git a/sys/src/kern/port/umem/test.c b/sys/src/kern/port/umem/test.c index caf446f..537b0b3 100644 --- a/sys/src/kern/port/umem/test.c +++ b/sys/src/kern/port/umem/test.c @@ -90,7 +90,7 @@ umem_test_raw_memory(void) if(!rawmem_lookup(0xfc000000, &name, &pa, &attr, &size, &page)) panic("rawmem_lookup: failed 1"); - if(strcmp(name, "vesascreen") != 0) + if(jehanne_strcmp(name, "vesascreen") != 0) panic("rawmem_lookup: failed 2"); if(pa != 0xfc000000) panic("rawmem_lookup: failed 3"); @@ -109,23 +109,23 @@ umem_test_raw_memory(void) void print_type_sizes(void) { - print("sizeof UserPage %d bytes\n", sizeof(UserPage)); - print("sizeof PageTableEntry %d bytes\n", sizeof(PageTableEntry)); - print("sizeof PageTable %d bytes\n", sizeof(PageTable)); - print("sizeof ElfSegment %d bytes\n", sizeof(ElfSegment)); - print("sizeof ElfImage %d bytes\n", sizeof(ElfImage)); - print("sizeof ProcSegment %d bytes\n", sizeof(ProcSegment)); - print("sizeof RawMemory %d bytes\n", sizeof(RawMemory)); + jehanne_print("sizeof UserPage %d bytes\n", sizeof(UserPage)); + jehanne_print("sizeof PageTableEntry %d bytes\n", sizeof(PageTableEntry)); + jehanne_print("sizeof PageTable %d bytes\n", sizeof(PageTable)); + jehanne_print("sizeof ElfSegment %d bytes\n", sizeof(ElfSegment)); + jehanne_print("sizeof ElfImage %d bytes\n", sizeof(ElfImage)); + jehanne_print("sizeof ProcSegment %d bytes\n", sizeof(ProcSegment)); + jehanne_print("sizeof RawMemory %d bytes\n", sizeof(RawMemory)); print("---\n"); - print("sizeof Page %d bytes\n", sizeof(Page)); - print("sizeof Pte %d bytes\n", sizeof(Pte)); - print("sizeof Pages %d bytes\n", sizeof(Pages)); - print("sizeof Section %d bytes\n", sizeof(Section)); - print("sizeof Image %d bytes\n", sizeof(Image)); - print("sizeof Segment %d bytes\n", sizeof(Segment)); - print("sizeof Physseg %d bytes\n", sizeof(Physseg)); + jehanne_print("sizeof Page %d bytes\n", sizeof(Page)); + jehanne_print("sizeof Pte %d bytes\n", sizeof(Pte)); + jehanne_print("sizeof Pages %d bytes\n", sizeof(Pages)); + jehanne_print("sizeof Section %d bytes\n", sizeof(Section)); + jehanne_print("sizeof Image %d bytes\n", sizeof(Image)); + jehanne_print("sizeof Segment %d bytes\n", sizeof(Segment)); + jehanne_print("sizeof Physseg %d bytes\n", sizeof(Physseg)); print("---\n"); - print("sizeof Proc %d bytes\n", sizeof(Proc)); + jehanne_print("sizeof Proc %d bytes\n", sizeof(Proc)); } diff --git a/sys/src/kern/port/usb.h b/sys/src/kern/port/usb.h index 2800fe0..a0802ef 100644 --- a/sys/src/kern/port/usb.h +++ b/sys/src/kern/port/usb.h @@ -1,10 +1,10 @@ /* * common USB definitions. */ -#define dprint(...) do if(debug)print(__VA_ARGS__); while(0) -#define ddprint(...) do if(debug>1)print(__VA_ARGS__); while(0) -#define deprint(...) do if(debug || ep->debug)print(__VA_ARGS__); while(0) -#define ddeprint(...) do if(debug>1 || ep->debug>1)print(__VA_ARGS__); while(0) +#define dprint(...) do if(debug)jehanne_print(__VA_ARGS__); while(0) +#define ddprint(...) do if(debug>1)jehanne_print(__VA_ARGS__); while(0) +#define deprint(...) do if(debug || ep->debug)jehanne_print(__VA_ARGS__); while(0) +#define ddeprint(...) do if(debug>1 || ep->debug>1)jehanne_print(__VA_ARGS__); while(0) #define GET2(p) ((((p)[1]&0xFF)<<8)|((p)[0]&0xFF)) #define PUT2(p,v) {((p)[0] = (v)); ((p)[1] = (v)>>8);} diff --git a/sys/src/kern/port/usbehci.c b/sys/src/kern/port/usbehci.c index b5f217a..5463194 100644 --- a/sys/src/kern/port/usbehci.c +++ b/sys/src/kern/port/usbehci.c @@ -23,10 +23,10 @@ #include "usbehci.h" #include "uncached.h" -#define diprint if(ehcidebug || iso->debug)print -#define ddiprint if(ehcidebug>1 || iso->debug>1)print -#define dqprint if(ehcidebug || (qh->io && qh->io->debug))print -#define ddqprint if(ehcidebug>1 || (qh->io && qh->io->debug>1))print +#define diprint if(ehcidebug || iso->debug)jehanne_print +#define ddiprint if(ehcidebug>1 || iso->debug>1)jehanne_print +#define dqprint if(ehcidebug || (qh->io && qh->io->debug))jehanne_print +#define ddqprint if(ehcidebug>1 || (qh->io && qh->io->debug>1))jehanne_print #define TRUNC(x, sz) ((x) & ((sz)-1)) #define LPTR(q) ((uint32_t*)KADDR((q) & ~0x1F)) @@ -393,7 +393,7 @@ ehcirun(Ctlr *ctlr, int on) else delay(1); if(i == 100) - print("ehci %#p %s cmd timed out\n", + jehanne_print("ehci %#p %s cmd timed out\n", ctlr->capio, on ? "run" : "halt"); ddprint("ehci %#p cmd %#ux sts %#ux\n", ctlr->capio, opio->cmd, opio->sts); @@ -407,7 +407,7 @@ edalloc(void) lock(&edpool.l); if(edpool.free == nil){ - pool = mallocalign(Incr*sizeof(Ed), Align, 0, 0); + pool = jehanne_mallocalign(Incr*sizeof(Ed), Align, 0, 0); if(pool == nil) panic("edalloc"); for(i=Incr; --i>=0;){ @@ -424,7 +424,7 @@ edalloc(void) edpool.nfree--; unlock(&edpool.l); - memset(ed, 0, sizeof(Ed)); /* safety */ + jehanne_memset(ed, 0, sizeof(Ed)); /* safety */ assert(((uintptr_t)ed & 0xF) == 0); return ed; } @@ -495,7 +495,7 @@ tdfree(Td *td) { if(td == nil) return; - free(td->buff); + jehanne_free(td->buff); edfree(td); } @@ -587,7 +587,7 @@ schedq(Ctlr *ctlr, Qh *qh, int pollival) ddqprint("ehci: sched %#p q %d, ival %d, bw %uld\n", qh->io, q, pollival, bw); if(q < 0){ - print("ehci: no room for ed\n"); + jehanne_print("ehci: no room for ed\n"); return -1; } ctlr->tree->bw[q] += bw; @@ -623,7 +623,7 @@ unschedq(Ctlr *ctlr, Qh *qh) this = this->next; } if(this == nil) - print("ehci: unschedq %d: not found\n", q); + jehanne_print("ehci: unschedq %d: not found\n", q); else{ next = this->next; qhlinkqh(prev, next); @@ -633,7 +633,7 @@ unschedq(Ctlr *ctlr, Qh *qh) *l = (*l)->inext; return; } - print("ehci: unschedq: qh %#p not found\n", qh); + jehanne_print("ehci: unschedq: qh %#p not found\n", qh); } static uint32_t @@ -713,7 +713,7 @@ qhalloc(Ctlr *ctlr, Ep *ep, Qio *io, char* tag) schedq(ctlr, qh, ep->pollival); break; default: - print("ehci: qhalloc called for ttype != ctl/bulk\n"); + jehanne_print("ehci: qhalloc called for ttype != ctl/bulk\n"); } iunlock(&ctlr->l); return qh; @@ -748,7 +748,7 @@ qhcoherency(Ctlr *ctlr) } dprint("ehci: qhcoherency: doorbell %d\n", qhadvanced(ctlr)); if(i == 3) - print("ehci: async advance doorbell did not ring\n"); + jehanne_print("ehci: async advance doorbell did not ring\n"); ctlr->opio->cmd &= ~Ciasync; /* try to clean */ qunlock(&ctlr->portlck); } @@ -814,20 +814,20 @@ qhlinktd(Qh *qh, Td *td) static char* seprintlink(char *s, char *se, char *name, uint32_t l, int typed) { - s = seprint(s, se, "%s %ux", name, l); + s = jehanne_seprint(s, se, "%s %ux", name, l); if((l & Lterm) != 0) - return seprint(s, se, "T"); + return jehanne_seprint(s, se, "T"); if(typed == 0) return s; switch(l & (3<<1)){ case Litd: - return seprint(s, se, "I"); + return jehanne_seprint(s, se, "I"); case Lqh: - return seprint(s, se, "Q"); + return jehanne_seprint(s, se, "Q"); case Lsitd: - return seprint(s, se, "S"); + return jehanne_seprint(s, se, "S"); default: - return seprint(s, se, "F"); + return jehanne_seprint(s, se, "F"); } } @@ -840,19 +840,19 @@ seprintitd(char *s, char *se, Itd *td) char *rw; if(td == nil) - return seprint(s, se, "\n"); + return jehanne_seprint(s, se, "\n"); b0 = td->buffer[0]; b1 = td->buffer[1]; - s = seprint(s, se, "itd %#p", td); + s = jehanne_seprint(s, se, "itd %#p", td); rw = (b1 & Itdin) ? "in" : "out"; - s = seprint(s, se, " %s ep %ud dev %ud max %ud mult %ud", + s = jehanne_seprint(s, se, " %s ep %ud dev %ud max %ud mult %ud", rw, (b0>>8)&Epmax, (b0&Devmax), td->buffer[1] & 0x7ff, b1 & 3); s = seprintlink(s, se, " link", td->link, 1); - s = seprint(s, se, "\n"); + s = jehanne_seprint(s, se, "\n"); for(i = 0; i < nelem(td->csw); i++){ - memset(flags, '-', 5); + jehanne_memset(flags, '-', 5); if((td->csw[i] & Itdactive) != 0) flags[0] = 'a'; if((td->csw[i] & Itdioc) != 0) @@ -864,15 +864,15 @@ seprintitd(char *s, char *se, Itd *td) if((td->csw[i] & Itdtrerr) != 0) flags[4] = 't'; flags[5] = 0; - s = seprint(s, se, "\ttd%d %s", i, flags); - s = seprint(s, se, " len %ud", (td->csw[i] >> 16) & 0x7ff); - s = seprint(s, se, " pg %ud", (td->csw[i] >> 12) & 0x7); - s = seprint(s, se, " off %ud\n", td->csw[i] & 0xfff); + s = jehanne_seprint(s, se, "\ttd%d %s", i, flags); + s = jehanne_seprint(s, se, " len %ud", (td->csw[i] >> 16) & 0x7ff); + s = jehanne_seprint(s, se, " pg %ud", (td->csw[i] >> 12) & 0x7); + s = jehanne_seprint(s, se, " off %ud\n", td->csw[i] & 0xfff); } - s = seprint(s, se, "\tbuffs:"); + s = jehanne_seprint(s, se, "\tbuffs:"); for(i = 0; i < nelem(td->buffer); i++) - s = seprint(s, se, " %#ux", td->buffer[i] >> 12); - return seprint(s, se, "\n"); + s = jehanne_seprint(s, se, " %#ux", td->buffer[i] >> 12); + return jehanne_seprint(s, se, "\n"); } static char* @@ -883,15 +883,15 @@ seprintsitd(char *s, char *se, Sitd *td) static char pc[4] = { 'a', 'b', 'm', 'e' }; if(td == nil) - return seprint(s, se, "\n"); - s = seprint(s, se, "sitd %#p", td); + return jehanne_seprint(s, se, "\n"); + s = jehanne_seprint(s, se, "sitd %#p", td); rw = (td->epc & Stdin) ? 'r' : 'w'; - s = seprint(s, se, " %c ep %ud dev %ud", + s = jehanne_seprint(s, se, " %c ep %ud dev %ud", rw, (td->epc>>8)&0xf, td->epc&0x7f); - s = seprint(s, se, " max %ud", (td->csw >> 16) & 0x3ff); - s = seprint(s, se, " hub %ud", (td->epc >> 16) & 0x7f); - s = seprint(s, se, " port %ud\n", (td->epc >> 24) & 0x7f); - memset(flags, '-', 7); + s = jehanne_seprint(s, se, " max %ud", (td->csw >> 16) & 0x3ff); + s = jehanne_seprint(s, se, " hub %ud", (td->epc >> 16) & 0x7f); + s = jehanne_seprint(s, se, " port %ud\n", (td->epc >> 24) & 0x7f); + jehanne_memset(flags, '-', 7); if((td->csw & Stdactive) != 0) flags[0] = 'a'; if((td->csw & Stdioc) != 0) @@ -909,16 +909,16 @@ seprintsitd(char *s, char *se, Sitd *td) flags[7] = 0; ss = (td->csw & Stddcs) ? 'c' : 's'; pg = (td->csw & Stdpg) ? '1' : '0'; - s = seprint(s, se, "\t%s %cs pg%c", flags, ss, pg); - s = seprint(s, se, " b0 %#ux b1 %#ux off %ud\n", + s = jehanne_seprint(s, se, "\t%s %cs pg%c", flags, ss, pg); + s = jehanne_seprint(s, se, " b0 %#ux b1 %#ux off %ud\n", td->buffer[0] >> 12, td->buffer[1] >> 12, td->buffer[0] & 0xfff); - s = seprint(s, se, "\ttpos %c tcnt %ud", + s = jehanne_seprint(s, se, "\ttpos %c tcnt %ud", pc[(td->buffer[0]>>3)&3], td->buffer[1] & 7); - s = seprint(s, se, " ssm %#ux csm %#ux cspm %#ux", + s = jehanne_seprint(s, se, " ssm %#ux csm %#ux cspm %#ux", td->mfs & 0xff, (td->mfs>>8) & 0xff, (td->csw>>8) & 0xff); s = seprintlink(s, se, " link", td->link, 1); s = seprintlink(s, se, " blink", td->blink, 0); - return seprint(s, se, "\n"); + return jehanne_seprint(s, se, "\n"); } static int32_t @@ -944,14 +944,14 @@ seprinttd(char *s, char *se, Td *td, char *tag) static char *tok[4] = { "out", "in", "setup", "BUG" }; if(td == nil) - return seprint(s, se, "%s \n", tag); - s = seprint(s, se, "%s %#p", tag, td); + return jehanne_seprint(s, se, "%s \n", tag); + s = jehanne_seprint(s, se, "%s %#p", tag, td); s = seprintlink(s, se, " nlink", td->nlink, 0); s = seprintlink(s, se, " alink", td->alink, 0); - s = seprint(s, se, " %s", tok[(td->csw & Tdtok) >> 8]); + s = jehanne_seprint(s, se, " %s", tok[(td->csw & Tdtok) >> 8]); if((td->csw & Tdping) != 0) - s = seprint(s, se, " png"); - memset(flags, '-', 8); + s = jehanne_seprint(s, se, " png"); + jehanne_memset(flags, '-', 8); if((td->csw & Tdactive) != 0) flags[0] = 'a'; if((td->csw & Tdioc) != 0) @@ -971,16 +971,16 @@ seprinttd(char *s, char *se, Td *td, char *tag) flags[8] = 0; t = (td->csw & Tddata1) ? '1' : '0'; ss = (td->csw & Tddcs) ? 'c' : 's'; - s = seprint(s, se, "\n\td%c %s %cs", t, flags, ss); - s = seprint(s, se, " max %uld", maxtdlen(td)); - s = seprint(s, se, " pg %ud off %#ux\n", + s = jehanne_seprint(s, se, "\n\td%c %s %cs", t, flags, ss); + s = jehanne_seprint(s, se, " max %uld", maxtdlen(td)); + s = jehanne_seprint(s, se, " pg %ud off %#ux\n", (td->csw >> Tdpgshift) & Tdpgmask, td->buffer[0] & 0xFFF); - s = seprint(s, se, "\tbuffs:"); + s = jehanne_seprint(s, se, "\tbuffs:"); for(i = 0; i < nelem(td->buffer); i++) - s = seprint(s, se, " %#ux", td->buffer[i]>>12); + s = jehanne_seprint(s, se, " %#ux", td->buffer[i]>>12); if(td->data != nil) s = seprintdata(s, se, td->data, td->ndata); - return seprint(s, se, "\n"); + return jehanne_seprint(s, se, "\n"); } static void @@ -994,9 +994,9 @@ dumptd(Td *td, char *pref) se = buf+sizeof(buf); for(; td != nil; td = td->next){ seprinttd(buf, se, td, pref); - print("%s", buf); + jehanne_print("%s", buf); if(i++ > 20){ - print("...more tds...\n"); + jehanne_print("...more tds...\n"); break; } } @@ -1011,7 +1011,7 @@ qhdump(Qh *qh) static char *speed[] = {"full", "low", "high", "BUG"}; if(qh == nil){ - print("\n"); + jehanne_print("\n"); return; } if(qh->io == nil) @@ -1019,34 +1019,34 @@ qhdump(Qh *qh) else tag = qh->io->tag; se = buf+sizeof(buf); - s = seprint(buf, se, "%s %#p", tag, qh); - s = seprint(s, se, " ep %ud dev %ud", + s = jehanne_seprint(buf, se, "%s %#p", tag, qh); + s = jehanne_seprint(s, se, " ep %ud dev %ud", (qh->eps0>>8)&0xf, qh->eps0&0x7f); - s = seprint(s, se, " hub %ud", (qh->eps1 >> 16) & 0x7f); - s = seprint(s, se, " port %ud", (qh->eps1 >> 23) & 0x7f); + s = jehanne_seprint(s, se, " hub %ud", (qh->eps1 >> 16) & 0x7f); + s = jehanne_seprint(s, se, " port %ud", (qh->eps1 >> 23) & 0x7f); s = seprintlink(s, se, " link", qh->link, 1); - seprint(s, se, " clink %#ux", qh->tclink); - print("%s\n", buf); - s = seprint(buf, se, "\tnrld %ud", (qh->eps0 >> Qhrlcshift) & Qhrlcmask); - s = seprint(s, se, " nak %ud", (qh->alink >> 1) & 0xf); - s = seprint(s, se, " max %ud ", qhmaxpkt(qh)); + jehanne_seprint(s, se, " clink %#ux", qh->tclink); + jehanne_print("%s\n", buf); + s = jehanne_seprint(buf, se, "\tnrld %ud", (qh->eps0 >> Qhrlcshift) & Qhrlcmask); + s = jehanne_seprint(s, se, " nak %ud", (qh->alink >> 1) & 0xf); + s = jehanne_seprint(s, se, " max %ud ", qhmaxpkt(qh)); if((qh->eps0 & Qhnhctl) != 0) - s = seprint(s, se, "c"); + s = jehanne_seprint(s, se, "c"); if((qh->eps0 & Qhhrl) != 0) - s = seprint(s, se, "h"); + s = jehanne_seprint(s, se, "h"); if((qh->eps0 & Qhdtc) != 0) - s = seprint(s, se, "d"); + s = jehanne_seprint(s, se, "d"); if((qh->eps0 & Qhint) != 0) - s = seprint(s, se, "i"); - s = seprint(s, se, " %s", speed[(qh->eps0 >> 12) & 3]); - s = seprint(s, se, " mult %ud", (qh->eps1 >> Qhmultshift) & Qhmultmask); - seprint(s, se, " scm %#ux ism %#ux\n", + s = jehanne_seprint(s, se, "i"); + s = jehanne_seprint(s, se, " %s", speed[(qh->eps0 >> 12) & 3]); + s = jehanne_seprint(s, se, " mult %ud", (qh->eps1 >> Qhmultshift) & Qhmultmask); + jehanne_seprint(s, se, " scm %#ux ism %#ux\n", (qh->eps1 >> 8 & 0xff), qh->eps1 & 0xff); - print("%s\n", buf); - memset(&td, 0, sizeof(td)); - memmove(&td, &qh->nlink, 32); /* overlay area */ + jehanne_print("%s\n", buf); + jehanne_memset(&td, 0, sizeof(td)); + jehanne_memmove(&td, &qh->nlink, 32); /* overlay area */ seprinttd(buf, se, &td, "\tovl"); - print("%s", buf); + jehanne_print("%s", buf); } static void @@ -1058,34 +1058,34 @@ isodump(Isoio* iso, int all) int i; if(iso == nil){ - print("\n"); + jehanne_print("\n"); return; } - print("iso %#p %s %s speed state %d nframes %d maxsz %uld", + jehanne_print("iso %#p %s %s speed state %d nframes %d maxsz %uld", iso, iso->tok == Tdtokin ? "in" : "out", iso->hs ? "high" : "full", iso->state, iso->nframes, iso->maxsize); - print(" td0 %uld tdi %#p tdu %#p data %#p\n", + jehanne_print(" td0 %uld tdi %#p tdu %#p data %#p\n", iso->td0frno, iso->tdi, iso->tdu, iso->data); if(iso->err != nil) - print("\terr %s\n", iso->err); + jehanne_print("\terr %s\n", iso->err); if(iso->err != nil) - print("\terr='%s'\n", iso->err); + jehanne_print("\terr='%s'\n", iso->err); if(all == 0) if(iso->hs != 0){ tdi = iso->tdi; seprintitd(buf, buf+sizeof(buf), tdi); - print("\ttdi %s\n", buf); + jehanne_print("\ttdi %s\n", buf); tdu = iso->tdu; seprintitd(buf, buf+sizeof(buf), tdu); - print("\ttdu %s\n", buf); + jehanne_print("\ttdu %s\n", buf); }else{ stdi = iso->stdi; seprintsitd(buf, buf+sizeof(buf), stdi); - print("\tstdi %s\n", buf); + jehanne_print("\tstdi %s\n", buf); stdu = iso->stdu; seprintsitd(buf, buf+sizeof(buf), stdu); - print("\tstdu %s\n", buf); + jehanne_print("\tstdu %s\n", buf); } else for(i = 0; i < Nisoframes; i++) @@ -1094,18 +1094,18 @@ isodump(Isoio* iso, int all) td = iso->itdps[i]; seprintitd(buf, buf+sizeof(buf), td); if(td == iso->tdi) - print("i->"); + jehanne_print("i->"); if(td == iso->tdu) - print("i->"); - print("[%d]\t%s", i, buf); + jehanne_print("i->"); + jehanne_print("[%d]\t%s", i, buf); }else{ std = iso->sitdps[i]; seprintsitd(buf, buf+sizeof(buf), std); if(std == iso->stdi) - print("i->"); + jehanne_print("i->"); if(std == iso->stdu) - print("u->"); - print("[%d]\t%s", i, buf); + jehanne_print("u->"); + jehanne_print("[%d]\t%s", i, buf); } } @@ -1123,22 +1123,22 @@ dump(Hci *hp) ctlr = hp->aux; opio = ctlr->opio; ilock(&ctlr->l); - print("ehci port %#p frames %#p (%d fr.) nintr %d ntdintr %d", + jehanne_print("ehci port %#p frames %#p (%d fr.) nintr %d ntdintr %d", ctlr->capio, ctlr->frames, ctlr->nframes, ctlr->nintr, ctlr->ntdintr); - print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr); - print("\tcmd %#ux sts %#ux intr %#ux frno %ud", + jehanne_print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr); + jehanne_print("\tcmd %#ux sts %#ux intr %#ux frno %ud", opio->cmd, opio->sts, opio->intr, opio->frno); - print(" base %#ux link %#ux fr0 %#lux\n", + jehanne_print(" base %#ux link %#ux fr0 %#lux\n", opio->frbase, opio->link, ctlr->frames[0]); se = buf+sizeof(buf); - s = seprint(buf, se, "\t"); + s = jehanne_seprint(buf, se, "\t"); for(i = 0; i < hp->nports; i++){ - s = seprint(s, se, "p%d %#ux ", i, opio->portsc[i]); + s = jehanne_seprint(s, se, "p%d %#ux ", i, opio->portsc[i]); if(hp->nports > 4 && i == hp->nports/2 - 1) - s = seprint(s, se, "\n\t"); + s = jehanne_seprint(s, se, "\n\t"); } - print("%s\n", buf); + jehanne_print("%s\n", buf); qh = ctlr->qhs; i = 0; do{ @@ -1146,19 +1146,19 @@ dump(Hci *hp) qh = qh->next; }while(qh != ctlr->qhs && i++ < 100); if(i > 100) - print("...too many Qhs...\n"); + jehanne_print("...too many Qhs...\n"); if(ctlr->intrqhs != nil) - print("intr qhs:\n"); + jehanne_print("intr qhs:\n"); for(qh = ctlr->intrqhs; qh != nil; qh = qh->inext) qhdump(qh); if(ctlr->iso != nil) - print("iso:\n"); + jehanne_print("iso:\n"); for(iso = ctlr->iso; iso != nil; iso = iso->next) isodump(ctlr->iso, 0); - print("%d eds in tree\n", ctlr->ntree); + jehanne_print("%d eds in tree\n", ctlr->ntree); iunlock(&ctlr->l); lock(&edpool.l); - print("%d eds allocated = %d in use + %d free\n", + jehanne_print("%d eds allocated = %d in use + %d free\n", edpool.nalloc, edpool.ninuse, edpool.nfree); unlock(&edpool.l); } @@ -1380,7 +1380,7 @@ isohsinterrupt(Ctlr *ctlr, Isoio *iso) }else tdi->ndata = 0; if(tdi->next == iso->tdu || tdi->next->next == iso->tdu){ - memset(iso->tdu->data, 0, iso->tdu->mdata); + jehanne_memset(iso->tdu->data, 0, iso->tdu->mdata); itdinit(iso, iso->tdu); iso->tdu = iso->tdu->next; iso->nleft = 0; @@ -1445,7 +1445,7 @@ isofsinterrupt(Ctlr *ctlr, Isoio *iso) stdi->ndata = 0; if(stdi->next == iso->stdu || stdi->next->next == iso->stdu){ - memset(iso->stdu->data, 0, iso->stdu->mdata); + jehanne_memset(iso->stdu->data, 0, iso->stdu->mdata); coherence(); sitdinit(iso, iso->stdu); iso->stdu = iso->stdu->next; @@ -1774,9 +1774,9 @@ portstatus(Hci *hp, int port) static char* seprintio(char *s, char *e, Qio *io, char *pref) { - s = seprint(s,e,"%s io %#p qh %#p id %#x", pref, io, io->qh, io->usbid); - s = seprint(s,e," iot %ld", io->iotime); - s = seprint(s,e," tog %#x tok %#x err %s", io->toggle, io->tok, io->err); + s = jehanne_seprint(s,e,"%s io %#p qh %#p id %#x", pref, io, io->qh, io->usbid); + s = jehanne_seprint(s,e," iot %ld", io->iotime); + s = jehanne_seprint(s,e," tog %#x tok %#x err %s", io->toggle, io->tok, io->err); return s; } @@ -1798,7 +1798,7 @@ seprintep(char *s, char *e, Ep *ep) case Tctl: cio = ep->aux; s = seprintio(s, e, cio, "c"); - s = seprint(s, e, "\trepl %d ndata %d\n", ep->rhrepl, cio->ndata); + s = jehanne_seprint(s, e, "\trepl %d ndata %d\n", ep->rhrepl, cio->ndata); break; case Tbulk: case Tintr: @@ -1854,13 +1854,13 @@ xdump(char* pref, void *qh) uint32_t *u; u = qh; - print("%s %#p:", pref, u); + jehanne_print("%s %#p:", pref, u); for(i = 0; i < 16; i++) if((i%4) == 0) - print("\n %#.8ux", u[i]); + jehanne_print("\n %#.8ux", u[i]); else - print(" %#.8ux", u[i]); - print("\n"); + jehanne_print(" %#.8ux", u[i]); + jehanne_print("\n"); } #endif @@ -1879,16 +1879,16 @@ episohscpy(Ctlr *ctlr, Ep *ep, Isoio* iso, uint8_t *b, int32_t count) if(tot + nr > count) nr = count - tot; if(nr == 0) - print("ehci: ep%d.%d: too many polls\n", + jehanne_print("ehci: ep%d.%d: too many polls\n", ep->dev->nb, ep->nb); else{ iunlock(&ctlr->l); /* We could page fault here */ - memmove(b+tot, tdu->data, nr); + jehanne_memmove(b+tot, tdu->data, nr); ilock(&ctlr->l); if(iso->tdu != tdu) continue; if(nr < tdu->ndata) - memmove(tdu->data, tdu->data+nr, tdu->ndata - nr); + jehanne_memmove(tdu->data, tdu->data+nr, tdu->ndata - nr); tdu->ndata -= nr; coherence(); } @@ -1917,16 +1917,16 @@ episofscpy(Ctlr *ctlr, Ep *ep, Isoio* iso, uint8_t *b, int32_t count) if(tot + nr > count) nr = count - tot; if(nr == 0) - print("ehci: ep%d.%d: too many polls\n", + jehanne_print("ehci: ep%d.%d: too many polls\n", ep->dev->nb, ep->nb); else{ iunlock(&ctlr->l); /* We could page fault here */ - memmove(b+tot, stdu->data, nr); + jehanne_memmove(b+tot, stdu->data, nr); ilock(&ctlr->l); if(iso->stdu != stdu) continue; if(nr < stdu->ndata) - memmove(stdu->data, stdu->data+nr, + jehanne_memmove(stdu->data, stdu->data+nr, stdu->ndata - nr); stdu->ndata -= nr; coherence(); @@ -2018,7 +2018,7 @@ putsamples(Ctlr *ctlr, Isoio *iso, uint8_t *b, int32_t count) if(n > tdu->mdata - left) n = tdu->mdata - left; iunlock(&ctlr->l); /* We could page fault here */ - memmove(tdu->data + left, b + tot, n); + jehanne_memmove(tdu->data + left, b + tot, n); ilock(&ctlr->l); if(iso->tdu != tdu) continue; @@ -2033,7 +2033,7 @@ putsamples(Ctlr *ctlr, Isoio *iso, uint8_t *b, int32_t count) if(n > stdu->mdata - left) n = stdu->mdata - left; iunlock(&ctlr->l); /* We could page fault here */ - memmove(stdu->data + left, b + tot, n); + jehanne_memmove(stdu->data + left, b + tot, n); ilock(&ctlr->l); if(iso->stdu != stdu) continue; @@ -2169,7 +2169,7 @@ epgettd(Qio *io, int flags, void *a, int count, int maxpkt) } td->ndata = count; if(a != nil && count > 0) - memmove(td->data, a, count); + jehanne_memmove(td->data, a, count); coherence(); io->toggle = nexttoggle(io->toggle, count, maxpkt); coherence(); @@ -2250,7 +2250,7 @@ pollcheck(Hci *hp) lock(&poll->l); if(poll->must != 0 && poll->does == 0){ poll->does++; - print("ehci %#p: polling\n", ctlr->capio); + jehanne_print("ehci %#p: polling\n", ctlr->capio); kproc("ehcipoll", ehcipoll, hp); } unlock(&poll->l); @@ -2357,7 +2357,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) ep->dev->nb, ep->nb, io, count, ctlr->load); if((ehcidebug > 1 || ep->debug > 1) && io->tok != Tdtokin){ seprintdata(buf, buf+sizeof(buf), a, count); - print("echi epio: user data: %s\n", buf); + jehanne_print("echi epio: user data: %s\n", buf); } if(mustlock){ qlock(&io->ql); @@ -2452,7 +2452,7 @@ epio(Ep *ep, Qio *io, void *a, int32_t count, int mustlock) if((tot + n) > count) n = count - tot; if(c != nil && (td->csw & Tdtok) == Tdtokin){ - memmove(c, td->data, n); + jehanne_memmove(c, td->data, n); c += n; } tot += n; @@ -2507,9 +2507,9 @@ epread(Ep *ep, void *a, int32_t count) if(count > cio->ndata) count = cio->ndata; if(count > 0) - memmove(a, cio->data, count); + jehanne_memmove(a, cio->data, count); /* BUG for big transfers */ - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; /* signal EOF next time */ } @@ -2517,7 +2517,7 @@ epread(Ep *ep, void *a, int32_t count) poperror(); if(ehcidebug>1 || ep->debug){ seprintdata(buf, buf+sizeof(buf), a, count); - print("epread: %s\n", buf); + jehanne_print("epread: %s\n", buf); } return count; case Tbulk: @@ -2564,11 +2564,11 @@ epctlio(Ep *ep, Ctlio *cio, void *a, int32_t count) if(count < Rsetuplen) error("short usb comand"); qlock(&cio->ql); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; if(waserror()){ - free(cio->data); + jehanne_free(cio->data); cio->data = nil; cio->ndata = 0; qunlock(&cio->ql); @@ -2699,9 +2699,9 @@ isofsinit(Ep *ep, Isoio *iso) td->mdata *= ep->samplesz; left = (ep->hz+left) * ep->pollival % 1000; if(td->mdata > ep->maxpkt){ - print("ehci: ep%d.%d: size > maxpkt\n", + jehanne_print("ehci: ep%d.%d: size > maxpkt\n", ep->dev->nb, ep->nb); - print("size = %d max = %ld\n", + jehanne_print("size = %d max = %ld\n", td->mdata, ep->maxpkt); td->mdata = ep->maxpkt; } @@ -2807,7 +2807,7 @@ isoopen(Ctlr *ctlr, Ep *ep) error("uhci isoopen bug"); /* we need at least 3 tds */ iso->maxsize = ep->ntds * ep->maxpkt; if(ctlr->load + ep->load > 800) - print("usb: ehci: bandwidth may be exceeded\n"); + jehanne_print("usb: ehci: bandwidth may be exceeded\n"); ilock(&ctlr->l); ctlr->load += ep->load; ctlr->isoload += ep->load; @@ -2899,7 +2899,7 @@ epopen(Ep *ep) if(ep->aux != nil) panic("ehci: epopen called with open ep"); if(waserror()){ - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; nexterror(); } @@ -3072,9 +3072,9 @@ cancelisoio(Ctlr *ctlr, Isoio *iso, int pollival, uint32_t load) iso->tdps[frno] = nil; frno = TRUNC(frno+pollival, Nisoframes); } - free(iso->tdps); + jehanne_free(iso->tdps); iso->tdps = nil; - free(iso->data); + jehanne_free(iso->data); iso->data = nil; coherence(); } @@ -3096,7 +3096,7 @@ epclose(Ep *ep) case Tctl: cio = ep->aux; cancelio(ctlr, cio); - free(cio->data); + jehanne_free(cio->data); cio->data = nil; break; case Tintr: @@ -3122,7 +3122,7 @@ epclose(Ep *ep) default: panic("epclose: bad ttype"); } - free(ep->aux); + jehanne_free(ep->aux); ep->aux = nil; } @@ -3154,13 +3154,13 @@ mkqhtree(Ctlr *ctlr) depth = flog2(Nintrleafs); n = (1 << (depth+1)) - 1; - qt = mallocz(sizeof(*qt), 1); + qt = jehanne_mallocz(sizeof(*qt), 1); if(qt == nil) panic("ehci: mkqhtree: no memory"); qt->nel = n; qt->depth = depth; - qt->bw = mallocz(n * sizeof(qt->bw), 1); - qt->root = tree = mallocz(n * sizeof(Qh *), 1); + qt->bw = jehanne_mallocz(n * sizeof(qt->bw), 1); + qt->root = tree = jehanne_mallocz(n * sizeof(Qh *), 1); if(qt->bw == nil || tree == nil) panic("ehci: mkqhtree: no memory"); for(i = 0; i < n; i++){ @@ -3187,14 +3187,14 @@ mkqhtree(Ctlr *ctlr) o |= 1; } if(leaf0 + o >= n){ - print("leaf0=%d o=%d i=%d n=%d\n", leaf0, o, i, n); + jehanne_print("leaf0=%d o=%d i=%d n=%d\n", leaf0, o, i, n); break; } leafs[i] = PADDR(tree[leaf0 + o]) | Lqh; } assert((ctlr->nframes % Nintrleafs) == 0); for(i = 0; i < ctlr->nframes; i += Nintrleafs){ - memmove(ctlr->frames + i, leafs, sizeof leafs); + jehanne_memmove(ctlr->frames + i, leafs, sizeof leafs); coherence(); } ctlr->tree = qt; @@ -3210,7 +3210,7 @@ ehcimeminit(Ctlr *ctlr) opio = ctlr->opio; frsize = ctlr->nframes * sizeof(uint32_t); assert((frsize & 0xFFF) == 0); /* must be 4k aligned */ - ctlr->frames = mallocalign(frsize, frsize, 0, 0); + ctlr->frames = jehanne_mallocalign(frsize, frsize, 0, 0); if(ctlr->frames == nil) panic("ehci reset: no memory"); diff --git a/sys/src/lib/9p/auth.c b/sys/src/lib/9p/auth.c index 9ecf418..e1d47c3 100644 --- a/sys/src/lib/9p/auth.c +++ b/sys/src/lib/9p/auth.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/dirread.c b/sys/src/lib/9p/dirread.c index a313b3a..514216f 100644 --- a/sys/src/lib/9p/dirread.c +++ b/sys/src/lib/9p/dirread.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/fid.c b/sys/src/lib/9p/fid.c index be80341..765dc33 100644 --- a/sys/src/lib/9p/fid.c +++ b/sys/src/lib/9p/fid.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/file.c b/sys/src/lib/9p/file.c index c5931bc..0153d05 100644 --- a/sys/src/lib/9p/file.c +++ b/sys/src/lib/9p/file.c @@ -32,7 +32,7 @@ allocfile(void) File *f; enum { N = 16 }; - qlock(&filelk); + jehanne_qlock(&filelk); if(freefilelist == nil){ f = emalloc9p(N*sizeof(*f)); for(i=0; iaux; - qunlock(&filelk); + jehanne_qunlock(&filelk); a = f->allocd; - memset(f, 0, sizeof *f); + jehanne_memset(f, 0, sizeof *f); f->allocd = a; return f; } @@ -60,18 +60,18 @@ freefile(File *f) for(fl=f->filelist; fl; fl=flnext){ flnext = fl->link; assert(fl->f == nil); - free(fl); + jehanne_free(fl); } - free(f->name); - free(f->uid); - free(f->gid); - free(f->muid); - qlock(&filelk); + jehanne_free(f->name); + jehanne_free(f->uid); + jehanne_free(f->gid); + jehanne_free(f->muid); + jehanne_qlock(&filelk); assert(f->ref.ref == 0); f->aux = freefilelist; freefilelist = f; - qunlock(&filelk); + jehanne_qunlock(&filelk); } static void @@ -100,7 +100,7 @@ cleanfilelist(File *f) for(l=&f->filelist; fl=*l; ){ if(fl->f == nil){ *l = (*l)->link; - free(fl); + jehanne_free(fl); }else l = &(*l)->link; } @@ -129,31 +129,31 @@ removefile(File *f) fp = f->parent; if(fp == nil){ - werrstr("no parent"); + jehanne_werrstr("no parent"); closefile(f); return -1; } if(fp == f){ - werrstr("cannot remove root"); + jehanne_werrstr("cannot remove root"); closefile(f); return -1; } - wlock(&f->rwl); - wlock(&fp->rwl); + jehanne_wlock(&f->rwl); + jehanne_wlock(&fp->rwl); if(f->nchild != 0){ - werrstr("has children"); - wunlock(&fp->rwl); - wunlock(&f->rwl); + jehanne_werrstr("has children"); + jehanne_wunlock(&fp->rwl); + jehanne_wunlock(&f->rwl); closefile(f); return -1; } if(f->parent != fp){ - werrstr("parent changed underfoot"); - wunlock(&fp->rwl); - wunlock(&f->rwl); + jehanne_werrstr("parent changed underfoot"); + jehanne_wunlock(&fp->rwl); + jehanne_wunlock(&f->rwl); closefile(f); return -1; } @@ -167,10 +167,10 @@ removefile(File *f) fp->nchild--; fp->nxchild++; f->parent = nil; - wunlock(&f->rwl); + jehanne_wunlock(&f->rwl); cleanfilelist(fp); - wunlock(&fp->rwl); + jehanne_wunlock(&fp->rwl); closefile(fp); /* reference from child */ closefile(f); /* reference from tree */ @@ -186,14 +186,14 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux) Tree *t; if((fp->qid.type&QTDIR) == 0){ - werrstr("create in non-directory"); + jehanne_werrstr("create in non-directory"); return nil; } - wlock(&fp->rwl); + jehanne_wlock(&fp->rwl); if(fp->parent == nil){ - wunlock(&fp->rwl); - werrstr("create in deleted directory"); + jehanne_wunlock(&fp->rwl); + jehanne_werrstr("create in deleted directory"); return nil; } @@ -206,9 +206,9 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux) * Always create at the end of the list. */ for(l=&fp->filelist; fl=*l; l=&fl->link){ - if(fl->f && strcmp(fl->f->name, name) == 0){ - wunlock(&fp->rwl); - werrstr("file already exists"); + if(fl->f && jehanne_strcmp(fl->f->name, name) == 0){ + jehanne_wunlock(&fp->rwl); + jehanne_werrstr("file already exists"); return nil; } } @@ -225,9 +225,9 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux) f->mode = perm; t = fp->tree; - lock(&t->genlock); + jehanne_lock(&t->genlock); f->qid.path = t->qidgen++; - unlock(&t->genlock); + jehanne_unlock(&t->genlock); if(perm & DMDIR) f->qid.type |= QTDIR; if(perm & DMAPPEND) @@ -235,7 +235,7 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux) if(perm & DMEXCL) f->qid.type |= QTEXCL; - f->atime = f->mtime = time(0); + f->atime = f->mtime = jehanne_time(0); f->length = 0; f->parent = fp; incref(&fp->ref); @@ -245,7 +245,7 @@ createfile(File *fp, char *name, char *uid, uint32_t perm, void *aux) incref(&f->ref); /* for the tree */ fl->f = f; fp->nchild++; - wunlock(&fp->rwl); + jehanne_wunlock(&fp->rwl); return f; } @@ -256,25 +256,25 @@ walkfile1(File *dir, char *elem) File *fp; Filelist *fl; - rlock(&dir->rwl); - if(strcmp(elem, "..") == 0){ + jehanne_rlock(&dir->rwl); + if(jehanne_strcmp(elem, "..") == 0){ fp = dir->parent; if(fp != nil) incref(&fp->ref); - runlock(&dir->rwl); + jehanne_runlock(&dir->rwl); closefile(dir); return fp; } fp = nil; for(fl=dir->filelist; fl; fl=fl->link) - if(fl->f && strcmp(fl->f->name, elem)==0){ + if(fl->f && jehanne_strcmp(fl->f->name, elem)==0){ fp = fl->f; incref(&fp->ref); break; } - runlock(&dir->rwl); + jehanne_runlock(&dir->rwl); closefile(dir); return fp; } @@ -284,20 +284,20 @@ walkfile(File *f, char *path) { char *os, *s, *nexts; - if(strchr(path, '/') == nil) + if(jehanne_strchr(path, '/') == nil) return walkfile1(f, path); /* avoid malloc */ os = s = estrdup9p(path); for(; *s; s=nexts){ - if(nexts = strchr(s, '/')) + if(nexts = jehanne_strchr(s, '/')) *nexts++ = '\0'; else - nexts = s+strlen(s); + nexts = s+jehanne_strlen(s); f = walkfile1(f, s); if(f == nil) break; } - free(os); + jehanne_free(os); return f; } @@ -312,7 +312,7 @@ alloctree(char *uid, char *gid, uint32_t mode, void (*destroy)(File*)) f = allocfile(); f->name = estrdup9p("/"); if(uid == nil){ - uid = getuser(); + uid = jehanne_getuser(); if(uid == nil) uid = "none"; } @@ -327,7 +327,7 @@ alloctree(char *uid, char *gid, uint32_t mode, void (*destroy)(File*)) f->qid = (Qid){0, 0, QTDIR}; f->length = 0; - f->atime = f->mtime = time(0); + f->atime = f->mtime = jehanne_time(0); f->mode = DMDIR | mode; f->tree = t; f->parent = f; @@ -354,7 +354,7 @@ _freefiles(File *f) for(fl=f->filelist; fl; fl=flnext){ flnext = fl->link; _freefiles(fl->f); - free(fl); + jehanne_free(fl); } f->tree->destroy(f); @@ -365,7 +365,7 @@ void freetree(Tree *t) { _freefiles(t->root); - free(t); + jehanne_free(t); } Readdir* @@ -373,9 +373,9 @@ opendirfile(File *dir) { Readdir *r; - rlock(&dir->rwl); + jehanne_rlock(&dir->rwl); if((dir->mode & DMDIR)==0){ - runlock(&dir->rwl); + jehanne_runlock(&dir->rwl); return nil; } r = emalloc9p(sizeof(*r)); @@ -389,7 +389,7 @@ opendirfile(File *dir) r->fl = dir->filelist; r->dir = dir; incref(&dir->readers); - runlock(&dir->rwl); + jehanne_runlock(&dir->rwl); return r; } @@ -402,7 +402,7 @@ readdirfile(Readdir *r, uint8_t *buf, int32_t n) for(fl=r->fl, m=0; fl && m+2<=n; fl=fl->link, m+=x){ if(fl->f == nil) x = 0; - else if((x=convD2M(fl->f, buf+m, n-m)) <= BIT16SZ) + else if((x=jehanne_convD2M(fl->f, buf+m, n-m)) <= BIT16SZ) break; } r->fl = fl; @@ -413,9 +413,9 @@ void closedirfile(Readdir *r) { if(decref(&r->dir->readers) == 0){ - wlock(&r->dir->rwl); + jehanne_wlock(&r->dir->rwl); cleanfilelist(r->dir); - wunlock(&r->dir->rwl); + jehanne_wunlock(&r->dir->rwl); } - free(r); + jehanne_free(r); } diff --git a/sys/src/lib/9p/ftest.c b/sys/src/lib/9p/ftest.c index f1c01df..a289e46 100644 --- a/sys/src/lib/9p/ftest.c +++ b/sys/src/lib/9p/ftest.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include "9p.h" diff --git a/sys/src/lib/9p/intmap.c b/sys/src/lib/9p/intmap.c index 4428e37..039b9e4 100644 --- a/sys/src/lib/9p/intmap.c +++ b/sys/src/lib/9p/intmap.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/listen.c b/sys/src/lib/9p/listen.c index c5f6fe3..5ac0477 100644 --- a/sys/src/lib/9p/listen.c +++ b/sys/src/lib/9p/listen.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/mem.c b/sys/src/lib/9p/mem.c index 7c8c477..47b9f2c 100644 --- a/sys/src/lib/9p/mem.c +++ b/sys/src/lib/9p/mem.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/parse.c b/sys/src/lib/9p/parse.c index f084632..d99fed5 100644 --- a/sys/src/lib/9p/parse.c +++ b/sys/src/lib/9p/parse.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/post.c b/sys/src/lib/9p/post.c index f8be9d9..9a16feb 100644 --- a/sys/src/lib/9p/post.c +++ b/sys/src/lib/9p/post.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/queue.c b/sys/src/lib/9p/queue.c index f557ea8..4b9600b 100644 --- a/sys/src/lib/9p/queue.c +++ b/sys/src/lib/9p/queue.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include <9p.h> diff --git a/sys/src/lib/9p/ramfs.c b/sys/src/lib/9p/ramfs.c index ae52a47..d8c33d9 100644 --- a/sys/src/lib/9p/ramfs.c +++ b/sys/src/lib/9p/ramfs.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/req.c b/sys/src/lib/9p/req.c index a3efd5b..a6c9bc9 100644 --- a/sys/src/lib/9p/req.c +++ b/sys/src/lib/9p/req.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/rfork.c b/sys/src/lib/9p/rfork.c index 12493da..23a051a 100644 --- a/sys/src/lib/9p/rfork.c +++ b/sys/src/lib/9p/rfork.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/srv.c b/sys/src/lib/9p/srv.c index 5fff6d0..1d89b5e 100644 --- a/sys/src/lib/9p/srv.c +++ b/sys/src/lib/9p/srv.c @@ -16,7 +16,7 @@ * along with Jehanne. If not, see . */ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/thread.c b/sys/src/lib/9p/thread.c index ad0931d..61c857c 100644 --- a/sys/src/lib/9p/thread.c +++ b/sys/src/lib/9p/thread.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/uid.c b/sys/src/lib/9p/uid.c index c892fdc..fc0a7aa 100644 --- a/sys/src/lib/9p/uid.c +++ b/sys/src/lib/9p/uid.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p/util.c b/sys/src/lib/9p/util.c index 6ac79f5..81338c7 100644 --- a/sys/src/lib/9p/util.c +++ b/sys/src/lib/9p/util.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include <9P2000.h> #include diff --git a/sys/src/lib/9p2000/convM2S.c b/sys/src/lib/9p2000/convM2S.c index 5d268ed..7183e13 100644 --- a/sys/src/lib/9p2000/convM2S.c +++ b/sys/src/lib/9p2000/convM2S.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> static diff --git a/sys/src/lib/9p2000/convS2M.c b/sys/src/lib/9p2000/convS2M.c index b2b4160..49ca90a 100644 --- a/sys/src/lib/9p2000/convS2M.c +++ b/sys/src/lib/9p2000/convS2M.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> static diff --git a/sys/src/lib/9p2000/fcallfmt.c b/sys/src/lib/9p2000/fcallfmt.c index bf69778..9659319 100644 --- a/sys/src/lib/9p2000/fcallfmt.c +++ b/sys/src/lib/9p2000/fcallfmt.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> static uint32_t dumpsome(char*, char*, char*, int32_t); diff --git a/sys/src/lib/9p2000/read9pmsg.c b/sys/src/lib/9p2000/read9pmsg.c index b1f8b45..40788b4 100644 --- a/sys/src/lib/9p2000/read9pmsg.c +++ b/sys/src/lib/9p2000/read9pmsg.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include <9P2000.h> int diff --git a/sys/src/lib/String/s_alloc.c b/sys/src/lib/String/s_alloc.c index ae46a49..a735556 100644 --- a/sys/src/lib/String/s_alloc.c +++ b/sys/src/lib/String/s_alloc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" #define STRLEN 128 @@ -18,12 +18,12 @@ s_free(String *sp) { if (sp == nil) return; - lock(sp); + jehanne_lock(sp); if(--(sp->ref) != 0){ - unlock(sp); + jehanne_unlock(sp); return; } - unlock(sp); + jehanne_unlock(sp); if(sp->fixed == 0 && sp->base != nil) free(sp->base); @@ -34,9 +34,9 @@ s_free(String *sp) extern String * s_incref(String *sp) { - lock(sp); + jehanne_lock(sp); sp->ref++; - unlock(sp); + jehanne_unlock(sp); return sp; } diff --git a/sys/src/lib/String/s_append.c b/sys/src/lib/String/s_append.c index ae314ab..1b611b0 100644 --- a/sys/src/lib/String/s_append.c +++ b/sys/src/lib/String/s_append.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" /* append a char array to a String */ diff --git a/sys/src/lib/String/s_array.c b/sys/src/lib/String/s_array.c index f28a8d4..cad8744 100644 --- a/sys/src/lib/String/s_array.c +++ b/sys/src/lib/String/s_array.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" extern String* _s_alloc(void); diff --git a/sys/src/lib/String/s_copy.c b/sys/src/lib/String/s_copy.c index 04516de..6fca224 100644 --- a/sys/src/lib/String/s_copy.c +++ b/sys/src/lib/String/s_copy.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" diff --git a/sys/src/lib/String/s_getline.c b/sys/src/lib/String/s_getline.c index a0e5258..5288faf 100644 --- a/sys/src/lib/String/s_getline.c +++ b/sys/src/lib/String/s_getline.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "String.h" diff --git a/sys/src/lib/String/s_grow.c b/sys/src/lib/String/s_grow.c index b73a878..4ccc05b 100644 --- a/sys/src/lib/String/s_grow.c +++ b/sys/src/lib/String/s_grow.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" /* grow a String's allocation by at least `incr' bytes */ diff --git a/sys/src/lib/String/s_memappend.c b/sys/src/lib/String/s_memappend.c index 2fa9fd2..2514fd3 100644 --- a/sys/src/lib/String/s_memappend.c +++ b/sys/src/lib/String/s_memappend.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" /* append a char array ( of up to n characters) to a String */ diff --git a/sys/src/lib/String/s_nappend.c b/sys/src/lib/String/s_nappend.c index 00b2ae6..aca3c3b 100644 --- a/sys/src/lib/String/s_nappend.c +++ b/sys/src/lib/String/s_nappend.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" /* append a char array ( of up to n characters) to a String */ diff --git a/sys/src/lib/String/s_parse.c b/sys/src/lib/String/s_parse.c index 1d0e05b..663d6a8 100644 --- a/sys/src/lib/String/s_parse.c +++ b/sys/src/lib/String/s_parse.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" #define isspace(c) ((c)==' ' || (c)=='\t' || (c)=='\n') diff --git a/sys/src/lib/String/s_putc.c b/sys/src/lib/String/s_putc.c index 49916e3..4283109 100644 --- a/sys/src/lib/String/s_putc.c +++ b/sys/src/lib/String/s_putc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" void diff --git a/sys/src/lib/String/s_rdinstack.c b/sys/src/lib/String/s_rdinstack.c index cfecd2a..e47a671 100644 --- a/sys/src/lib/String/s_rdinstack.c +++ b/sys/src/lib/String/s_rdinstack.c @@ -9,7 +9,7 @@ #include -#include +#include #include #include "String.h" diff --git a/sys/src/lib/String/s_read.c b/sys/src/lib/String/s_read.c index dcba98f..c08a7c4 100644 --- a/sys/src/lib/String/s_read.c +++ b/sys/src/lib/String/s_read.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "String.h" diff --git a/sys/src/lib/String/s_read_line.c b/sys/src/lib/String/s_read_line.c index be41799..9b81022 100644 --- a/sys/src/lib/String/s_read_line.c +++ b/sys/src/lib/String/s_read_line.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "String.h" diff --git a/sys/src/lib/String/s_reset.c b/sys/src/lib/String/s_reset.c index 9732cc4..9a03b91 100644 --- a/sys/src/lib/String/s_reset.c +++ b/sys/src/lib/String/s_reset.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" String* diff --git a/sys/src/lib/String/s_terminate.c b/sys/src/lib/String/s_terminate.c index 8d80072..c725af1 100644 --- a/sys/src/lib/String/s_terminate.c +++ b/sys/src/lib/String/s_terminate.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" void diff --git a/sys/src/lib/String/s_tolower.c b/sys/src/lib/String/s_tolower.c index f109430..a2dc3f9 100644 --- a/sys/src/lib/String/s_tolower.c +++ b/sys/src/lib/String/s_tolower.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" diff --git a/sys/src/lib/String/s_unique.c b/sys/src/lib/String/s_unique.c index 23f25b0..7b9f228 100644 --- a/sys/src/lib/String/s_unique.c +++ b/sys/src/lib/String/s_unique.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "String.h" String* diff --git a/sys/src/lib/aml/aml.c b/sys/src/lib/aml/aml.c index efe58ff..6eecbac 100644 --- a/sys/src/lib/aml/aml.c +++ b/sys/src/lib/aml/aml.c @@ -1,5 +1,5 @@ #include -#include +#include #include typedef struct Interp Interp; diff --git a/sys/src/lib/aml/amlalloc.c b/sys/src/lib/aml/amlalloc.c index 2b8f2f2..7cdf662 100644 --- a/sys/src/lib/aml/amlalloc.c +++ b/sys/src/lib/aml/amlalloc.c @@ -1,5 +1,5 @@ #include -#include +#include #include void* diff --git a/sys/src/lib/aml/amldelay.c b/sys/src/lib/aml/amldelay.c index 29960c5..ed53ed4 100644 --- a/sys/src/lib/aml/amldelay.c +++ b/sys/src/lib/aml/amldelay.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/lib/aml/amlmapio.c b/sys/src/lib/aml/amlmapio.c index 11dd1b5..598d5c9 100644 --- a/sys/src/lib/aml/amlmapio.c +++ b/sys/src/lib/aml/amlmapio.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/aml/amlunmapio.c b/sys/src/lib/aml/amlunmapio.c index 7e515c3..2975fbf 100644 --- a/sys/src/lib/aml/amlunmapio.c +++ b/sys/src/lib/aml/amlunmapio.c @@ -1,5 +1,5 @@ #include -#include +#include #include void diff --git a/sys/src/lib/auth/amount.c b/sys/src/lib/auth/amount.c index 5492a07..2de8e1f 100644 --- a/sys/src/lib/auth/amount.c +++ b/sys/src/lib/auth/amount.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/amount_getkey.c b/sys/src/lib/auth/amount_getkey.c index 019fad2..cf99188 100644 --- a/sys/src/lib/auth/amount_getkey.c +++ b/sys/src/lib/auth/amount_getkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include int (*amount_getkey)(char*) = auth_getkey; diff --git a/sys/src/lib/auth/attr.c b/sys/src/lib/auth/attr.c index e004161..b462451 100644 --- a/sys/src/lib/auth/attr.c +++ b/sys/src/lib/auth/attr.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/auth/auth_attr.c b/sys/src/lib/auth/auth_attr.c index 2acc32f..1bf05e3 100644 --- a/sys/src/lib/auth/auth_attr.c +++ b/sys/src/lib/auth/auth_attr.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_challenge.c b/sys/src/lib/auth/auth_challenge.c index d21841a..5ce93ef 100644 --- a/sys/src/lib/auth/auth_challenge.c +++ b/sys/src/lib/auth/auth_challenge.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_chuid.c b/sys/src/lib/auth/auth_chuid.c index dd7fb26..663b125 100644 --- a/sys/src/lib/auth/auth_chuid.c +++ b/sys/src/lib/auth/auth_chuid.c @@ -1,5 +1,5 @@ #include -#include +#include #include /* diff --git a/sys/src/lib/auth/auth_getkey.c b/sys/src/lib/auth/auth_getkey.c index 0ae28b1..ca0dd9b 100644 --- a/sys/src/lib/auth/auth_getkey.c +++ b/sys/src/lib/auth/auth_getkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/auth/auth_getuserpasswd.c b/sys/src/lib/auth/auth_getuserpasswd.c index 4d66dce..fa4359d 100644 --- a/sys/src/lib/auth/auth_getuserpasswd.c +++ b/sys/src/lib/auth/auth_getuserpasswd.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_proxy.c b/sys/src/lib/auth/auth_proxy.c index 3c75d81..faaf6d7 100644 --- a/sys/src/lib/auth/auth_proxy.c +++ b/sys/src/lib/auth/auth_proxy.c @@ -1,5 +1,5 @@ #include -#include +#include #include <9P2000.h> #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_respond.c b/sys/src/lib/auth/auth_respond.c index cd66016..92e1605 100644 --- a/sys/src/lib/auth/auth_respond.c +++ b/sys/src/lib/auth/auth_respond.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_rpc.c b/sys/src/lib/auth/auth_rpc.c index db9bcb7..75e7cd4 100644 --- a/sys/src/lib/auth/auth_rpc.c +++ b/sys/src/lib/auth/auth_rpc.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_userpasswd.c b/sys/src/lib/auth/auth_userpasswd.c index 1acee13..a6370e9 100644 --- a/sys/src/lib/auth/auth_userpasswd.c +++ b/sys/src/lib/auth/auth_userpasswd.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/auth_wep.c b/sys/src/lib/auth/auth_wep.c index afde46b..b683833 100644 --- a/sys/src/lib/auth/auth_wep.c +++ b/sys/src/lib/auth/auth_wep.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "authlocal.h" diff --git a/sys/src/lib/auth/login.c b/sys/src/lib/auth/login.c index 8bbc7b1..7edadfc 100644 --- a/sys/src/lib/auth/login.c +++ b/sys/src/lib/auth/login.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/auth/newns.c b/sys/src/lib/auth/newns.c index 919b782..2263420 100644 --- a/sys/src/lib/auth/newns.c +++ b/sys/src/lib/auth/newns.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/lib/auth/noworld.c b/sys/src/lib/auth/noworld.c index c61b146..48e62ec 100644 --- a/sys/src/lib/auth/noworld.c +++ b/sys/src/lib/auth/noworld.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/lib/authsrv/_asgetpakkey.c b/sys/src/lib/authsrv/_asgetpakkey.c index 746d1fc..6b48b07 100644 --- a/sys/src/lib/authsrv/_asgetpakkey.c +++ b/sys/src/lib/authsrv/_asgetpakkey.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/_asgetresp.c b/sys/src/lib/authsrv/_asgetresp.c index 3f7cb5d..21b3194 100644 --- a/sys/src/lib/authsrv/_asgetresp.c +++ b/sys/src/lib/authsrv/_asgetresp.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/_asgetticket.c b/sys/src/lib/authsrv/_asgetticket.c index d7e30b2..f14d0da 100644 --- a/sys/src/lib/authsrv/_asgetticket.c +++ b/sys/src/lib/authsrv/_asgetticket.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/_asrdresp.c b/sys/src/lib/authsrv/_asrdresp.c index 8a7daf8..ff6da58 100644 --- a/sys/src/lib/authsrv/_asrdresp.c +++ b/sys/src/lib/authsrv/_asrdresp.c @@ -1,5 +1,5 @@ #include -#include +#include #include static char *pbmsg = "AS protocol botch"; diff --git a/sys/src/lib/authsrv/_asrequest.c b/sys/src/lib/authsrv/_asrequest.c index 7479c48..ececa7b 100644 --- a/sys/src/lib/authsrv/_asrequest.c +++ b/sys/src/lib/authsrv/_asrequest.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/authdial.c b/sys/src/lib/authsrv/authdial.c index 1aaa5b1..7ced0c5 100644 --- a/sys/src/lib/authsrv/authdial.c +++ b/sys/src/lib/authsrv/authdial.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/lib/authsrv/authpak.c b/sys/src/lib/authsrv/authpak.c index e2cdde2..04a9a60 100644 --- a/sys/src/lib/authsrv/authpak.c +++ b/sys/src/lib/authsrv/authpak.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ authpak_curve(void) { static PAKcurve a; - lock(&a); + jehanne_lock(&a); if(a.P == nil){ a.P = mpnew(0); a.A = mpnew(0); @@ -37,7 +37,7 @@ authpak_curve(void) ed448_curve(a.P, a.A, a.D, a.X, a.Y); a.P = mpfield(a.P); } - unlock(&a); + jehanne_unlock(&a); return &a; } diff --git a/sys/src/lib/authsrv/convA2M.c b/sys/src/lib/authsrv/convA2M.c index fb44927..16837c8 100644 --- a/sys/src/lib/authsrv/convA2M.c +++ b/sys/src/lib/authsrv/convA2M.c @@ -1,5 +1,5 @@ #include -#include +#include #include extern int form1B2M(char *ap, int n, uint8_t key[32]); diff --git a/sys/src/lib/authsrv/convM2A.c b/sys/src/lib/authsrv/convM2A.c index d647611..34802f8 100644 --- a/sys/src/lib/authsrv/convM2A.c +++ b/sys/src/lib/authsrv/convM2A.c @@ -1,5 +1,5 @@ #include -#include +#include #include extern int form1M2B(char *ap, int n, uint8_t key[32]); diff --git a/sys/src/lib/authsrv/convM2PR.c b/sys/src/lib/authsrv/convM2PR.c index 4f082df..7619515 100644 --- a/sys/src/lib/authsrv/convM2PR.c +++ b/sys/src/lib/authsrv/convM2PR.c @@ -1,5 +1,5 @@ #include -#include +#include #include extern int form1M2B(char *ap, int n, uint8_t key[32]); diff --git a/sys/src/lib/authsrv/convM2T.c b/sys/src/lib/authsrv/convM2T.c index ae4f2ee..0fea638 100644 --- a/sys/src/lib/authsrv/convM2T.c +++ b/sys/src/lib/authsrv/convM2T.c @@ -1,5 +1,5 @@ #include -#include +#include #include extern int form1check(char *ap, int n); diff --git a/sys/src/lib/authsrv/convM2TR.c b/sys/src/lib/authsrv/convM2TR.c index ef29c62..6aef874 100644 --- a/sys/src/lib/authsrv/convM2TR.c +++ b/sys/src/lib/authsrv/convM2TR.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/convPR2M.c b/sys/src/lib/authsrv/convPR2M.c index 4705aaf..8dd50a9 100644 --- a/sys/src/lib/authsrv/convPR2M.c +++ b/sys/src/lib/authsrv/convPR2M.c @@ -1,5 +1,5 @@ #include -#include +#include #include extern int form1B2M(char *ap, int n, uint8_t key[32]); diff --git a/sys/src/lib/authsrv/convT2M.c b/sys/src/lib/authsrv/convT2M.c index ea3dd56..f051059 100644 --- a/sys/src/lib/authsrv/convT2M.c +++ b/sys/src/lib/authsrv/convT2M.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/lib/authsrv/convTR2M.c b/sys/src/lib/authsrv/convTR2M.c index 1c76625..b7226db 100644 --- a/sys/src/lib/authsrv/convTR2M.c +++ b/sys/src/lib/authsrv/convTR2M.c @@ -1,5 +1,5 @@ #include -#include +#include #include int diff --git a/sys/src/lib/authsrv/form1.c b/sys/src/lib/authsrv/form1.c index 5a9d108..d38f93a 100644 --- a/sys/src/lib/authsrv/form1.c +++ b/sys/src/lib/authsrv/form1.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/lib/authsrv/nvcsum.c b/sys/src/lib/authsrv/nvcsum.c index 9c7d5a2..41bf83d 100644 --- a/sys/src/lib/authsrv/nvcsum.c +++ b/sys/src/lib/authsrv/nvcsum.c @@ -1,5 +1,5 @@ #include -#include +#include #include uint8_t diff --git a/sys/src/lib/authsrv/passtokey.c b/sys/src/lib/authsrv/passtokey.c index 39e5ed5..cc1ccc2 100644 --- a/sys/src/lib/authsrv/passtokey.c +++ b/sys/src/lib/authsrv/passtokey.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/sys/src/lib/authsrv/readnvram.c b/sys/src/lib/authsrv/readnvram.c index 2d8cab0..8beebbb 100644 --- a/sys/src/lib/authsrv/readnvram.c +++ b/sys/src/lib/authsrv/readnvram.c @@ -1,5 +1,5 @@ #include -#include +#include #include static int32_t finddosfile(int, char*); diff --git a/sys/src/lib/avl/avl.c b/sys/src/lib/avl/avl.c index 72f77dd..ad27f5f 100644 --- a/sys/src/lib/avl/avl.c +++ b/sys/src/lib/avl/avl.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/bio/bbuffered.c b/sys/src/lib/bio/bbuffered.c index c7ace90..93a4c1d 100644 --- a/sys/src/lib/bio/bbuffered.c +++ b/sys/src/lib/bio/bbuffered.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bfildes.c b/sys/src/lib/bio/bfildes.c index f4881d4..c572998 100644 --- a/sys/src/lib/bio/bfildes.c +++ b/sys/src/lib/bio/bfildes.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bflush.c b/sys/src/lib/bio/bflush.c index f638f81..d20a085 100644 --- a/sys/src/lib/bio/bflush.c +++ b/sys/src/lib/bio/bflush.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bgetc.c b/sys/src/lib/bio/bgetc.c index 39c8e43..c7cad5a 100644 --- a/sys/src/lib/bio/bgetc.c +++ b/sys/src/lib/bio/bgetc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bgetd.c b/sys/src/lib/bio/bgetd.c index 173f994..48f0c03 100644 --- a/sys/src/lib/bio/bgetd.c +++ b/sys/src/lib/bio/bgetd.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include struct bgetd diff --git a/sys/src/lib/bio/bgetrune.c b/sys/src/lib/bio/bgetrune.c index 8263600..e871d1b 100644 --- a/sys/src/lib/bio/bgetrune.c +++ b/sys/src/lib/bio/bgetrune.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int32_t diff --git a/sys/src/lib/bio/binit.c b/sys/src/lib/bio/binit.c index b02c56a..e542c2a 100644 --- a/sys/src/lib/bio/binit.c +++ b/sys/src/lib/bio/binit.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static Biobufhdr* wbufs[20]; diff --git a/sys/src/lib/bio/boffset.c b/sys/src/lib/bio/boffset.c index e1a9694..fa33daa 100644 --- a/sys/src/lib/bio/boffset.c +++ b/sys/src/lib/bio/boffset.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int64_t diff --git a/sys/src/lib/bio/bprint.c b/sys/src/lib/bio/bprint.c index e85ee51..473a058 100644 --- a/sys/src/lib/bio/bprint.c +++ b/sys/src/lib/bio/bprint.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bputc.c b/sys/src/lib/bio/bputc.c index 662e635..fc9aa76 100644 --- a/sys/src/lib/bio/bputc.c +++ b/sys/src/lib/bio/bputc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/bputrune.c b/sys/src/lib/bio/bputrune.c index c3aeeb2..c872c27 100644 --- a/sys/src/lib/bio/bputrune.c +++ b/sys/src/lib/bio/bputrune.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/bio/brdline.c b/sys/src/lib/bio/brdline.c index 372fb72..6bdc5b6 100644 --- a/sys/src/lib/bio/brdline.c +++ b/sys/src/lib/bio/brdline.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void* diff --git a/sys/src/lib/bio/brdstr.c b/sys/src/lib/bio/brdstr.c index b27d2f5..379209d 100644 --- a/sys/src/lib/bio/brdstr.c +++ b/sys/src/lib/bio/brdstr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static char* diff --git a/sys/src/lib/bio/bread.c b/sys/src/lib/bio/bread.c index b30f0af..9208739 100644 --- a/sys/src/lib/bio/bread.c +++ b/sys/src/lib/bio/bread.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int32_t diff --git a/sys/src/lib/bio/bseek.c b/sys/src/lib/bio/bseek.c index 42d8068..3cbde1b 100644 --- a/sys/src/lib/bio/bseek.c +++ b/sys/src/lib/bio/bseek.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int64_t diff --git a/sys/src/lib/bio/btestprint.c b/sys/src/lib/bio/btestprint.c index b8e89a3..a1d60d9 100644 --- a/sys/src/lib/bio/btestprint.c +++ b/sys/src/lib/bio/btestprint.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/bio/bvprint.c b/sys/src/lib/bio/bvprint.c index c198160..011ef24 100644 --- a/sys/src/lib/bio/bvprint.c +++ b/sys/src/lib/bio/bvprint.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static int diff --git a/sys/src/lib/bio/bwrite.c b/sys/src/lib/bio/bwrite.c index 07f3741..e811a00 100644 --- a/sys/src/lib/bio/bwrite.c +++ b/sys/src/lib/bio/bwrite.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int32_t diff --git a/sys/src/lib/c/9sys/access.c b/sys/src/lib/c/9sys/access.c index c85727d..7ade817 100644 --- a/sys/src/lib/c/9sys/access.c +++ b/sys/src/lib/c/9sys/access.c @@ -20,7 +20,7 @@ #include int -access(const char *name, int mode) +jehanne_access(const char *name, int mode) { int fd; diff --git a/sys/src/lib/c/9sys/announce.c b/sys/src/lib/c/9sys/announce.c index 18424cb..3ff0447 100644 --- a/sys/src/lib/c/9sys/announce.c +++ b/sys/src/lib/c/9sys/announce.c @@ -22,7 +22,7 @@ enum * announce a network service. */ int -announce(const char *addr, char *dir) +jehanne_announce(const char *addr, char *dir) { int ctl, n, m; char buf[Maxpath]; @@ -42,12 +42,12 @@ announce(const char *addr, char *dir) */ ctl = open(netdir, ORDWR); if(ctl<0){ - werrstr("announce opening %s: %r", netdir); + jehanne_werrstr("announce opening %s: %r", netdir); return -1; } - cp = strrchr(netdir, '/'); + cp = jehanne_strrchr(netdir, '/'); if(cp == nil){ - werrstr("announce arg format %s", netdir); + jehanne_werrstr("announce arg format %s", netdir); close(ctl); return -1; } @@ -56,10 +56,10 @@ announce(const char *addr, char *dir) /* * find out which line we have */ - n = snprint(buf, sizeof(buf), "%s/", netdir); + n = jehanne_snprint(buf, sizeof(buf), "%s/", netdir); m = read(ctl, &buf[n], sizeof(buf)-n-1); if(m <= 0){ - werrstr("announce reading %s: %r", netdir); + jehanne_werrstr("announce reading %s: %r", netdir); close(ctl); return -1; } @@ -68,9 +68,9 @@ announce(const char *addr, char *dir) /* * make the call */ - n = snprint(buf2, sizeof(buf2), "announce %s", naddr); + n = jehanne_snprint(buf2, sizeof(buf2), "announce %s", naddr); if(write(ctl, buf2, n)!=n){ - werrstr("announce writing %s: %r", netdir); + jehanne_werrstr("announce writing %s: %r", netdir); close(ctl); return -1; } @@ -79,7 +79,7 @@ announce(const char *addr, char *dir) * return directory etc. */ if(dir){ - strncpy(dir, buf, NETPATHLEN); + jehanne_strncpy(dir, buf, NETPATHLEN); dir[NETPATHLEN-1] = 0; } return ctl; @@ -89,7 +89,7 @@ announce(const char *addr, char *dir) * listen for an incoming call */ int -listen(const char *dir, char *newdir) +jehanne_listen(const char *dir, char *newdir) { int ctl, n, m; char buf[Maxpath]; @@ -98,22 +98,22 @@ listen(const char *dir, char *newdir) /* * open listen, wait for a call */ - snprint(buf, sizeof(buf), "%s/listen", dir); + jehanne_snprint(buf, sizeof(buf), "%s/listen", dir); ctl = open(buf, ORDWR); if(ctl < 0){ - werrstr("listen opening %s: %r", buf); + jehanne_werrstr("listen opening %s: %r", buf); return -1; } /* * find out which line we have */ - strncpy(buf, dir, sizeof(buf) - 1); + jehanne_strncpy(buf, dir, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; - cp = strrchr(buf, '/'); + cp = jehanne_strrchr(buf, '/'); if(cp == nil){ close(ctl); - werrstr("listen arg format %s", dir); + jehanne_werrstr("listen arg format %s", dir); return -1; } *++cp = 0; @@ -121,7 +121,7 @@ listen(const char *dir, char *newdir) m = read(ctl, cp, sizeof(buf) - n - 1); if(m <= 0){ close(ctl); - werrstr("listen reading %s/listen: %r", dir); + jehanne_werrstr("listen reading %s/listen: %r", dir); return -1; } buf[n+m] = 0; @@ -130,7 +130,7 @@ listen(const char *dir, char *newdir) * return directory etc. */ if(newdir){ - strncpy(newdir, buf, NETPATHLEN); + jehanne_strncpy(newdir, buf, NETPATHLEN); newdir[NETPATHLEN-1] = 0; } return ctl; @@ -141,22 +141,22 @@ listen(const char *dir, char *newdir) * accept a call, return an fd to the open data file */ int -accept(int ctl, const char *dir) +jehanne_accept(int ctl, const char *dir) { char buf[Maxpath]; const char *num; int32_t n; - num = strrchr(dir, '/'); + num = jehanne_strrchr(dir, '/'); if(num == nil) num = dir; else num++; - n = snprint(buf, sizeof(buf), "accept %s", num); + n = jehanne_snprint(buf, sizeof(buf), "accept %s", num); write(ctl, buf, n); /* ignore return value, network might not need accepts */ - snprint(buf, sizeof(buf), "%s/data", dir); + jehanne_snprint(buf, sizeof(buf), "%s/data", dir); return open(buf, ORDWR); } @@ -164,19 +164,19 @@ accept(int ctl, const char *dir) * reject a call, tell device the reason for the rejection */ int -reject(int ctl, const char *dir, const char *cause) +jehanne_reject(int ctl, const char *dir, const char *cause) { char buf[Maxpath]; const char *num; int32_t n; - num = strrchr(dir, '/'); + num = jehanne_strrchr(dir, '/'); if(num == 0) num = dir; else num++; - snprint(buf, sizeof(buf), "reject %s %s", num, cause); - n = strlen(buf); + jehanne_snprint(buf, sizeof(buf), "reject %s %s", num, cause); + n = jehanne_strlen(buf); if(write(ctl, buf, n) != n) return -1; return 0; @@ -195,14 +195,14 @@ identtrans(char *netdir, const char *addr, char *naddr, int na, USED(nf); /* parse the protocol */ - strncpy(proto, addr, sizeof(proto)); + jehanne_strncpy(proto, addr, sizeof(proto)); proto[sizeof(proto)-1] = 0; - p = strchr(proto, '!'); + p = jehanne_strchr(proto, '!'); if(p) *p++ = 0; - snprint(file, nf, "%s/%s/clone", netdir, proto); - strncpy(naddr, p, na); + jehanne_snprint(file, nf, "%s/%s/clone", netdir, proto); + jehanne_strncpy(naddr, p, na); naddr[na-1] = 0; return 1; @@ -223,23 +223,23 @@ nettrans(const char *addr, char *naddr, int na, char *file, int nf) /* * parse, get network directory */ - p = strchr(addr, '!'); + p = jehanne_strchr(addr, '!'); if(p == 0){ - werrstr("bad dial string: %s", addr); + jehanne_werrstr("bad dial string: %s", addr); return -1; } if(*addr != '/'){ - strncpy(netdir, "/net", sizeof(netdir)); + jehanne_strncpy(netdir, "/net", sizeof(netdir)); netdir[sizeof(netdir) - 1] = 0; } else { for(p2 = p; *p2 != '/'; p2--) ; i = p2 - addr; if(i == 0 || i >= sizeof(netdir)){ - werrstr("bad dial string: %s", addr); + jehanne_werrstr("bad dial string: %s", addr); return -1; } - strncpy(netdir, addr, i); + jehanne_strncpy(netdir, addr, i); netdir[i] = 0; addr = p2 + 1; } @@ -247,11 +247,11 @@ nettrans(const char *addr, char *naddr, int na, char *file, int nf) /* * ask the connection server */ - snprint(buf, sizeof(buf), "%s/cs", netdir); + jehanne_snprint(buf, sizeof(buf), "%s/cs", netdir); fd = open(buf, ORDWR); if(fd < 0) return identtrans(netdir, addr, naddr, na, file, nf); - if(write(fd, addr, strlen(addr)) < 0){ + if(write(fd, addr, jehanne_strlen(addr)) < 0){ close(fd); return -1; } @@ -265,20 +265,20 @@ nettrans(const char *addr, char *naddr, int na, char *file, int nf) /* * parse the reply */ - p = strchr(buf, ' '); + p = jehanne_strchr(buf, ' '); if(p == 0) return -1; *p++ = 0; - strncpy(naddr, p, na); + jehanne_strncpy(naddr, p, na); naddr[na-1] = 0; if(buf[0] == '/'){ - p = strchr(buf+1, '/'); + p = jehanne_strchr(buf+1, '/'); if(p == nil) p = buf; else p++; } - snprint(file, nf, "%s/%s", netdir, p); + jehanne_snprint(file, nf, "%s/%s", netdir, p); return 0; } diff --git a/sys/src/lib/c/9sys/awakened.c b/sys/src/lib/c/9sys/awakened.c index ccd3826..c5349c8 100644 --- a/sys/src/lib/c/9sys/awakened.c +++ b/sys/src/lib/c/9sys/awakened.c @@ -20,7 +20,7 @@ #include int -awakened(int64_t wakeup) +jehanne_awakened(int64_t wakeup) { /* awake returns the ticks of the scheduled wakeup in negative, * thus a wakeup is in the past iff (-awake(0)) >= (-wakeup) @@ -33,12 +33,12 @@ awakened(int64_t wakeup) } int -forgivewkp(int64_t wakeup) +jehanne_forgivewkp(int64_t wakeup) { /* awake returns the ticks of the scheduled wakeup in negative, * and is able to remove a wakeup provided such value. * - * forgivewkp() is just a wrapper to hide awake()'s details that + * jehanne_forgivewkp() is just a wrapper to hide awake()'s details that * could change in the future and make client code easier to * read. * diff --git a/sys/src/lib/c/9sys/chdir.c b/sys/src/lib/c/9sys/chdir.c index 8c7009c..99af29e 100644 --- a/sys/src/lib/c/9sys/chdir.c +++ b/sys/src/lib/c/9sys/chdir.c @@ -20,19 +20,19 @@ #include int -chdir(const char *dirname) +jehanne_chdir(const char *dirname) { char buf[32]; int tmp, fd; - tmp = getpid(); - snprint(buf, sizeof(buf), "/proc/%d/wdir", tmp); + tmp = jehanne_getpid(); + jehanne_snprint(buf, sizeof(buf), "/proc/%d/wdir", tmp); fd = open(buf, OWRITE); if(fd < 0) fd = open("#0/wdir", OWRITE); if(fd < 0) return fd; - tmp = write(fd, dirname, 1+strlen(dirname)); + tmp = write(fd, dirname, 1+jehanne_strlen(dirname)); close(fd); return tmp; } diff --git a/sys/src/lib/c/9sys/convD2M.c b/sys/src/lib/c/9sys/convD2M.c index 66b3a17..b2aea40 100644 --- a/sys/src/lib/c/9sys/convD2M.c +++ b/sys/src/lib/c/9sys/convD2M.c @@ -12,7 +12,7 @@ #include <9P2000.h> uint32_t -sizeD2M(Dir *d) +jehanne_sizeD2M(Dir *d) { char *sv[4]; int i, ns; @@ -25,13 +25,13 @@ sizeD2M(Dir *d) ns = 0; for(i = 0; i < 4; i++) if(sv[i]) - ns += strlen(sv[i]); + ns += jehanne_strlen(sv[i]); return STATFIXLEN + ns; } uint32_t -convD2M(Dir *d, uint8_t *buf, uint32_t nbuf) +jehanne_convD2M(Dir *d, uint8_t *buf, uint32_t nbuf) { uint8_t *p, *ebuf; char *sv[4]; @@ -51,7 +51,7 @@ convD2M(Dir *d, uint8_t *buf, uint32_t nbuf) ns = 0; for(i = 0; i < 4; i++){ if(sv[i]) - nsv[i] = strlen(sv[i]); + nsv[i] = jehanne_strlen(sv[i]); else nsv[i] = 0; ns += nsv[i]; @@ -93,7 +93,7 @@ convD2M(Dir *d, uint8_t *buf, uint32_t nbuf) PBIT16(p, ns); p += BIT16SZ; if(ns) - memmove(p, sv[i], ns); + jehanne_memmove(p, sv[i], ns); p += ns; } diff --git a/sys/src/lib/c/9sys/convM2D.c b/sys/src/lib/c/9sys/convM2D.c index d2ae4bc..0f2cbf9 100644 --- a/sys/src/lib/c/9sys/convM2D.c +++ b/sys/src/lib/c/9sys/convM2D.c @@ -39,7 +39,7 @@ statcheck(uint8_t *buf, uint32_t nbuf) static char nullstring[] = ""; uint32_t -convM2D(uint8_t *buf, uint32_t nbuf, Dir *d, char *strs) +jehanne_convM2D(uint8_t *buf, uint32_t nbuf, Dir *d, char *strs) { uint8_t *p, *ebuf; char *sv[4]; @@ -82,7 +82,7 @@ convM2D(uint8_t *buf, uint32_t nbuf, Dir *d, char *strs) return 0; if(strs){ sv[i] = strs; - memmove(strs, p, ns); + jehanne_memmove(strs, p, ns); strs += ns; *strs++ = '\0'; } diff --git a/sys/src/lib/c/9sys/cputime.c b/sys/src/lib/c/9sys/cputime.c index fb0d92a..b684307 100644 --- a/sys/src/lib/c/9sys/cputime.c +++ b/sys/src/lib/c/9sys/cputime.c @@ -13,12 +13,12 @@ #define HZ 1000 double -cputime(void) +jehanne_cputime(void) { int32_t t[4]; int i; - times(t); + jehanne_times(t); for(i=1; i<4; i++) t[0] += t[i]; return t[0] / (double)HZ; diff --git a/sys/src/lib/c/9sys/ctime.c b/sys/src/lib/c/9sys/ctime.c index 22b37f1..f8e776c 100644 --- a/sys/src/lib/c/9sys/ctime.c +++ b/sys/src/lib/c/9sys/ctime.c @@ -11,7 +11,7 @@ * This routine converts time as follows. * The epoch is 0000 Jan 1 1970 GMT. * The argument time is in seconds since then. - * The localtime(t) entry returns a pointer to an array + * The jehanne_localtime(t) entry returns a pointer to an array * containing * * seconds (0-59) @@ -26,7 +26,7 @@ * * The routine gets the daylight savings time from the environment. * - * asctime(tvec)) + * jehanne_asctime(tvec)) * where tvec is produced by localtime * returns a ptr to a character string * that has the ascii time in the form @@ -36,7 +36,7 @@ * 012345678901234567890123456789 * 0 1 2 * - * ctime(t) just calls localtime, then asctime. + * jehanne_ctime(t) just calls localtime, then asctime. */ #include @@ -71,13 +71,13 @@ struct } timezone; char* -ctime(int32_t t) +jehanne_ctime(int32_t t) { - return asctime(localtime(t)); + return jehanne_asctime(jehanne_localtime(t)); } Tm* -localtime(int32_t tim) +jehanne_localtime(int32_t tim) { Tm *ct; int32_t t, *p; @@ -94,19 +94,19 @@ localtime(int32_t tim) dlflag++; break; } - ct = gmtime(t); + ct = jehanne_gmtime(t); if(dlflag){ - strcpy(ct->zone, timezone.dlname); + jehanne_strcpy(ct->zone, timezone.dlname); ct->tzoff = timezone.dldiff; } else { - strcpy(ct->zone, timezone.stname); + jehanne_strcpy(ct->zone, timezone.stname); ct->tzoff = timezone.stdiff; } return ct; } Tm* -gmtime(int32_t tim) +jehanne_gmtime(int32_t tim) { int d0, d1; int32_t hms, day; @@ -162,17 +162,17 @@ gmtime(int32_t tim) dmsize[1] = 28; xtime.mday = d0 + 1; xtime.mon = d1; - strcpy(xtime.zone, "GMT"); + jehanne_strcpy(xtime.zone, "GMT"); return &xtime; } char* -asctime(Tm *t) +jehanne_asctime(Tm *t) { char *ncp; static char cbuf[30]; - strcpy(cbuf, "Thu Jan 01 00:00:00 GMT 1970\n"); + jehanne_strcpy(cbuf, "Thu Jan 01 00:00:00 GMT 1970\n"); ncp = &"SunMonTueWedThuFriSat"[t->wday*3]; cbuf[0] = *ncp++; cbuf[1] = *ncp++; @@ -225,7 +225,7 @@ readtimezone(void) char buf[TZSIZE*11+30], *p; int i; - memset(buf, 0, sizeof(buf)); + jehanne_memset(buf, 0, sizeof(buf)); i = open("/env/timezone", OREAD); if(i < 0) goto error; @@ -252,7 +252,7 @@ readtimezone(void) error: timezone.stdiff = 0; - strcpy(timezone.stname, "GMT"); + jehanne_strcpy(timezone.stname, "GMT"); timezone.dlpairs[0] = 0; } diff --git a/sys/src/lib/c/9sys/dial.c b/sys/src/lib/c/9sys/dial.c index 43f4b89..74ff667 100644 --- a/sys/src/lib/c/9sys/dial.c +++ b/sys/src/lib/c/9sys/dial.c @@ -101,8 +101,8 @@ dialimpl(const char *dest, const char *local, char *dir, int *cfdp) return rv; err[0] = '\0'; errstr(err, sizeof err); - if(strstr(err, "refused") != 0){ - werrstr("%s", err); + if(jehanne_strstr(err, "refused") != 0){ + jehanne_werrstr("%s", err); return rv; } ds.netdir = "/net.alt"; @@ -112,10 +112,10 @@ dialimpl(const char *dest, const char *local, char *dir, int *cfdp) alterr[0] = 0; errstr(alterr, sizeof alterr); - if(strstr(alterr, "translate") || strstr(alterr, "does not exist")) - werrstr("%s", err); + if(jehanne_strstr(alterr, "translate") || jehanne_strstr(alterr, "does not exist")) + jehanne_werrstr("%s", err); else - werrstr("%s", alterr); + jehanne_werrstr("%s", alterr); return rv; } @@ -126,7 +126,7 @@ dialimpl(const char *dest, const char *local, char *dir, int *cfdp) int (*_dial)(const char *, const char *, char *, int *) = dialimpl; int -dial(const char *dest, const char *local, char *dir, int *cfdp) +jehanne_dial(const char *dest, const char *local, char *dir, int *cfdp) { return (*_dial)(dest, local, dir, cfdp); } @@ -136,11 +136,11 @@ connsalloc(Dest *dp, int addrs) { Conn *conn; - free(dp->conn); + jehanne_free(dp->conn); dp->connend = nil; assert(addrs > 0); - dp->conn = mallocz(addrs * sizeof *dp->conn, 1); + dp->conn = jehanne_mallocz(addrs * sizeof *dp->conn, 1); if(dp->conn == nil) return -1; dp->connend = dp->conn + addrs; @@ -157,8 +157,8 @@ freedest(Dest *dp) if (dp == nil) return; oalarm = dp->oalarm; - free(dp->conn); - free(dp); + jehanne_free(dp->conn); + jehanne_free(dp); if (oalarm >= 0) alarm(oalarm); } @@ -181,10 +181,10 @@ notedeath(Dest *dp, char *exitsts) for (i = 0; i < nelem(fields); i++) fields[i] = ""; - n = tokenize(exitsts, fields, nelem(fields)); + n = jehanne_tokenize(exitsts, fields, nelem(fields)); if (n < 4) return; - pid = atoi(fields[0]); + pid = jehanne_atoi(fields[0]); if (pid <= 0) return; for (conn = dp->conn; conn < dp->connend; conn++) @@ -193,7 +193,7 @@ notedeath(Dest *dp, char *exitsts) closeopenfd(&conn->dfd); closeopenfd(&conn->cfd); } - strncpy(conn->err, fields[4], sizeof conn->err - 1); + jehanne_strncpy(conn->err, fields[4], sizeof conn->err - 1); conn->err[sizeof conn->err - 1] = '\0'; conn->dead = 1; return; @@ -235,7 +235,7 @@ fillinds(DS *ds, Dest *dp) if (ds->cfdp) *ds->cfdp = conn->cfd; if (ds->dir) { - strncpy(ds->dir, conn->dir, NETPATHLEN); + jehanne_strncpy(ds->dir, conn->dir, NETPATHLEN); ds->dir[NETPATHLEN-1] = '\0'; } return conn->dfd; @@ -253,7 +253,7 @@ connectwait(Dest *dp, char *besterr) /* kill all of our still-live kids & reap them */ for (conn = dp->conn; conn < dp->connend; conn++) if (!conn->dead) - postnote(PNPROC, conn->pid, "alarm"); + jehanne_postnote(PNPROC, conn->pid, "alarm"); while (reap(dp) >= 0) ; @@ -261,7 +261,7 @@ connectwait(Dest *dp, char *besterr) for (conn = dp->conn; conn < dp->connend; conn++) if (conn - dp->conn != dp->winner && conn->dead && conn->err[0]) { - strncpy(besterr, conn->err, ERRMAX-1); + jehanne_strncpy(besterr, conn->err, ERRMAX-1); besterr[ERRMAX-1] = '\0'; break; } @@ -273,18 +273,18 @@ parsecs(Dest *dp, char **clonep, char **destp) { char *dest, *p; - dest = strchr(dp->nextaddr, ' '); + dest = jehanne_strchr(dp->nextaddr, ' '); if(dest == nil) { - p = strchr(dp->nextaddr, '\n'); + p = jehanne_strchr(dp->nextaddr, '\n'); if(p) *p = '\0'; - werrstr("malformed clone cmd from cs `%s'", dp->nextaddr); + jehanne_werrstr("malformed clone cmd from cs `%s'", dp->nextaddr); if(p) *p = '\n'; return -1; } *dest++ = '\0'; - p = strchr(dest, '\n'); + p = jehanne_strchr(dest, '\n'); if(p == nil) return -1; *p++ = '\0'; @@ -299,14 +299,14 @@ pickuperr(char *besterr, char *err) { err[0] = '\0'; errstr(err, ERRMAX); - if(strstr(err, "does not exist") == 0) - strcpy(besterr, err); + if(jehanne_strstr(err, "does not exist") == 0) + jehanne_strcpy(besterr, err); } static int catcher(void *v, char *s) { - return strstr(s, "alarm") != nil; + return jehanne_strstr(s, "alarm") != nil; } /* @@ -333,7 +333,7 @@ dialmulti(DS *ds, Dest *dp) char err[ERRMAX]; /* only in kid, to avoid atnotify callbacks in parent */ - atnotify(catcher, 1); + jehanne_atnotify(catcher, 1); *besterr = '\0'; rv = call(clone, dest, ds, dp, &dp->conn[kidme]); @@ -345,7 +345,7 @@ dialmulti(DS *ds, Dest *dp) *besterr = '\0'; rv = connectwait(dp, besterr); if(rv < 0) - werrstr("%s", (*besterr? besterr: "unknown error")); + jehanne_werrstr("%s", (*besterr? besterr: "unknown error")); return rv; } @@ -358,8 +358,8 @@ csdial(DS *ds) char buf[Maxstring], clone[Maxpath], err[ERRMAX], besterr[ERRMAX]; Dest *dp; - werrstr(""); - dp = mallocz(sizeof *dp, 1); + jehanne_werrstr(""); + dp = jehanne_mallocz(sizeof *dp, 1); if(dp == nil) return -1; dp->winner = -1; @@ -372,11 +372,11 @@ csdial(DS *ds) /* * open connection server */ - snprint(buf, sizeof(buf), "%s/cs", ds->netdir); + jehanne_snprint(buf, sizeof(buf), "%s/cs", ds->netdir); fd = open(buf, ORDWR); if(fd < 0){ /* no connection server, don't translate */ - snprint(clone, sizeof(clone), "%s/%s/clone", ds->netdir, ds->proto); + jehanne_snprint(clone, sizeof(clone), "%s/%s/clone", ds->netdir, ds->proto); rv = call(clone, ds->rem, ds, dp, &dp->conn[0]); fillinds(ds, dp); freedest(dp); @@ -387,8 +387,8 @@ csdial(DS *ds) * ask connection server to translate * e.g., net!cs.bell-labs.com!smtp */ - snprint(buf, sizeof(buf), "%s!%s", ds->proto, ds->rem); - if(write(fd, buf, strlen(buf)) < 0){ + jehanne_snprint(buf, sizeof(buf), "%s!%s", ds->proto, ds->rem); + if(write(fd, buf, jehanne_strlen(buf)) < 0){ close(fd); freedest(dp); return -1; @@ -427,13 +427,13 @@ csdial(DS *ds) rv = -1; /* pessimistic default */ dp->naddrs = addrs; if (addrs == 0) - werrstr("no address to dial"); + jehanne_werrstr("no address to dial"); else if (addrs == 1) { /* common case: dial one address without forking */ if (parsecs(dp, &clone2, &dest) >= 0 && (rv = call(clone2, dest, ds, dp, &dp->conn[0])) < 0) { pickuperr(besterr, err); - werrstr("%s", besterr); + jehanne_werrstr("%s", besterr); } } else if (connsalloc(dp, addrs) >= 0) rv = dialmulti(ds, dp); @@ -454,16 +454,16 @@ call(char *clone, char *dest, DS *ds, Dest *dp, Conn *conn) /* because cs is in a different name space, replace the mount point */ if(*clone == '/'){ - p = strchr(clone+1, '/'); + p = jehanne_strchr(clone+1, '/'); if(p == nil) p = clone; else p++; } else p = clone; - snprint(cname, sizeof cname, "%s/%s", ds->netdir, p); + jehanne_snprint(cname, sizeof cname, "%s/%s", ds->netdir, p); - conn->pid = getpid(); + conn->pid = jehanne_getpid(); conn->cfd = cfd = open(cname, ORDWR); if(cfd < 0) return -1; @@ -477,12 +477,12 @@ call(char *clone, char *dest, DS *ds, Dest *dp, Conn *conn) name[n] = 0; for(p = name; *p == ' '; p++) ; - snprint(name, sizeof(name), "%ld", strtoul(p, 0, 0)); - p = strrchr(cname, '/'); + jehanne_snprint(name, sizeof(name), "%ld", jehanne_strtoul(p, 0, 0)); + p = jehanne_strrchr(cname, '/'); *p = 0; if(ds->dir) - snprint(conn->dir, NETPATHLEN, "%s/%s", cname, name); - snprint(data, sizeof(data), "%s/%s/data", cname, name); + jehanne_snprint(conn->dir, NETPATHLEN, "%s/%s", cname, name); + jehanne_snprint(data, sizeof(data), "%s/%s/data", cname, name); /* should be no alarm pending now; re-instate caller's alarm, if any */ calleralarm = dp->oalarm > 0; @@ -493,10 +493,10 @@ call(char *clone, char *dest, DS *ds, Dest *dp, Conn *conn) /* connect */ if(ds->local) - snprint(name, sizeof(name), "connect %s %s", dest, ds->local); + jehanne_snprint(name, sizeof(name), "connect %s %s", dest, ds->local); else - snprint(name, sizeof(name), "connect %s", dest); - if(write(cfd, name, strlen(name)) < 0){ + jehanne_snprint(name, sizeof(name), "connect %s", dest); + if(write(cfd, name, jehanne_strlen(name)) < 0){ closeopenfd(&conn->cfd); return -1; } @@ -517,10 +517,10 @@ call(char *clone, char *dest, DS *ds, Dest *dp, Conn *conn) n = conn - dp->conn; if (dp->winner < 0) { - qlock(&dp->winlck); + jehanne_qlock(&dp->winlck); if (dp->winner < 0 && conn < dp->connend) dp->winner = n; - qunlock(&dp->winlck); + jehanne_qunlock(&dp->winlck); } alarm(calleralarm? dp->oalarm: 0); return fd; @@ -534,10 +534,10 @@ _dial_string_parse(const char *str, DS *ds) { char *p, *p2; - strncpy(ds->buf, str, Maxstring); + jehanne_strncpy(ds->buf, str, Maxstring); ds->buf[Maxstring-1] = 0; - p = strchr(ds->buf, '!'); + p = jehanne_strchr(ds->buf, '!'); if(p == 0) { ds->netdir = 0; ds->proto = "net"; diff --git a/sys/src/lib/c/9sys/dirfstat.c b/sys/src/lib/c/9sys/dirfstat.c index 9af440f..670a31f 100644 --- a/sys/src/lib/c/9sys/dirfstat.c +++ b/sys/src/lib/c/9sys/dirfstat.c @@ -17,7 +17,7 @@ enum }; Dir* -dirfstat(int fd) +jehanne_dirfstat(int fd) { Dir *d; uint8_t *buf; @@ -25,22 +25,22 @@ dirfstat(int fd) nd = DIRSIZE; for(i=0; i<2; i++){ /* should work by the second try */ - d = malloc(sizeof(Dir) + BIT16SZ + nd); + d = jehanne_malloc(sizeof(Dir) + BIT16SZ + nd); if(d == nil) return nil; buf = (uint8_t*)&d[1]; n = fstat(fd, buf, BIT16SZ+nd); if(n < BIT16SZ){ - free(d); + jehanne_free(d); return nil; } nd = GBIT16(buf); /* upper bound on size of Dir + strings */ if(nd <= n){ - convM2D(buf, n, d, (char*)&d[1]); + jehanne_convM2D(buf, n, d, (char*)&d[1]); return d; } /* else sizeof(Dir)+BIT16SZ+nd is plenty */ - free(d); + jehanne_free(d); } return nil; } diff --git a/sys/src/lib/c/9sys/dirfwstat.c b/sys/src/lib/c/9sys/dirfwstat.c index 569bbda..022aa5c 100644 --- a/sys/src/lib/c/9sys/dirfwstat.c +++ b/sys/src/lib/c/9sys/dirfwstat.c @@ -12,17 +12,17 @@ #include <9P2000.h> int -dirfwstat(int fd, Dir *d) +jehanne_dirfwstat(int fd, Dir *d) { uint8_t *buf; int r; - r = sizeD2M(d); - buf = malloc(r); + r = jehanne_sizeD2M(d); + buf = jehanne_malloc(r); if(buf == nil) return -1; - convD2M(d, buf, r); + jehanne_convD2M(d, buf, r); r = fwstat(fd, buf, r); - free(buf); + jehanne_free(buf); return r; } diff --git a/sys/src/lib/c/9sys/dirmodefmt.c b/sys/src/lib/c/9sys/dirmodefmt.c index 0f83f81..68dbf2b 100644 --- a/sys/src/lib/c/9sys/dirmodefmt.c +++ b/sys/src/lib/c/9sys/dirmodefmt.c @@ -26,11 +26,11 @@ static char *modes[] = static void rwx(int32_t m, char *s) { - strncpy(s, modes[m], 3); + jehanne_strncpy(s, modes[m], 3); } int -dirmodefmt(Fmt *f) +jehanne_dirmodefmt(Fmt *f) { static char buf[16]; uint32_t m; @@ -53,5 +53,5 @@ dirmodefmt(Fmt *f) rwx((m>>3)&7, buf+5); rwx((m>>0)&7, buf+8); buf[11] = 0; - return fmtstrcpy(f, buf); + return jehanne_fmtstrcpy(f, buf); } diff --git a/sys/src/lib/c/9sys/dirread.c b/sys/src/lib/c/9sys/dirread.c index aad441d..35a9a59 100644 --- a/sys/src/lib/c/9sys/dirread.c +++ b/sys/src/lib/c/9sys/dirread.c @@ -38,7 +38,7 @@ dirpackage(uint8_t *buf, int32_t ts, Dir **d) if(i != ts) return -1; - *d = malloc(n * sizeof(Dir) + ss); + *d = jehanne_malloc(n * sizeof(Dir) + ss); if(*d == nil) return -1; @@ -49,8 +49,8 @@ dirpackage(uint8_t *buf, int32_t ts, Dir **d) nn = 0; for(i = 0; i < ts; i += m){ m = BIT16SZ + GBIT16((uint8_t*)&buf[i]); - if(nn >= n || convM2D(&buf[i], m, *d + nn, s) != m){ - free(*d); + if(nn >= n || jehanne_convM2D(&buf[i], m, *d + nn, s) != m){ + jehanne_free(*d); *d = nil; return -1; } @@ -62,23 +62,23 @@ dirpackage(uint8_t *buf, int32_t ts, Dir **d) } int32_t -dirread(int fd, Dir **d) +jehanne_dirread(int fd, Dir **d) { uint8_t *buf; int32_t ts; - buf = malloc(DIRMAX); + buf = jehanne_malloc(DIRMAX); if(buf == nil) return -1; ts = read(fd, buf, DIRMAX); if(ts >= 0) ts = dirpackage(buf, ts, d); - free(buf); + jehanne_free(buf); return ts; } int32_t -dirreadall(int fd, Dir **d) +jehanne_dirreadall(int fd, Dir **d) { uint8_t *buf, *nbuf; int32_t n, ts; @@ -86,9 +86,9 @@ dirreadall(int fd, Dir **d) buf = nil; ts = 0; for(;;){ - nbuf = realloc(buf, ts+DIRMAX); + nbuf = jehanne_realloc(buf, ts+DIRMAX); if(nbuf == nil){ - free(buf); + jehanne_free(buf); return -1; } buf = nbuf; @@ -99,7 +99,7 @@ dirreadall(int fd, Dir **d) } if(ts >= 0) ts = dirpackage(buf, ts, d); - free(buf); + jehanne_free(buf); if(ts == 0 && n < 0) return -1; return ts; diff --git a/sys/src/lib/c/9sys/dirstat.c b/sys/src/lib/c/9sys/dirstat.c index 2291264..95a8c54 100644 --- a/sys/src/lib/c/9sys/dirstat.c +++ b/sys/src/lib/c/9sys/dirstat.c @@ -17,7 +17,7 @@ enum }; Dir* -dirstat(const char *name) +jehanne_dirstat(const char *name) { Dir *d; uint8_t *buf; @@ -25,22 +25,22 @@ dirstat(const char *name) nd = DIRSIZE; for(i=0; i<2; i++){ /* should work by the second try */ - d = malloc(sizeof(Dir) + BIT16SZ + nd); + d = jehanne_malloc(sizeof(Dir) + BIT16SZ + nd); if(d == nil) return nil; buf = (uint8_t*)&d[1]; - n = stat(name, buf, BIT16SZ+nd); + n = jehanne_stat(name, buf, BIT16SZ+nd); if(n < BIT16SZ){ - free(d); + jehanne_free(d); return nil; } nd = GBIT16((uint8_t*)buf); /* upper bound on size of Dir + strings */ if(nd <= n){ - convM2D(buf, n, d, (char*)&d[1]); + jehanne_convM2D(buf, n, d, (char*)&d[1]); return d; } /* else sizeof(Dir)+BIT16SZ+nd is plenty */ - free(d); + jehanne_free(d); } return nil; } diff --git a/sys/src/lib/c/9sys/dirwstat.c b/sys/src/lib/c/9sys/dirwstat.c index 90c8831..f3b098a 100644 --- a/sys/src/lib/c/9sys/dirwstat.c +++ b/sys/src/lib/c/9sys/dirwstat.c @@ -12,17 +12,17 @@ #include <9P2000.h> int -dirwstat(const char *name, Dir *d) +jehanne_dirwstat(const char *name, Dir *d) { uint8_t *buf; int r; - r = sizeD2M(d); - buf = malloc(r); + r = jehanne_sizeD2M(d); + buf = jehanne_malloc(r); if(buf == nil) return -1; - convD2M(d, buf, r); - r = wstat(name, buf, r); - free(buf); + jehanne_convD2M(d, buf, r); + r = jehanne_wstat(name, buf, r); + jehanne_free(buf); return r; } diff --git a/sys/src/lib/c/9sys/dup.c b/sys/src/lib/c/9sys/dup.c index 0d42395..c7c5519 100644 --- a/sys/src/lib/c/9sys/dup.c +++ b/sys/src/lib/c/9sys/dup.c @@ -19,7 +19,7 @@ #include int -dup(int oldfd, int newfd) +jehanne_dup(int oldfd, int newfd) { FdPair in, out; long f; diff --git a/sys/src/lib/c/9sys/fork.c b/sys/src/lib/c/9sys/fork.c index bc086d0..7703044 100644 --- a/sys/src/lib/c/9sys/fork.c +++ b/sys/src/lib/c/9sys/fork.c @@ -11,7 +11,7 @@ #include int -fork(void) +jehanne_fork(void) { return rfork(RFPROC|RFFDG|RFREND); } diff --git a/sys/src/lib/c/9sys/getenv.c b/sys/src/lib/c/9sys/getenv.c index d5b4aa5..46703ff 100644 --- a/sys/src/lib/c/9sys/getenv.c +++ b/sys/src/lib/c/9sys/getenv.c @@ -20,7 +20,7 @@ #include char* -getenv(const char *name) +jehanne_getenv(const char *name) { int f; int32_t l; @@ -29,13 +29,13 @@ getenv(const char *name) assert(name != nil); if(name[0]=='\0') goto BadName; - if(strcmp(name, ".")==0 || strcmp(name, "..")==0) + if(jehanne_strcmp(name, ".")==0 || jehanne_strcmp(name, "..")==0) goto BadName; - if(strchr(name, '/')!=nil) + if(jehanne_strchr(name, '/')!=nil) goto BadName; - snprint(path, sizeof path, "/env/%s", name); - if(strcmp(path+5, name) != 0) + jehanne_snprint(path, sizeof path, "/env/%s", name); + if(jehanne_strcmp(path+5, name) != 0) goto BadName; f = open(path, OREAD); @@ -47,16 +47,16 @@ getenv(const char *name) * using #ec when the open in #e fails is both * slow and not flexible enough. */ - snprint(path, sizeof path, "#e/%s", name); + jehanne_snprint(path, sizeof path, "#e/%s", name); f = open(path, OREAD); if(f < 0) return nil; } l = seek(f, 0, 2); - value = malloc(l+1); + value = jehanne_malloc(l+1); if(value == nil) goto Done; - setmalloctag(value, getcallerpc()); + jehanne_setmalloctag(value, jehanne_getcallerpc()); seek(f, 0, 0); if(read(f, value, l) >= 0) value[l] = '\0'; @@ -65,6 +65,6 @@ Done: return value; BadName: - werrstr("bad env name: '%s'", name); + jehanne_werrstr("bad env name: '%s'", name); return nil; } diff --git a/sys/src/lib/c/9sys/getmainpid.c b/sys/src/lib/c/9sys/getmainpid.c index c20fcb0..7aec5f1 100644 --- a/sys/src/lib/c/9sys/getmainpid.c +++ b/sys/src/lib/c/9sys/getmainpid.c @@ -24,7 +24,7 @@ extern int32_t _mainpid; /* declared in $ARCH/argv0.c */ int32_t -getmainpid(void) +jehanne_getmainpid(void) { /* getmainpid returns the pid of the process at the top of the * stack, that is the process that started the main() function. diff --git a/sys/src/lib/c/9sys/getnetconninfo.c b/sys/src/lib/c/9sys/getnetconninfo.c index 1348b4e..3c9f814 100644 --- a/sys/src/lib/c/9sys/getnetconninfo.c +++ b/sys/src/lib/c/9sys/getnetconninfo.c @@ -21,18 +21,18 @@ getendpoint(char *dir, char *file, char **sysp, char **servp) sys = serv = 0; - snprint(buf, sizeof buf, "%s/%s", dir, file); + jehanne_snprint(buf, sizeof buf, "%s/%s", dir, file); fd = open(buf, OREAD); if(fd >= 0){ n = read(fd, buf, sizeof(buf)-1); if(n>0){ buf[n-1] = 0; - serv = strchr(buf, '!'); + serv = jehanne_strchr(buf, '!'); if(serv){ *serv++ = 0; - serv = strdup(serv); + serv = jehanne_strdup(serv); } - sys = strdup(buf); + sys = jehanne_strdup(buf); } close(fd); } @@ -45,7 +45,7 @@ getendpoint(char *dir, char *file, char **sysp, char **servp) } NetConnInfo* -getnetconninfo(const char *dir, int fd) +jehanne_getnetconninfo(const char *dir, int fd) { NetConnInfo *nci; char *cp; @@ -58,40 +58,40 @@ getnetconninfo(const char *dir, int fd) if(dir == nil || *dir == 0){ if(fd2path(fd, path, sizeof(path)) < 0) return nil; - cp = strrchr(path, '/'); + cp = jehanne_strrchr(path, '/'); if(cp == nil) return nil; *cp = 0; dir = path; } - nci = mallocz(sizeof *nci, 1); + nci = jehanne_mallocz(sizeof *nci, 1); if(nci == nil) return nil; /* copy connection directory */ - nci->dir = strdup(dir); + nci->dir = jehanne_strdup(dir); if(nci->dir == nil) goto err; /* get netroot */ - nci->root = strdup(dir); + nci->root = jehanne_strdup(dir); if(nci->root == nil) goto err; - cp = strchr(nci->root+1, '/'); + cp = jehanne_strchr(nci->root+1, '/'); if(cp == nil) goto err; *cp = 0; /* figure out bind spec */ - d = dirstat(nci->dir); + d = jehanne_dirstat(nci->dir); if(d != nil){ - sprint(spec, "#%C%d", d->type, d->dev); - nci->spec = strdup(spec); + jehanne_sprint(spec, "#%C%d", d->type, d->dev); + nci->spec = jehanne_strdup(spec); } if(nci->spec == nil) nci->spec = unknown; - free(d); + jehanne_free(d); /* get the two end points */ getendpoint(nci->dir, "local", &nci->lsys, &nci->lserv); @@ -101,18 +101,18 @@ getnetconninfo(const char *dir, int fd) if(nci->rsys == nil || nci->rserv == nil) goto err; - strecpy(netname, netname+sizeof netname, nci->dir); - if((p = strrchr(netname, '/')) != nil) + jehanne_strecpy(netname, netname+sizeof netname, nci->dir); + if((p = jehanne_strrchr(netname, '/')) != nil) *p = 0; - if(strncmp(netname, "/net/", 5) == 0) - memmove(netname, netname+5, strlen(netname+5)+1); - nci->laddr = smprint("%s!%s!%s", netname, nci->lsys, nci->lserv); - nci->raddr = smprint("%s!%s!%s", netname, nci->rsys, nci->rserv); + if(jehanne_strncmp(netname, "/net/", 5) == 0) + jehanne_memmove(netname, netname+5, jehanne_strlen(netname+5)+1); + nci->laddr = jehanne_smprint("%s!%s!%s", netname, nci->lsys, nci->lserv); + nci->raddr = jehanne_smprint("%s!%s!%s", netname, nci->rsys, nci->rserv); if(nci->laddr == nil || nci->raddr == nil) goto err; return nci; err: - freenetconninfo(nci); + jehanne_freenetconninfo(nci); return nil; } @@ -121,11 +121,11 @@ xfree(char *x) { if(x == nil || x == unknown) return; - free(x); + jehanne_free(x); } void -freenetconninfo(NetConnInfo *nci) +jehanne_freenetconninfo(NetConnInfo *nci) { if(nci == nil) return; @@ -138,5 +138,5 @@ freenetconninfo(NetConnInfo *nci) xfree(nci->rserv); xfree(nci->laddr); xfree(nci->raddr); - free(nci); + jehanne_free(nci); } diff --git a/sys/src/lib/c/9sys/getpid.c b/sys/src/lib/c/9sys/getpid.c index 4e113f6..5eed694 100644 --- a/sys/src/lib/c/9sys/getpid.c +++ b/sys/src/lib/c/9sys/getpid.c @@ -20,7 +20,7 @@ #include int -getpid(void) +jehanne_getpid(void) { int pid; pid = (int)remove("#0/pid"); diff --git a/sys/src/lib/c/9sys/getppid.c b/sys/src/lib/c/9sys/getppid.c index d18c57e..62d4c22 100644 --- a/sys/src/lib/c/9sys/getppid.c +++ b/sys/src/lib/c/9sys/getppid.c @@ -20,7 +20,7 @@ #include int -getppid(void) +jehanne_getppid(void) { int pid; pid = (int)remove("#0/ppid"); diff --git a/sys/src/lib/c/9sys/getwd.c b/sys/src/lib/c/9sys/getwd.c index 2b4e04b..559e6db 100644 --- a/sys/src/lib/c/9sys/getwd.c +++ b/sys/src/lib/c/9sys/getwd.c @@ -27,7 +27,7 @@ * - the (positive) length of the working directory on success */ long -getwd(char *buf, int nbuf) +jehanne_getwd(char *buf, int nbuf) { long n; int fd; diff --git a/sys/src/lib/c/9sys/iounit.c b/sys/src/lib/c/9sys/iounit.c index daec478..36a4418 100644 --- a/sys/src/lib/c/9sys/iounit.c +++ b/sys/src/lib/c/9sys/iounit.c @@ -16,12 +16,12 @@ */ int -iounit(int fd) +jehanne_iounit(int fd) { int i, cfd; char buf[128], *args[10]; - snprint(buf, sizeof buf, "#d/%dctl", fd); + jehanne_snprint(buf, sizeof buf, "#d/%dctl", fd); cfd = open(buf, OREAD); if(cfd < 0) return 0; @@ -30,7 +30,7 @@ iounit(int fd) if(i <= 0) return 0; buf[i] = '\0'; - if(tokenize(buf, args, nelem(args)) != nelem(args)) + if(jehanne_tokenize(buf, args, nelem(args)) != nelem(args)) return 0; - return atoi(args[7]); + return jehanne_atoi(args[7]); } diff --git a/sys/src/lib/c/9sys/nsec.c b/sys/src/lib/c/9sys/nsec.c index 732d286..2025e00 100644 --- a/sys/src/lib/c/9sys/nsec.c +++ b/sys/src/lib/c/9sys/nsec.c @@ -20,7 +20,7 @@ #include unsigned long -nsec(void) +jehanne_nsec(void) { long r; r = remove("/dev/time"); diff --git a/sys/src/lib/c/9sys/nulldir.c b/sys/src/lib/c/9sys/nulldir.c index 0d3a17e..bb3d251 100644 --- a/sys/src/lib/c/9sys/nulldir.c +++ b/sys/src/lib/c/9sys/nulldir.c @@ -11,8 +11,8 @@ #include void -nulldir(Dir *d) +jehanne_nulldir(Dir *d) { - memset(d, ~0, sizeof(Dir)); + jehanne_memset(d, ~0, sizeof(Dir)); d->name = d->uid = d->gid = d->muid = ""; } diff --git a/sys/src/lib/c/9sys/ocreate.c b/sys/src/lib/c/9sys/ocreate.c index 88e4571..b2df87e 100644 --- a/sys/src/lib/c/9sys/ocreate.c +++ b/sys/src/lib/c/9sys/ocreate.c @@ -36,7 +36,7 @@ * For more info see http://marc.info/?t=146412533100003&r=1&w=2 */ int -ocreate(const char *path, unsigned int omode, unsigned int perm) +jehanne_ocreate(const char *path, unsigned int omode, unsigned int perm) { int fd; Dir *s; @@ -53,16 +53,16 @@ ocreate(const char *path, unsigned int omode, unsigned int perm) } } - s = dirfstat(fd); + s = jehanne_dirfstat(fd); if(s == nil){ close(fd); return -1; } if(s->mode != perm){ s->mode = perm; - dirfwstat(fd, s); /* we ignore the return value, the device/server is allowed to ignore us */ + jehanne_dirfwstat(fd, s); /* we ignore the return value, the device/server is allowed to ignore us */ } - free(s); + jehanne_free(s); Done: return fd; diff --git a/sys/src/lib/c/9sys/pipe.c b/sys/src/lib/c/9sys/pipe.c index c3fd6b4..07dba02 100644 --- a/sys/src/lib/c/9sys/pipe.c +++ b/sys/src/lib/c/9sys/pipe.c @@ -19,7 +19,7 @@ #include int -pipe(int pipes[2]) +jehanne_pipe(int pipes[2]) { FdPair pset; pset.aslong = remove("#0/pipes"); diff --git a/sys/src/lib/c/9sys/postnote.c b/sys/src/lib/c/9sys/postnote.c index 87126d1..b073897 100644 --- a/sys/src/lib/c/9sys/postnote.c +++ b/sys/src/lib/c/9sys/postnote.c @@ -25,14 +25,14 @@ openprocnotes(int pid) char file[128]; int32_t f; - sprint(file, "#p/%d/note", pid); + jehanne_sprint(file, "#p/%d/note", pid); f = open(file, OWRITE); if(f < 0){ - sprint(file, "/proc/%d/note", pid); + jehanne_sprint(file, "/proc/%d/note", pid); f = open(file, OWRITE); } if(f < 0) - werrstr("postnote: cannot open neither #p/%d/note nor /proc/%d/note", pid, pid); + jehanne_werrstr("postnote: cannot open neither #p/%d/note nor /proc/%d/note", pid, pid); return f; } @@ -42,19 +42,19 @@ opengroupnotes(int pid) char file[128]; int32_t f; - sprint(file, "#p/%d/notepg", pid); + jehanne_sprint(file, "#p/%d/notepg", pid); f = open(file, OWRITE); if(f < 0){ - sprint(file, "/proc/%d/notepg", pid); + jehanne_sprint(file, "/proc/%d/notepg", pid); f = open(file, OWRITE); } if(f < 0) - werrstr("postnote: cannot open neither #p/%d/notepg nor /proc/%d/notepg", pid, pid); + jehanne_werrstr("postnote: cannot open neither #p/%d/notepg nor /proc/%d/notepg", pid, pid); return f; } int -postnote(int group, int pid, const char *note) +jehanne_postnote(int group, int pid, const char *note) { int f, r; @@ -66,13 +66,13 @@ postnote(int group, int pid, const char *note) f = opengroupnotes(pid); break; default: - werrstr("postnote: invalid group flag %d", group); + jehanne_werrstr("postnote: invalid group flag %d", group); return -1; } if(f < 0) return f; - r = strlen(note); + r = jehanne_strlen(note); if(write(f, note, r) != r) { close(f); return -1; diff --git a/sys/src/lib/c/9sys/privalloc.c b/sys/src/lib/c/9sys/privalloc.c index 3117ffc..921628a 100644 --- a/sys/src/lib/c/9sys/privalloc.c +++ b/sys/src/lib/c/9sys/privalloc.c @@ -7,16 +7,16 @@ extern void **_privates; extern int _nprivates; void ** -privalloc(void) +jehanne_privalloc(void) { void **p; - lock(&privlock); + jehanne_lock(&privlock); if(_nprivates > 0) p = &_privates[--_nprivates]; else p = nil; - unlock(&privlock); + jehanne_unlock(&privlock); return p; } diff --git a/sys/src/lib/c/9sys/pushssl.c b/sys/src/lib/c/9sys/pushssl.c index 3f2b2c8..bc7ce04 100644 --- a/sys/src/lib/c/9sys/pushssl.c +++ b/sys/src/lib/c/9sys/pushssl.c @@ -17,7 +17,7 @@ */ int -pushssl(int fd, const char *alg, const char *secin, const char *secout, int *cfd) +jehanne_pushssl(int fd, const char *alg, const char *secin, const char *secout, int *cfd) { char buf[8]; char dname[64]; @@ -30,14 +30,14 @@ pushssl(int fd, const char *alg, const char *secin, const char *secout, int *cfd if(n < 0) goto error; buf[n] = 0; - sprint(dname, "#D/ssl/%s/data", buf); + jehanne_sprint(dname, "#D/ssl/%s/data", buf); data = open(dname, ORDWR); if(data < 0) goto error; - if(fprint(ctl, "fd %d", fd) < 0 || - fprint(ctl, "secretin %s", secin) < 0 || - fprint(ctl, "secretout %s", secout) < 0 || - fprint(ctl, "alg %s", alg) < 0){ + if(jehanne_fprint(ctl, "fd %d", fd) < 0 || + jehanne_fprint(ctl, "secretin %s", secin) < 0 || + jehanne_fprint(ctl, "secretout %s", secout) < 0 || + jehanne_fprint(ctl, "alg %s", alg) < 0){ close(data); goto error; } diff --git a/sys/src/lib/c/9sys/putenv.c b/sys/src/lib/c/9sys/putenv.c index 3d42a84..aa2f65a 100644 --- a/sys/src/lib/c/9sys/putenv.c +++ b/sys/src/lib/c/9sys/putenv.c @@ -20,7 +20,7 @@ #include int -putenv(const char *name, const char *value) +jehanne_putenv(const char *name, const char *value) { int f; int32_t l; @@ -30,25 +30,25 @@ putenv(const char *name, const char *value) assert(value != nil); if(name[0]=='\0') goto BadName; - if(strcmp(name, ".")==0 || strcmp(name, "..")==0) + if(jehanne_strcmp(name, ".")==0 || jehanne_strcmp(name, "..")==0) goto BadName; - if(strchr(name, '/')!=nil) + if(jehanne_strchr(name, '/')!=nil) goto BadName; - snprint(path, sizeof path, "/env/%s", name); - if(strcmp(path+5, name) != 0) + jehanne_snprint(path, sizeof path, "/env/%s", name); + if(jehanne_strcmp(path+5, name) != 0) goto BadName; - f = ocreate(path, OWRITE, 0664); + f = jehanne_ocreate(path, OWRITE, 0664); if(f < 0){ /* try with #e, in case of a previous rfork(RFCNAMEG) */ - snprint(path, sizeof path, "#e/%s", name); - f = ocreate(path, OWRITE, 0664); + jehanne_snprint(path, sizeof path, "#e/%s", name); + f = jehanne_ocreate(path, OWRITE, 0664); if(f < 0) return -1; } - l = strlen(value); + l = jehanne_strlen(value); if(l > 0 && write(f, value, l) != l){ close(f); return -1; @@ -57,6 +57,6 @@ putenv(const char *name, const char *value) return 0; BadName: - werrstr("bad env name: '%s'", name); + jehanne_werrstr("bad env name: '%s'", name); return -1; } diff --git a/sys/src/lib/c/9sys/qlock.c b/sys/src/lib/c/9sys/qlock.c index 127c2a4..3573132 100644 --- a/sys/src/lib/c/9sys/qlock.c +++ b/sys/src/lib/c/9sys/qlock.c @@ -83,19 +83,19 @@ debugrendezvous(void *tag, void *val) int i; if(pidp == nil) - pidp = privalloc(); + pidp = jehanne_privalloc(); if(*pidp == 0) - *pidp = (void*)(long)getpid(); + *pidp = (void*)(long)jehanne_getpid(); - i = ainc(&logidx) - 1; + i = jehanne_ainc(&logidx) - 1; logs[i].tag = tag; logs[i].pid = (long)*pidp; - logs[i].start = nsec(); + logs[i].start = jehanne_nsec(); logs[i].addr = __builtin_return_address(0); logs[i].caller = __builtin_return_address(1); logs[i].r = (void*)0xffabcdefffabcdef; logs[i].r = rendezvous(tag, (void*)logs[i].addr); - logs[i].end = nsec(); + logs[i].end = jehanne_nsec(); return logs[i].r; } void @@ -103,7 +103,7 @@ printdebugrendezvouslogs(void) { int i; for(i = 0; i < logidx; ++i) - print("[%d] %#p @ %#p rendezvous(%#p, %#p) -> %#p @ %#p\n", logs[i].pid, logs[i].caller, logs[i].start, logs[i].tag, logs[i].addr, logs[i].r, logs[i].end); + jehanne_print("[%d] %#p @ %#p rendezvous(%#p, %#p) -> %#p @ %#p\n", logs[i].pid, logs[i].caller, logs[i].start, logs[i].tag, logs[i].addr, logs[i].r, logs[i].end); } static void* (*_rendezvousp)(void*, void*) = debugrendezvous; #else @@ -118,7 +118,7 @@ static void* (*_rendezvousp)(void*, void*) = __rendezvous; /* this gets called by the thread library ONLY to get us to use its rendezvous */ void -_qlockinit(void* (*r)(void*, void*)) +jehanne__qlockinit(void* (*r)(void*, void*)) { _rendezvousp = r; } @@ -145,14 +145,14 @@ getqlp(uint8_t use) } void -qlock(QLock *q) +jehanne_qlock(QLock *q) { QLp *p, *mp; - lock(&q->lock); + jehanne_lock(&q->lock); if(!q->locked){ q->locked = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return; } @@ -165,32 +165,32 @@ qlock(QLock *q) else p->next = mp; q->tail = mp; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) ; if(mp->state != Done){ - print("mp %#p: state %d pc %#p\n", mp, mp->state, __builtin_return_address(0)); + jehanne_print("mp %#p: state %d pc %#p\n", mp, mp->state, __builtin_return_address(0)); abort(); } mp->state = Free; } void -qunlock(QLock *q) +jehanne_qunlock(QLock *q) { QLp *p; - lock(&q->lock); + jehanne_lock(&q->lock); if (q->locked == 0) - fprint(2, "qunlock called with qlock not held, from %#p\n", - getcallerpc()); + jehanne_fprint(2, "qunlock called with qlock not held, from %#p\n", + jehanne_getcallerpc()); p = q->head; while(p != nil && !cas(&p->state, Queuing, Done)){ /* the lock in p timed out */ if(p->state != Timedout){ - print("qunlock mp %#p: state %d (should be Timedout) pc %#p\n", p, p->state, (uintptr_t)__builtin_return_address(0)); + jehanne_print("qunlock mp %#p: state %d (should be Timedout) pc %#p\n", p, p->state, (uintptr_t)__builtin_return_address(0)); abort(); } p->state = Free; @@ -199,13 +199,13 @@ qunlock(QLock *q) if(p != nil){ /* wakeup head waiting process */ if(p->state != Done){ - print("qunlock: p %#p p->state %d\n", p, p->state); + jehanne_print("qunlock: p %#p p->state %d\n", p, p->state); abort(); } q->head = p->next; if(q->head == nil) q->tail = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); while((*_rendezvousp)(p, (void*)0x12345) == (void*)~0) ; return; @@ -215,11 +215,11 @@ qunlock(QLock *q) q->tail = nil; } q->locked = 0; - unlock(&q->lock); + jehanne_unlock(&q->lock); } int -qlockt(QLock *q, uint32_t ms) +jehanne_qlockt(QLock *q, uint32_t ms) { QLp *p, *mp; int64_t wkup; @@ -227,15 +227,15 @@ qlockt(QLock *q, uint32_t ms) /* set up awake to interrupt rendezvous */ wkup = awake(ms); - if(!lockt(&q->lock, ms)){ - forgivewkp(wkup); + if(!jehanne_lockt(&q->lock, ms)){ + jehanne_forgivewkp(wkup); return 0; } if(!q->locked){ - forgivewkp(wkup); + jehanne_forgivewkp(wkup); q->locked = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } @@ -248,11 +248,11 @@ qlockt(QLock *q, uint32_t ms) p->next = mp; q->tail = mp; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) - if (awakened(wkup)){ + if (jehanne_awakened(wkup)){ /* interrupted by awake */ if(cas(&mp->state, Queuing, Timedout)) /* if we can atomically mark the QLp @@ -264,7 +264,7 @@ qlockt(QLock *q, uint32_t ms) */ } - forgivewkp(wkup); + jehanne_forgivewkp(wkup); if(mp->state != Done) abort(); mp->state = Free; @@ -273,29 +273,29 @@ qlockt(QLock *q, uint32_t ms) } int -canqlock(QLock *q) +jehanne_canqlock(QLock *q) { - if(!canlock(&q->lock)) + if(!jehanne_canlock(&q->lock)) return 0; if(!q->locked){ q->locked = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } - unlock(&q->lock); + jehanne_unlock(&q->lock); return 0; } void -rlock(RWLock *q) +jehanne_rlock(RWLock *q) { QLp *p, *mp; - lock(&q->lock); + jehanne_lock(&q->lock); if(q->writer == 0 && q->head == nil){ /* no writer, go for it */ q->_readers++; - unlock(&q->lock); + jehanne_unlock(&q->lock); return; } @@ -307,7 +307,7 @@ rlock(RWLock *q) p->next = mp; q->tail = mp; mp->next = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait in kernel */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) @@ -318,7 +318,7 @@ rlock(RWLock *q) } int -rlockt(RWLock *q, uint32_t ms) +jehanne_rlockt(RWLock *q, uint32_t ms) { QLp *p, *mp; int64_t wkup; @@ -326,16 +326,16 @@ rlockt(RWLock *q, uint32_t ms) /* set up awake to interrupt rendezvous */ wkup = awake(ms); - if(!lockt(&q->lock, ms)) { - forgivewkp(wkup); + if(!jehanne_lockt(&q->lock, ms)) { + jehanne_forgivewkp(wkup); return 0; } if(q->writer == 0 && q->head == nil){ /* no writer, go for it */ - forgivewkp(wkup); + jehanne_forgivewkp(wkup); q->_readers++; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } @@ -349,11 +349,11 @@ rlockt(RWLock *q, uint32_t ms) q->tail = mp; mp->next = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait in kernel */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) - if (awakened(wkup)){ + if (jehanne_awakened(wkup)){ /* interrupted by awake */ if(cas(&mp->state, QueuingR, Timedout)) /* if we can atomically mark the QLp @@ -365,7 +365,7 @@ rlockt(RWLock *q, uint32_t ms) */ } - forgivewkp(wkup); + jehanne_forgivewkp(wkup); if(mp->state != Done) abort(); mp->state = Free; @@ -374,31 +374,31 @@ rlockt(RWLock *q, uint32_t ms) } int -canrlock(RWLock *q) +jehanne_canrlock(RWLock *q) { - lock(&q->lock); + jehanne_lock(&q->lock); if (q->writer == 0 && q->head == nil) { /* no writer; go for it */ q->_readers++; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } - unlock(&q->lock); + jehanne_unlock(&q->lock); return 0; } void -runlock(RWLock *q) +jehanne_runlock(RWLock *q) { QLp *p; - lock(&q->lock); + jehanne_lock(&q->lock); if(q->_readers <= 0) abort(); p = q->head; if(--(q->_readers) > 0 || p == nil){ runlockWithoutWriters: - unlock(&q->lock); + jehanne_unlock(&q->lock); return; } @@ -422,7 +422,7 @@ runlockWithoutWriters: if(q->head == 0) q->tail = 0; q->writer = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wakeup waiter */ while((*_rendezvousp)(p, 0) == (void*)~0) @@ -430,15 +430,15 @@ runlockWithoutWriters: } void -wlock(RWLock *q) +jehanne_wlock(RWLock *q) { QLp *p, *mp; - lock(&q->lock); + jehanne_lock(&q->lock); if(q->_readers == 0 && q->writer == 0){ /* noone waiting, go for it */ q->writer = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return; } @@ -451,7 +451,7 @@ wlock(RWLock *q) p->next = mp; q->tail = mp; mp->next = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait in kernel */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) @@ -464,7 +464,7 @@ wlock(RWLock *q) int -wlockt(RWLock *q, uint32_t ms) +jehanne_wlockt(RWLock *q, uint32_t ms) { QLp *p, *mp; int64_t wkup; @@ -472,16 +472,16 @@ wlockt(RWLock *q, uint32_t ms) /* set up awake to interrupt rendezvous */ wkup = awake(ms); - if(!lockt(&q->lock, ms)) { - forgivewkp(wkup); + if(!jehanne_lockt(&q->lock, ms)) { + jehanne_forgivewkp(wkup); return 0; } if(q->_readers == 0 && q->writer == 0){ /* noone waiting, go for it */ - forgivewkp(wkup); + jehanne_forgivewkp(wkup); q->writer = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } @@ -495,11 +495,11 @@ wlockt(RWLock *q, uint32_t ms) q->tail = mp; mp->next = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); /* wait in kernel */ while((*_rendezvousp)(mp, (void*)1) == (void*)~0) - if (awakened(wkup)){ + if (jehanne_awakened(wkup)){ /* interrupted by awake */ if(cas(&mp->state, QueuingW, Timedout)) /* if we can atomically mark the QLp @@ -510,7 +510,7 @@ wlockt(RWLock *q, uint32_t ms) * on the next rendezvous from runlock/wunlock */ } - forgivewkp(wkup); + jehanne_forgivewkp(wkup); if(mp->state != Done) abort(); mp->state = Free; @@ -519,31 +519,31 @@ wlockt(RWLock *q, uint32_t ms) } int -canwlock(RWLock *q) +jehanne_canwlock(RWLock *q) { - lock(&q->lock); + jehanne_lock(&q->lock); if (q->_readers == 0 && q->writer == 0) { /* no one waiting; go for it */ q->writer = 1; - unlock(&q->lock); + jehanne_unlock(&q->lock); return 1; } - unlock(&q->lock); + jehanne_unlock(&q->lock); return 0; } void -wunlock(RWLock *q) +jehanne_wunlock(RWLock *q) { QLp *p, *tmp; - lock(&q->lock); + jehanne_lock(&q->lock); if(q->writer == 0) abort(); p = q->head; if(p == nil){ q->writer = 0; - unlock(&q->lock); + jehanne_unlock(&q->lock); return; } @@ -555,7 +555,7 @@ wakeupPendingWriter: /* when we jump here, we know p is not nil */ q->head = p->next; if(q->head == nil) q->tail = nil; - unlock(&q->lock); + jehanne_unlock(&q->lock); while((*_rendezvousp)(p, 0) == (void*)~0) ; return; @@ -568,7 +568,7 @@ wakeupPendingWriter: /* when we jump here, we know p is not nil */ /* wakeup pending readers */ goto wakeupPendingReaders; default: - print("wunlock: %#p has state %d instead of QueuingW\n", p, p->state); + jehanne_print("wunlock: %#p has state %d instead of QueuingW\n", p, p->state); abort(); break; } @@ -602,7 +602,7 @@ wakeupPendingReaders: /* when we jump here, we know p is not nil */ goto wakeupPendingWriter; } default: - print("wunlock: %#p has state %d instead of QueuingR\n", p, p->state); + jehanne_print("wunlock: %#p has state %d instead of QueuingR\n", p, p->state); abort(); break; } @@ -613,17 +613,17 @@ allPendingReadersStarted: if(q->head == nil) q->tail = nil; q->writer = 0; - unlock(&q->lock); + jehanne_unlock(&q->lock); } void -rsleep(Rendez *r) +jehanne_rsleep(Rendez *r) { QLp *t, *me; if(!r->l) abort(); - lock(&r->l->lock); + jehanne_lock(&r->l->lock); /* we should hold the qlock */ if(!r->l->locked) abort(); @@ -642,7 +642,7 @@ rsleep(Rendez *r) while(t != nil && !cas(&t->state, Queuing, Done)){ /* the lock in t timed out */ if(t->state != Timedout){ - print("rsleep mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); + jehanne_print("rsleep mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); abort(); } t->state = Free; @@ -652,14 +652,14 @@ rsleep(Rendez *r) r->l->head = t->next; if(r->l->head == nil) r->l->tail = nil; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); while((*_rendezvousp)(t, (void*)0x12345) == (void*)~0) ; }else{ r->l->head = nil; r->l->tail = nil; r->l->locked = 0; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); } /* wait for a wakeup */ @@ -671,7 +671,7 @@ rsleep(Rendez *r) } int -rsleept(Rendez *r, uint32_t ms) +jehanne_rsleept(Rendez *r, uint32_t ms) { QLp *t, *me; int64_t wkup; @@ -679,7 +679,7 @@ rsleept(Rendez *r, uint32_t ms) if(!r->l) abort(); - if(!lockt(&r->l->lock, ms)) + if(!jehanne_lockt(&r->l->lock, ms)) return 0; /* we should hold the qlock */ @@ -700,7 +700,7 @@ rsleept(Rendez *r, uint32_t ms) while(t != nil && !cas(&t->state, Queuing, Done)){ /* the lock in t timed out */ if(t->state != Timedout){ - print("rsleept mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); + jehanne_print("rsleept mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); abort(); } t->state = Free; @@ -710,7 +710,7 @@ rsleept(Rendez *r, uint32_t ms) r->l->head = t->next; if(r->l->head == nil) r->l->tail = nil; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); while((*_rendezvousp)(t, (void*)0x12345) == (void*)~0) ; @@ -718,7 +718,7 @@ rsleept(Rendez *r, uint32_t ms) r->l->head = nil; r->l->tail = nil; r->l->locked = 0; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); } /* set up awake to interrupt rendezvous */ @@ -726,12 +726,12 @@ rsleept(Rendez *r, uint32_t ms) /* wait for a rwakeup (or a timeout) */ while((*_rendezvousp)(me, (void*)1) == (void*)~0) - if (awakened(wkup)){ + if (jehanne_awakened(wkup)){ if(cas(&me->state, Sleeping, Timedout)){ /* if we can atomically mark the QLp * a future rwakeup will release it... */ - qlock(r->l); + jehanne_qlock(r->l); return 0; } /* ... otherwise we are going to take the lock @@ -739,7 +739,7 @@ rsleept(Rendez *r, uint32_t ms) */ } - forgivewkp(wkup); + jehanne_forgivewkp(wkup); if(me->state != Done) abort(); me->state = Free; @@ -748,7 +748,7 @@ rsleept(Rendez *r, uint32_t ms) } int -rwakeup(Rendez *r) +jehanne_rwakeup(Rendez *r) { QLp *t; @@ -759,7 +759,7 @@ rwakeup(Rendez *r) if(!r->l) abort(); - lock(&r->l->lock); + jehanne_lock(&r->l->lock); if(!r->l->locked) abort(); @@ -770,7 +770,7 @@ rwakeup(Rendez *r) while(t != nil && !cas(&t->state, Sleeping, Queuing)){ if(t->state != Timedout){ - print("rwakeup mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); + jehanne_print("rwakeup mp %#p: state %d (should be Timedout) pc %#p\n", t, t->state, __builtin_return_address(0)); abort(); } t->state = Free; @@ -779,7 +779,7 @@ rwakeup(Rendez *r) if(t == nil){ r->head = nil; r->tail = nil; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); return 0; } r->head = t->next; @@ -791,16 +791,16 @@ rwakeup(Rendez *r) if(r->l->tail == nil) r->l->tail = t; - unlock(&r->l->lock); + jehanne_unlock(&r->l->lock); return 1; } int -rwakeupall(Rendez *r) +jehanne_rwakeupall(Rendez *r) { int i; - for(i=0; rwakeup(r); i++) + for(i=0; jehanne_rwakeup(r); i++) ; return i; } diff --git a/sys/src/lib/c/9sys/rerrstr.c b/sys/src/lib/c/9sys/rerrstr.c index f5c3715..4bc1e8c 100644 --- a/sys/src/lib/c/9sys/rerrstr.c +++ b/sys/src/lib/c/9sys/rerrstr.c @@ -11,12 +11,12 @@ #include void -rerrstr(char *buf, uint32_t nbuf) +jehanne_rerrstr(char *buf, uint32_t nbuf) { char tmp[ERRMAX]; tmp[0] = 0; errstr(tmp, sizeof tmp); - utfecpy(buf, buf+nbuf, tmp); + jehanne_utfecpy(buf, buf+nbuf, tmp); errstr(tmp, sizeof tmp); } diff --git a/sys/src/lib/c/9sys/segattach.c b/sys/src/lib/c/9sys/segattach.c index af98ae1..14a5ea3 100644 --- a/sys/src/lib/c/9sys/segattach.c +++ b/sys/src/lib/c/9sys/segattach.c @@ -19,7 +19,7 @@ #include void* -segattach(int attr, const char *class, void *va, unsigned long len) +jehanne_segattach(int attr, const char *class, void *va, unsigned long len) { int fd; long tmp; @@ -29,14 +29,14 @@ segattach(int attr, const char *class, void *va, unsigned long len) if(fd < 0) return (void*)-1; - tmp = snprint(msg, sizeof(msg), "attach 0x%ux %#p %ulld %s", attr, va, len, class); + tmp = jehanne_snprint(msg, sizeof(msg), "attach 0x%ux %#p %ulld %s", attr, va, len, class); tmp = write(fd, msg, tmp); close(fd); return (void*)tmp; } int -segdetach(void *addr) +jehanne_segdetach(void *addr) { int fd, tmp; char msg[256]; @@ -45,14 +45,14 @@ segdetach(void *addr) if(fd < 0) return -1; - tmp = snprint(msg, sizeof(msg), "detach %#p", addr); + tmp = jehanne_snprint(msg, sizeof(msg), "detach %#p", addr); tmp = write(fd, msg, tmp); close(fd); return tmp; } int -segfree(void *addr, unsigned long len) +jehanne_segfree(void *addr, unsigned long len) { int fd, tmp; char msg[256]; @@ -61,7 +61,7 @@ segfree(void *addr, unsigned long len) if(fd < 0) return -1; - tmp = snprint(msg, sizeof(msg), "free %#p %ulld", addr, len); + tmp = jehanne_snprint(msg, sizeof(msg), "free %#p %ulld", addr, len); tmp = write(fd, msg, tmp); close(fd); return tmp; diff --git a/sys/src/lib/c/9sys/sbrk.c b/sys/src/lib/c/9sys/segbrk.c similarity index 96% rename from sys/src/lib/c/9sys/sbrk.c rename to sys/src/lib/c/9sys/segbrk.c index 220caff..cd3c9cf 100644 --- a/sys/src/lib/c/9sys/sbrk.c +++ b/sys/src/lib/c/9sys/segbrk.c @@ -36,7 +36,7 @@ setbrk(uintptr_t p) } int -brk(void *p) +jehanne_brk(void *p) { uintptr_t new_brk; @@ -48,7 +48,7 @@ brk(void *p) } void* -sbrk(uint32_t increment) +jehanne_segbrk(uint32_t increment) { uintptr_t new_brk; diff --git a/sys/src/lib/c/9sys/setnetmtpt.c b/sys/src/lib/c/9sys/setnetmtpt.c index 48f2cd2..7086ff1 100644 --- a/sys/src/lib/c/9sys/setnetmtpt.c +++ b/sys/src/lib/c/9sys/setnetmtpt.c @@ -11,15 +11,15 @@ #include void -setnetmtpt(char *net, int n, const char *x) +jehanne_setnetmtpt(char *net, int n, const char *x) { if(x == nil) x = "/net"; if(*x == '/'){ - strncpy(net, x, n); + jehanne_strncpy(net, x, n); net[n-1] = 0; } else { - snprint(net, n, "/net%s", x); + jehanne_snprint(net, n, "/net%s", x); } } diff --git a/sys/src/lib/c/9sys/sleep.c b/sys/src/lib/c/9sys/sleep.c index da17b0d..99fb541 100644 --- a/sys/src/lib/c/9sys/sleep.c +++ b/sys/src/lib/c/9sys/sleep.c @@ -20,13 +20,13 @@ #include void -sleep(int32_t millisecs) +jehanne_sleep(int32_t millisecs) { int64_t wakeup; wakeup = awake(millisecs); // give up the processor, in any case if(millisecs > 0) while(rendezvous(&wakeup, (void*)1) == (void*)~0) - if(awakened(wakeup)) + if(jehanne_awakened(wakeup)) return; } diff --git a/sys/src/lib/c/9sys/stat.c b/sys/src/lib/c/9sys/stat.c index d15a89a..deea76a 100644 --- a/sys/src/lib/c/9sys/stat.c +++ b/sys/src/lib/c/9sys/stat.c @@ -20,13 +20,13 @@ #include int -stat(const char* name, uint8_t* edir, int nedir) +jehanne_stat(const char* name, uint8_t* edir, int nedir) { int fd, statsz; fd = open(name, OSTAT); if(fd < 0){ - werrstr("stat: %r"); + jehanne_werrstr("stat: %r"); return fd; } statsz = fstat(fd, edir, nedir); @@ -35,13 +35,13 @@ stat(const char* name, uint8_t* edir, int nedir) } int -wstat(const char* name, uint8_t* edir, int nedir) +jehanne_wstat(const char* name, uint8_t* edir, int nedir) { int fd, statsz; fd = open(name, OSTAT); if(fd < 0){ - werrstr("wstat: %r"); + jehanne_werrstr("wstat: %r"); return fd; } statsz = fwstat(fd, edir, nedir); diff --git a/sys/src/lib/c/9sys/sysfatal.c b/sys/src/lib/c/9sys/sysfatal.c index f297f29..d6d652a 100644 --- a/sys/src/lib/c/9sys/sysfatal.c +++ b/sys/src/lib/c/9sys/sysfatal.c @@ -16,18 +16,18 @@ _sysfatalimpl(const char *fmt, va_list arg) { char buf[1024]; - vseprint(buf, buf+sizeof(buf), fmt, arg); + jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg); if(argv0) - fprint(2, "%s: %s\n", argv0, buf); + jehanne_fprint(2, "%s: %s\n", argv0, buf); else - fprint(2, "%s\n", buf); - exits(buf); + jehanne_fprint(2, "%s\n", buf); + jehanne_exits(buf); } void (*_sysfatal)(const char *fmt, va_list arg) = _sysfatalimpl; void -sysfatal(const char *fmt, ...) +jehanne_sysfatal(const char *fmt, ...) { va_list arg; diff --git a/sys/src/lib/c/9sys/syslog.c b/sys/src/lib/c/9sys/syslog.c index 196f479..3f6de4a 100644 --- a/sys/src/lib/c/9sys/syslog.c +++ b/sys/src/lib/c/9sys/syslog.c @@ -30,7 +30,7 @@ _syslogopen(void) if(sl.fd >= 0) close(sl.fd); - snprint(buf, sizeof(buf), "/sys/log/%s", sl.name); + jehanne_snprint(buf, sizeof(buf), "/sys/log/%s", sl.name); sl.fd = open(buf, OWRITE|OCEXEC); } @@ -49,7 +49,7 @@ eqdirdev(Dir *a, Dir *b) * If cons or log file can't be opened, print on the system console, too. */ void -syslog(int cons, const char *logname, const char *fmt, ...) +jehanne_syslog(int cons, const char *logname, const char *fmt, ...) { char buf[1024]; char *ctim, *p; @@ -60,55 +60,55 @@ syslog(int cons, const char *logname, const char *fmt, ...) err[0] = '\0'; errstr(err, sizeof err); - lock(&sl); + jehanne_lock(&sl); /* * paranoia makes us stat to make sure a fork+close * hasn't broken our fd's */ - d = dirfstat(sl.fd); - if(sl.fd < 0 || sl.name == nil || strcmp(sl.name, logname) != 0 || + d = jehanne_dirfstat(sl.fd); + if(sl.fd < 0 || sl.name == nil || jehanne_strcmp(sl.name, logname) != 0 || !eqdirdev(d, sl.d)){ - free(sl.name); - sl.name = strdup(logname); + jehanne_free(sl.name); + sl.name = jehanne_strdup(logname); if(sl.name == nil) cons = 1; else{ - free(sl.d); + jehanne_free(sl.d); sl.d = nil; _syslogopen(); if(sl.fd < 0) cons = 1; else - sl.d = dirfstat(sl.fd); + sl.d = jehanne_dirfstat(sl.fd); } } - free(d); + jehanne_free(d); if(cons){ - d = dirfstat(sl.consfd); + d = jehanne_dirfstat(sl.consfd); if(sl.consfd < 0 || !eqdirdev(d, sl.consd)){ - free(sl.consd); + jehanne_free(sl.consd); sl.consd = nil; sl.consfd = open("#c/cons", OWRITE|OCEXEC); if(sl.consfd >= 0) - sl.consd = dirfstat(sl.consfd); + sl.consd = jehanne_dirfstat(sl.consfd); } - free(d); + jehanne_free(d); } if(fmt == nil){ - unlock(&sl); + jehanne_unlock(&sl); return; } - ctim = ctime(time(0)); - p = buf + snprint(buf, sizeof(buf)-1, "%s ", sysname()); - strncpy(p, ctim+4, 15); + ctim = jehanne_ctime(jehanne_time(0)); + p = buf + jehanne_snprint(buf, sizeof(buf)-1, "%s ", jehanne_sysname()); + jehanne_strncpy(p, ctim+4, 15); p += 15; *p++ = ' '; errstr(err, sizeof err); va_start(arg, fmt); - p = vseprint(p, buf+sizeof(buf)-1, fmt, arg); + p = jehanne_vseprint(p, buf+sizeof(buf)-1, fmt, arg); va_end(arg); *p++ = '\n'; n = p - buf; @@ -121,5 +121,5 @@ syslog(int cons, const char *logname, const char *fmt, ...) if(cons && sl.consfd >=0) write(sl.consfd, buf, n); - unlock(&sl); + jehanne_unlock(&sl); } diff --git a/sys/src/lib/c/9sys/sysname.c b/sys/src/lib/c/9sys/sysname.c index 1a28bc2..3f2b60e 100644 --- a/sys/src/lib/c/9sys/sysname.c +++ b/sys/src/lib/c/9sys/sysname.c @@ -11,7 +11,7 @@ #include char* -sysname(void) +jehanne_sysname(void) { int f, n; static char b[128]; diff --git a/sys/src/lib/c/9sys/time.c b/sys/src/lib/c/9sys/time.c index 4730581..4782207 100644 --- a/sys/src/lib/c/9sys/time.c +++ b/sys/src/lib/c/9sys/time.c @@ -11,11 +11,11 @@ #include int32_t -time(int32_t *tp) +jehanne_time(int32_t *tp) { int64_t t; - t = nsec()/1000000000LL; + t = jehanne_nsec()/1000000000LL; if(tp != nil) *tp = t; return t; diff --git a/sys/src/lib/c/9sys/times.c b/sys/src/lib/c/9sys/times.c index 8bc4e75..a04308e 100644 --- a/sys/src/lib/c/9sys/times.c +++ b/sys/src/lib/c/9sys/times.c @@ -30,14 +30,14 @@ skip(char *p) * in the middle of this routine. */ int32_t -times(int32_t *t) +jehanne_times(int32_t *t) { char b[200], *p; static int f = -1; int i, retries; uint32_t r; - memset(b, 0, sizeof(b)); + jehanne_memset(b, 0, sizeof(b)); for(retries = 0; retries < 100; retries++){ if(f < 0) f = open("/dev/cputime", OREAD|OCEXEC); @@ -53,17 +53,17 @@ times(int32_t *t) } p = b; if(t) - t[0] = atol(p); + t[0] = jehanne_atol(p); p = skip(p); if(t) - t[1] = atol(p); + t[1] = jehanne_atol(p); p = skip(p); - r = atol(p); + r = jehanne_atol(p); if(t){ p = skip(p); - t[2] = atol(p); + t[2] = jehanne_atol(p); p = skip(p); - t[3] = atol(p); + t[3] = jehanne_atol(p); } return r; } diff --git a/sys/src/lib/c/9sys/tm2sec.c b/sys/src/lib/c/9sys/tm2sec.c index 301ac5b..6b8e915 100644 --- a/sys/src/lib/c/9sys/tm2sec.c +++ b/sys/src/lib/c/9sys/tm2sec.c @@ -57,12 +57,12 @@ yrsize(int y) * and convert to our timezone. */ int32_t -tm2sec(Tm *tm) +jehanne_tm2sec(Tm *tm) { int32_t secs; int i, yday, year, *d2m; - if(strcmp(tm->zone, "GMT") != 0 && timezone.stname[0] == 0) + if(jehanne_strcmp(tm->zone, "GMT") != 0 && timezone.stname[0] == 0) readtimezone(); secs = 0; @@ -100,9 +100,9 @@ tm2sec(Tm *tm) * Only handles zones mentioned in /env/timezone, * but things get too ambiguous otherwise. */ - if(strcmp(tm->zone, timezone.stname) == 0) + if(jehanne_strcmp(tm->zone, timezone.stname) == 0) secs -= timezone.stdiff; - else if(strcmp(tm->zone, timezone.dlname) == 0) + else if(jehanne_strcmp(tm->zone, timezone.dlname) == 0) secs -= timezone.dldiff; if(secs < 0) secs = 0; @@ -116,7 +116,7 @@ readtimezone(void) char buf[TZSIZE*11+30], *p; int i; - memset(buf, 0, sizeof(buf)); + jehanne_memset(buf, 0, sizeof(buf)); i = open("/env/timezone", OREAD); if(i < 0) goto error; @@ -143,7 +143,7 @@ readtimezone(void) error: timezone.stdiff = 0; - strcpy(timezone.stname, "GMT"); + jehanne_strcpy(timezone.stname, "GMT"); timezone.dlpairs[0] = 0; } diff --git a/sys/src/lib/c/9sys/truerand.c b/sys/src/lib/c/9sys/truerand.c index f3c0e88..1d8b411 100644 --- a/sys/src/lib/c/9sys/truerand.c +++ b/sys/src/lib/c/9sys/truerand.c @@ -11,7 +11,7 @@ #include uint32_t -truerand(void) +jehanne_truerand(void) { uint32_t x; static int randfd = -1; @@ -19,8 +19,8 @@ truerand(void) if(randfd < 0) randfd = open("/dev/random", OREAD|OCEXEC); if(randfd < 0) - sysfatal("can't open /dev/random"); + jehanne_sysfatal("can't open /dev/random"); if(read(randfd, &x, sizeof(x)) != sizeof(x)) - sysfatal("can't read /dev/random"); + jehanne_sysfatal("can't read /dev/random"); return x; } diff --git a/sys/src/lib/c/9sys/wait.c b/sys/src/lib/c/9sys/wait.c index b60a930..e3dfe61 100644 --- a/sys/src/lib/c/9sys/wait.c +++ b/sys/src/lib/c/9sys/wait.c @@ -12,7 +12,7 @@ #include <9P2000.h> Waitmsg* -wait(void) +jehanne_wait(void) { int n, l; char buf[512], *fld[5]; @@ -22,20 +22,20 @@ wait(void) if(n < 0) return nil; buf[n] = '\0'; - if(tokenize(buf, fld, nelem(fld)) != nelem(fld)){ - werrstr("couldn't parse wait message"); + if(jehanne_tokenize(buf, fld, nelem(fld)) != nelem(fld)){ + jehanne_werrstr("couldn't parse wait message"); return nil; } - l = strlen(fld[4])+1; - w = malloc(sizeof(Waitmsg)+l); + l = jehanne_strlen(fld[4])+1; + w = jehanne_malloc(sizeof(Waitmsg)+l); if(w == nil) return nil; - w->pid = atoi(fld[0]); - w->time[0] = atoi(fld[1]); - w->time[1] = atoi(fld[2]); - w->time[2] = atoi(fld[3]); + w->pid = jehanne_atoi(fld[0]); + w->time[0] = jehanne_atoi(fld[1]); + w->time[1] = jehanne_atoi(fld[2]); + w->time[2] = jehanne_atoi(fld[3]); w->msg = (char*)&w[1]; - memmove(w->msg, fld[4], l); + jehanne_memmove(w->msg, fld[4], l); return w; } diff --git a/sys/src/lib/c/9sys/waitpid.c b/sys/src/lib/c/9sys/waitpid.c index 95f9d6a..1bc8133 100644 --- a/sys/src/lib/c/9sys/waitpid.c +++ b/sys/src/lib/c/9sys/waitpid.c @@ -12,7 +12,7 @@ #include <9P2000.h> int -waitpid(void) +jehanne_waitpid(void) { int n; char buf[512], *fld[5]; @@ -21,10 +21,10 @@ waitpid(void) if(n <= 0) return -1; buf[n] = '\0'; - if(tokenize(buf, fld, nelem(fld)) != nelem(fld)){ - werrstr("couldn't parse wait message"); + if(jehanne_tokenize(buf, fld, nelem(fld)) != nelem(fld)){ + jehanne_werrstr("couldn't parse wait message"); return -1; } - return atoi(fld[0]); + return jehanne_atoi(fld[0]); } diff --git a/sys/src/lib/c/9sys/werrstr.c b/sys/src/lib/c/9sys/werrstr.c index f62b28a..e17ba39 100644 --- a/sys/src/lib/c/9sys/werrstr.c +++ b/sys/src/lib/c/9sys/werrstr.c @@ -11,13 +11,13 @@ #include void -werrstr(const char *fmt, ...) +jehanne_werrstr(const char *fmt, ...) { va_list arg; char buf[ERRMAX]; va_start(arg, fmt); - vseprint(buf, buf+ERRMAX, fmt, arg); + jehanne_vseprint(buf, buf+ERRMAX, fmt, arg); va_end(arg); errstr(buf, ERRMAX); } diff --git a/sys/src/lib/c/amd64/atom.s b/sys/src/lib/c/amd64/atom.s index b4c9fb5..d182c9e 100644 --- a/sys/src/lib/c/amd64/atom.s +++ b/sys/src/lib/c/amd64/atom.s @@ -1,8 +1,8 @@ .text -.globl ainc /* long ainc(long *); */ +.globl jehanne_ainc /* long ainc(long *); */ /* N.B.: long in Plan 9 is 32 BITS! */ -ainc: +jehanne_ainc: pushq %rcx ainclp: @@ -15,8 +15,8 @@ ainclp: popq %rcx ret -.globl adec /* long adec(long*); */ -adec: +.globl jehanne_adec /* long adec(long*); */ +jehanne_adec: pushq %rcx adeclp: movl (%rdi), %eax @@ -31,8 +31,8 @@ adeclp: /* * void mfence(void); */ -.globl mfence -mfence: +.globl jehanne_mfence +jehanne_mfence: mfence ret diff --git a/sys/src/lib/c/amd64/crt0.s b/sys/src/lib/c/amd64/crt0.s index d99f4ce..7d04063 100644 --- a/sys/src/lib/c/amd64/crt0.s +++ b/sys/src/lib/c/amd64/crt0.s @@ -29,17 +29,6 @@ _main: /* set _mainpid */ movl %r12d, _mainpid - /* setup _privates */ - movq $-(8*16), _privates /* sizeof(void*) * NPRIVATES */ - addq %rsp, _privates - movl $16, _nprivates /* NPRIVATES */ - leaq -128(%rsp), %rsp /* space for _privates */ - - /* setup _sysargs */ - movq $-(8*6), _sysargs /* sizeof(long) * MAX SYS ARGS */ - addq %rsp, _sysargs - leaq -48(%rsp), %rsp /* space for _sysargs */ - movq %rsp, %rbp pushq %rsi pushq %rdi @@ -47,14 +36,6 @@ _main: popq %rdi popq %rsi - call main + call __jehanne_libc_init -loop: - movq $_exits, %rdi - call exits - jmp loop .size _main,.-_main - -.data -_exits: - .ascii "main" diff --git a/sys/src/lib/c/amd64/getfcr.s b/sys/src/lib/c/amd64/getfcr.s index 8f77814..b044b43 100644 --- a/sys/src/lib/c/amd64/getfcr.s +++ b/sys/src/lib/c/amd64/getfcr.s @@ -18,8 +18,8 @@ .text -.globl setfcr -setfcr: +.globl jehanne_setfcr +jehanne_setfcr: xor $(0x3F<<7), %edi and $0xFFC0, %edi wait @@ -31,8 +31,8 @@ setfcr: ldmxcsr -8(%rsp) ret -.globl getfcr -getfcr: +.globl jehanne_getfcr +jehanne_getfcr: wait stmxcsr -8(%rsp) movzx -8(%rsp), %ax @@ -40,15 +40,16 @@ getfcr: xorl $(0x3F<<7), %eax ret -.globl getfsr +.globl jehanne_getfsr +jehanne_getfsr: wait stmxcsr -8(%rsp) mov -8(%rsp), %eax and $0x3F, %eax RET -.globl setfsr -setfsr: +.globl jehanne_setfsr +jehanne_setfsr: and $0x3F, %edi wait stmxcsr -8(%rsp) diff --git a/sys/src/lib/c/amd64/initlib.c b/sys/src/lib/c/amd64/initlib.c new file mode 100644 index 0000000..d8ce9d1 --- /dev/null +++ b/sys/src/lib/c/amd64/initlib.c @@ -0,0 +1,51 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#include +#include + +extern void **_privates; +extern int _nprivates; + +static void call_main(int argc, char *argv[]) __attribute__((noreturn)); + +void +__jehanne_libc_init(int argc, char *argv[]) +{ + /* Initialize per process structures on the stack */ + void *privates[NPRIVATES]; + NativeTypes sysargs[6]; + + _nprivates = NPRIVATES; + for(_nprivates = 0; _nprivates < NPRIVATES; ++_nprivates) + privates[_nprivates] = nil; + _privates = privates; + _sysargs = &sysargs[0]; + + if(__libc_init != nil) + __libc_init(argc, argv); + call_main(argc, argv); +} + +static void +call_main(int argc, char *argv[]) +{ + extern void main(int argc, char *argv[]); + + main(argc, argv); + jehanne_exits("main"); +} diff --git a/sys/src/lib/c/amd64/notejmp.c b/sys/src/lib/c/amd64/notejmp.c index 05b7a0e..063cfd1 100644 --- a/sys/src/lib/c/amd64/notejmp.c +++ b/sys/src/lib/c/amd64/notejmp.c @@ -3,7 +3,7 @@ #include void -notejmp(void *vr, jmp_buf j, int ret) +jehanne_notejmp(void *vr, jmp_buf j, int ret) { struct Ureg *r = vr; diff --git a/sys/src/lib/c/amd64/setjmp.s b/sys/src/lib/c/amd64/setjmp.s index bc7113a..0fe27fb 100644 --- a/sys/src/lib/c/amd64/setjmp.s +++ b/sys/src/lib/c/amd64/setjmp.s @@ -1,7 +1,7 @@ .text -.globl longjmp -longjmp: +.globl jehanne_longjmp +jehanne_longjmp: movq %rdi, %r9 movq 0(%r9), %rbx movq 8(%r9), %r12 @@ -24,8 +24,8 @@ longjmp: jmp *%r8 -.globl setjmp -setjmp: +.globl jehanne_setjmp +jehanne_setjmp: movq %rbx, 0(%rdi) movq %r12, 8(%rdi) movq %r13, 16(%rdi) diff --git a/sys/src/lib/c/amd64/sqrt.s b/sys/src/lib/c/amd64/sqrt.s index ab520b8..e721375 100644 --- a/sys/src/lib/c/amd64/sqrt.s +++ b/sys/src/lib/c/amd64/sqrt.s @@ -1,5 +1,5 @@ -.globl sqrt -sqrt: +.globl jehanne_sqrt +jehanne_sqrt: sqrtsd %xmm0, %xmm0 ret diff --git a/sys/src/lib/c/amd64/tas.s b/sys/src/lib/c/amd64/tas.s index 7c9d388..71da8ad 100644 --- a/sys/src/lib/c/amd64/tas.s +++ b/sys/src/lib/c/amd64/tas.s @@ -2,8 +2,8 @@ * The kernel and the libc use the same constant for TAS */ .text -.globl _tas -_tas: +.globl jehanne__tas +jehanne__tas: movl $0xdeaddead, %eax xchgl %eax, 0(%rdi) /* lock->key */ ret diff --git a/sys/src/lib/c/apw/eprintf.c b/sys/src/lib/c/apw/eprintf.c index 602a159..58414e6 100644 --- a/sys/src/lib/c/apw/eprintf.c +++ b/sys/src/lib/c/apw/eprintf.c @@ -20,6 +20,6 @@ void __eprintf(const char *format, const char *file, unsigned int line, const char *expression) { - fprint(2, format, file, line, expression); + jehanne_fprint(2, format, file, line, expression); abort(); } diff --git a/sys/src/lib/c/apw/exit.c b/sys/src/lib/c/apw/exit.c index 7600730..b84e3e5 100644 --- a/sys/src/lib/c/apw/exit.c +++ b/sys/src/lib/c/apw/exit.c @@ -21,6 +21,6 @@ void exit(int status) { if(status == EXIT_SUCCESS) - exits(nil); - exits(smprint(__POSIX_EXIT_PREFIX "%d", status)); + jehanne_exits(nil); + jehanne_exits(jehanne_smprint(__POSIX_EXIT_PREFIX "%d", status)); } diff --git a/sys/src/lib/c/apw/system.c b/sys/src/lib/c/apw/system.c index a6b8e7c..6e50da3 100644 --- a/sys/src/lib/c/apw/system.c +++ b/sys/src/lib/c/apw/system.c @@ -25,29 +25,29 @@ system(const char *command) int ret = 0; char *s = nil; if(command == nil) - return access("/cmd/rc", AEXEC) == 0; + return jehanne_access("/cmd/rc", AEXEC) == 0; switch(pid = rfork(RFFDG|RFREND|RFPROC|RFENVG|RFNOTEG)){ case -1: return -1; case 0: - execl("/cmd/rc", "rc", "-c", command, nil); - sysfatal("execl returned"); + jehanne_execl("/cmd/rc", "rc", "-c", command, nil); + jehanne_sysfatal("execl returned"); return -1; default: // TODO: fix this http://man7.org/linux/man-pages/man3/system.3.html - while((w = wait()) && w->pid != pid) - free(w); + while((w = jehanne_wait()) && w->pid != pid) + jehanne_free(w); if(w == nil) return -1; if(w->msg[0] != 0){ - s = strstr(w->msg, __POSIX_EXIT_PREFIX); + s = jehanne_strstr(w->msg, __POSIX_EXIT_PREFIX); if(s){ s += (sizeof(__POSIX_EXIT_PREFIX)/sizeof(char) - 1); - ret = atoi(s); + ret = jehanne_atoi(s); } else ret = 127; } - free(w); + jehanne_free(w); return ret; } diff --git a/sys/src/lib/c/build.json b/sys/src/lib/c/build.json index 272c570..326bcf8 100644 --- a/sys/src/lib/c/build.json +++ b/sys/src/lib/c/build.json @@ -68,7 +68,7 @@ "9sys/qlock.c", "9sys/read.c", "9sys/rerrstr.c", - "9sys/sbrk.c", + "9sys/segbrk.c", "9sys/segattach.c", "9sys/setnetmtpt.c", "9sys/sleep.c", @@ -226,6 +226,7 @@ "port/u16.c", "port/u32.c", "port/u64.c", + "$ARCH/initlib.c", "$ARCH/syscalls.c", "$ARCH/notejmp.c", "$ARCH/cycles.c", diff --git a/sys/src/lib/c/fmt/dofmt.c b/sys/src/lib/c/fmt/dofmt.c index 0c51a02..66d9cea 100644 --- a/sys/src/lib/c/fmt/dofmt.c +++ b/sys/src/lib/c/fmt/dofmt.c @@ -13,7 +13,7 @@ /* format the output into f->to and return the number of characters fmted */ int -dofmt(Fmt *f, const char *fmt) +jehanne_dofmt(Fmt *f, const char *fmt) { Rune rune, *rt, *rs; int r; @@ -29,7 +29,7 @@ dofmt(Fmt *f, const char *fmt) if(r < Runeself) fmt++; else{ - fmt += chartorune(&rune, fmt); + fmt += jehanne_chartorune(&rune, fmt); r = rune; } FMTRCHAR(f, rt, rs, r); @@ -48,7 +48,7 @@ dofmt(Fmt *f, const char *fmt) FMTCHAR(f, t, s, r); fmt++; }else{ - n = chartorune(&rune, fmt); + n = jehanne_chartorune(&rune, fmt); if(t + n > s){ t = _fmtflush(f, t, n); if(t != nil) @@ -147,8 +147,8 @@ _fmtcpy(Fmt *f, const void *vm, int n, int sz) r = *(uint8_t*)m; if(r < Runeself) m++; - else if((me - m) >= UTFmax || fullrune(m, me-m)) - m += chartorune(&r, m); + else if((me - m) >= UTFmax || jehanne_fullrune(m, me-m)) + m += jehanne_chartorune(&r, m); else break; FMTRCHAR(f, rt, rs, r); @@ -166,8 +166,8 @@ _fmtcpy(Fmt *f, const void *vm, int n, int sz) r = *(uint8_t*)m; if(r < Runeself) m++; - else if((me - m) >= UTFmax || fullrune(m, me-m)) - m += chartorune(&r, m); + else if((me - m) >= UTFmax || jehanne_fullrune(m, me-m)) + m += jehanne_chartorune(&r, m); else break; FMTRUNE(f, t, s, r); @@ -245,7 +245,7 @@ _runefmt(Fmt *f) /* public helper routine: fmt out a null terminated string already in hand */ int -fmtstrcpy(Fmt *f, const char *s) +jehanne_fmtstrcpy(Fmt *f, const char *s) { int i, j; Rune r; @@ -256,10 +256,10 @@ fmtstrcpy(Fmt *f, const char *s) if(f->flags & FmtPrec){ i = 0; for(j=0; jprec && s[i]; j++) - i += chartorune(&r, s+i); + i += jehanne_chartorune(&r, s+i); return _fmtcpy(f, s, j, i); } - return _fmtcpy(f, s, utflen(s), strlen(s)); + return _fmtcpy(f, s, jehanne_utflen(s), jehanne_strlen(s)); } /* fmt out a null terminated utf string */ @@ -269,12 +269,12 @@ _strfmt(Fmt *f) char *s; s = va_arg(f->args, char *); - return fmtstrcpy(f, s); + return jehanne_fmtstrcpy(f, s); } /* public helper routine: fmt out a null terminated rune string already in hand */ int -fmtrunestrcpy(Fmt *f, const Rune *s) +jehanne_fmtrunestrcpy(Fmt *f, const Rune *s) { const Rune *e; int n, p; @@ -302,7 +302,7 @@ _runesfmt(Fmt *f) Rune *s; s = va_arg(f->args, Rune *); - return fmtrunestrcpy(f, s); + return jehanne_fmtrunestrcpy(f, s); } /* fmt a % */ diff --git a/sys/src/lib/c/fmt/dorfmt.c b/sys/src/lib/c/fmt/dorfmt.c index 2d96c22..f94dc8f 100644 --- a/sys/src/lib/c/fmt/dorfmt.c +++ b/sys/src/lib/c/fmt/dorfmt.c @@ -14,7 +14,7 @@ /* format the output into f->to and return the number of characters fmted */ int -dorfmt(Fmt *f, const Rune *fmt) +jehanne_dorfmt(Fmt *f, const Rune *fmt) { Rune *rt, *rs; int r; diff --git a/sys/src/lib/c/fmt/errfmt.c b/sys/src/lib/c/fmt/errfmt.c index 0cef0ea..8f5d02a 100644 --- a/sys/src/lib/c/fmt/errfmt.c +++ b/sys/src/lib/c/fmt/errfmt.c @@ -12,13 +12,13 @@ #include "fmtdef.h" int -errfmt(Fmt *f) +jehanne_errfmt(Fmt *f) { #if __STDC_HOSTED__ char buf[ERRMAX+1]; - rerrstr(buf, ERRMAX); - return _fmtcpy(f, buf, utflen(buf), strlen(buf)); + jehanne_rerrstr(buf, ERRMAX); + return _fmtcpy(f, buf, jehanne_utflen(buf), jehanne_strlen(buf)); #else extern void panic(char *fmt, ...) __attribute__ ((noreturn)); panic("No errfmt in kernel"); diff --git a/sys/src/lib/c/fmt/fltfmt.c b/sys/src/lib/c/fmt/fltfmt.c index bc320a1..5c8f5fb 100644 --- a/sys/src/lib/c/fmt/fltfmt.c +++ b/sys/src/lib/c/fmt/fltfmt.c @@ -73,16 +73,16 @@ xdtoa(Fmt *fmt, char *s2, double f) prec = fmt->prec; if(prec > FDIGIT) prec = FDIGIT; - if(isNaN(f)) { - strcpy(s2, "NaN"); + if(jehanne_isNaN(f)) { + jehanne_strcpy(s2, "NaN"); return; } - if(isInf(f, 1)) { - strcpy(s2, "+Inf"); + if(jehanne_isInf(f, 1)) { + jehanne_strcpy(s2, "+Inf"); return; } - if(isInf(f, -1)) { - strcpy(s2, "-Inf"); + if(jehanne_isInf(f, -1)) { + jehanne_strcpy(s2, "-Inf"); return; } sign = 0; @@ -94,29 +94,29 @@ xdtoa(Fmt *fmt, char *s2, double f) chr = fmt->r; if(isupper(chr)) { ucase = 1; - chr = tolower(chr); + chr = jehanne_tolower(chr); } e = 0; g = f; if(g != 0) { - frexp(f, &e); + jehanne_frexp(f, &e); e = e * .301029995664; if(e >= -150 && e <= +150) { d = 0; h = f; } else { d = e/2; - h = f * pow10(-d); + h = f * jehanne_pow10(-d); } - g = h * pow10(d-e); + g = h * jehanne_pow10(d-e); while(g < 1) { e--; - g = h * pow10(d-e); + g = h * jehanne_pow10(d-e); } while(g >= 10) { e++; - g = h * pow10(d-e); + g = h * jehanne_pow10(d-e); } } @@ -138,22 +138,22 @@ xdtoa(Fmt *fmt, char *s2, double f) if(chr == 'f') c2 += e; if(c2 >= NSIGNIF-2) { - strcpy(s2, s1); + jehanne_strcpy(s2, s1); d = e; s1[NSIGNIF-2] = '0'; s1[NSIGNIF-1] = '0'; - sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); - g = strtod(s1, nil); + jehanne_sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); + g = jehanne_strtod(s1, nil); if(g == f) goto found; if(xadd(s1, NSIGNIF-3, 1)) { e++; - sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); + jehanne_sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); } - g = strtod(s1, nil); + g = jehanne_strtod(s1, nil); if(g == f) goto found; - strcpy(s1, s2); + jehanne_strcpy(s1, s2); e = d; } @@ -161,8 +161,8 @@ xdtoa(Fmt *fmt, char *s2, double f) * convert back so s1 gets exact answer */ for(;;) { - sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); - g = strtod(s1, nil); + jehanne_sprint(s1+NSIGNIF, "e%d", e-NSIGNIF+1); + g = jehanne_strtod(s1, nil); if(f > g) { if(xadd(s1, NSIGNIF-1, 1)) e--; @@ -313,7 +313,7 @@ _floatfmt(Fmt *fmt, double f) */ xdtoa(fmt, s, f); fmt->flags &= FmtWidth|FmtLeft; - _fmtcpy(fmt, s, strlen(s), strlen(s)); + _fmtcpy(fmt, s, jehanne_strlen(s), jehanne_strlen(s)); return 0; } diff --git a/sys/src/lib/c/fmt/fmt.c b/sys/src/lib/c/fmt/fmt.c index afeb3a9..e623db2 100644 --- a/sys/src/lib/c/fmt/fmt.c +++ b/sys/src/lib/c/fmt/fmt.c @@ -53,7 +53,7 @@ static Convfmt knownfmt[] = { 'n', _countfmt, 'o', _ifmt, 'p', _ifmt, - 'r', errfmt, + 'r', jehanne_errfmt, 's', _strfmt, 'u', _flagfmt, 'x', _ifmt, @@ -93,7 +93,7 @@ _fmtinstall(int c, Fmts f) } int -fmtinstall(int c, Fmts f) +jehanne_fmtinstall(int c, Fmts f) { int ret; @@ -149,7 +149,7 @@ _fmtdispatch(Fmt *f, const void *fmt, int isrunes) r = *(Rune*)fmt; fmt = (Rune*)fmt + 1; }else{ - fmt = (char*)fmt + chartorune(&rune, fmt); + fmt = (char*)fmt + jehanne_chartorune(&rune, fmt); r = rune; } f->r = r; diff --git a/sys/src/lib/c/fmt/fmtdef.h b/sys/src/lib/c/fmt/fmtdef.h index 928101f..a35bd75 100644 --- a/sys/src/lib/c/fmt/fmtdef.h +++ b/sys/src/lib/c/fmt/fmtdef.h @@ -78,7 +78,7 @@ void _fmtunlock(void); do{\ Rune _rune;\ int _runelen;\ - if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\ + if(t + UTFmax > (char*)s && t + (_runelen = jehanne_runelen(r)) > (char*)s){\ t = _fmtflush(f, t, _runelen);\ if(t != nil)\ s = f->stop;\ @@ -89,6 +89,6 @@ void _fmtunlock(void); *t++ = r;\ else{\ _rune = r;\ - t += runetochar(t, &_rune);\ + t += jehanne_runetochar(t, &_rune);\ }\ }while(0) diff --git a/sys/src/lib/c/fmt/fmtfd.c b/sys/src/lib/c/fmt/fmtfd.c index 4938c15..284a593 100644 --- a/sys/src/lib/c/fmt/fmtfd.c +++ b/sys/src/lib/c/fmt/fmtfd.c @@ -16,7 +16,7 @@ * to a file descriptor; returns total char count. */ int -fmtfdflush(Fmt *f) +jehanne_fmtfdflush(Fmt *f) { if(_fmtFdFlush(f) <= 0) return -1; @@ -27,7 +27,7 @@ fmtfdflush(Fmt *f) * initialize an output buffer for buffered printing */ int -fmtfdinit(Fmt *f, int fd, char *buf, int size) +jehanne_fmtfdinit(Fmt *f, int fd, char *buf, int size) { f->runes = 0; f->start = buf; diff --git a/sys/src/lib/c/fmt/fmtlock.c b/sys/src/lib/c/fmt/fmtlock.c index 5583a72..c09c11b 100644 --- a/sys/src/lib/c/fmt/fmtlock.c +++ b/sys/src/lib/c/fmt/fmtlock.c @@ -15,11 +15,11 @@ static Lock fmtl; void _fmtlock(void) { - lock(&fmtl); + jehanne_lock(&fmtl); } void _fmtunlock(void) { - unlock(&fmtl); + jehanne_unlock(&fmtl); } diff --git a/sys/src/lib/c/fmt/fmtprint.c b/sys/src/lib/c/fmt/fmtprint.c index 8c2e149..f189c2d 100644 --- a/sys/src/lib/c/fmt/fmtprint.c +++ b/sys/src/lib/c/fmt/fmtprint.c @@ -17,13 +17,13 @@ * designed for formats which themselves call fmt */ int -fmtprint(Fmt *f, const char *fmt, ...) +jehanne_fmtprint(Fmt *f, const char *fmt, ...) { va_list va; int n; va_start(va, fmt); - n = fmtvprint(f, fmt, va); + n = jehanne_fmtvprint(f, fmt, va); va_end(va); return n; } diff --git a/sys/src/lib/c/fmt/fmtquote.c b/sys/src/lib/c/fmt/fmtquote.c index 589bef7..9d85245 100644 --- a/sys/src/lib/c/fmt/fmtquote.c +++ b/sys/src/lib/c/fmt/fmtquote.c @@ -45,10 +45,10 @@ _quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, } for(; nin!=0; nin--){ if(s) - w = chartorune(&c, s); + w = jehanne_chartorune(&c, s); else{ c = *r; - w = runelen(c); + w = jehanne_runelen(c); } if(c == '\0') @@ -137,8 +137,8 @@ qstrfmt(char *sin, Rune *rin, Quoteinfo *q, Fmt *f) r = *(uint8_t*)m; if(r < Runeself) m++; - else if((me - m) >= UTFmax || fullrune(m, me-m)) - m += chartorune(&r, m); + else if((me - m) >= UTFmax || jehanne_fullrune(m, me-m)) + m += jehanne_chartorune(&r, m); else break; }else{ @@ -204,7 +204,7 @@ _quotestrfmt(int runesin, Fmt *f) outlen = (char*)f->stop - (char*)f->to; _quotesetup(s, r, nin, outlen, &q, f->flags&FmtSharp, f->runes); -//print("bytes in %d bytes out %d runes in %d runesout %d\n", q.nbytesin, q.nbytesout, q.nrunesin, q.nrunesout); +//jehanne_print("bytes in %d bytes out %d runes in %d runesout %d\n", q.nbytesin, q.nbytesout, q.nrunesin, q.nrunesout); if(runesin){ if(!q.quoted) @@ -218,22 +218,22 @@ _quotestrfmt(int runesin, Fmt *f) } int -quotestrfmt(Fmt *f) +jehanne_quotestrfmt(Fmt *f) { return _quotestrfmt(0, f); } int -quoterunestrfmt(Fmt *f) +jehanne_quoterunestrfmt(Fmt *f) { return _quotestrfmt(1, f); } void -quotefmtinstall(void) +jehanne_quotefmtinstall(void) { - fmtinstall('q', quotestrfmt); - fmtinstall('Q', quoterunestrfmt); + jehanne_fmtinstall('q', jehanne_quotestrfmt); + jehanne_fmtinstall('Q', jehanne_quoterunestrfmt); } int diff --git a/sys/src/lib/c/fmt/fmtrune.c b/sys/src/lib/c/fmt/fmtrune.c index 7286fa6..183afa7 100644 --- a/sys/src/lib/c/fmt/fmtrune.c +++ b/sys/src/lib/c/fmt/fmtrune.c @@ -12,7 +12,7 @@ #include "fmtdef.h" int -fmtrune(Fmt *f, int r) +jehanne_fmtrune(Fmt *f, int r) { Rune *rt; char *t; diff --git a/sys/src/lib/c/fmt/fmtstr.c b/sys/src/lib/c/fmt/fmtstr.c index b746f7e..a661934 100644 --- a/sys/src/lib/c/fmt/fmtstr.c +++ b/sys/src/lib/c/fmt/fmtstr.c @@ -11,7 +11,7 @@ #include char* -fmtstrflush(Fmt *f) +jehanne_fmtstrflush(Fmt *f) { if(f->start == nil) return nil; diff --git a/sys/src/lib/c/fmt/fmtvprint.c b/sys/src/lib/c/fmt/fmtvprint.c index 5dde86b..5082b4a 100644 --- a/sys/src/lib/c/fmt/fmtvprint.c +++ b/sys/src/lib/c/fmt/fmtvprint.c @@ -17,7 +17,7 @@ * designed for formats which themselves call fmt */ int -fmtvprint(Fmt *f, const char *fmt, va_list args) +jehanne_fmtvprint(Fmt *f, const char *fmt, va_list args) { va_list va; int n; @@ -27,7 +27,7 @@ fmtvprint(Fmt *f, const char *fmt, va_list args) va_copy(va,f->args); va_end(f->args); va_copy(f->args,args); - n = dofmt(f, fmt); + n = jehanne_dofmt(f, fmt); va_end(f->args); va_copy(f->args,va); va_end(va); diff --git a/sys/src/lib/c/fmt/fprint.c b/sys/src/lib/c/fmt/fprint.c index 6ee18c1..8217b4b 100644 --- a/sys/src/lib/c/fmt/fprint.c +++ b/sys/src/lib/c/fmt/fprint.c @@ -11,13 +11,13 @@ #include int -fprint(int fd, const char *fmt, ...) +jehanne_fprint(int fd, const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = vfprint(fd, fmt, args); + n = jehanne_vfprint(fd, fmt, args); va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/print.c b/sys/src/lib/c/fmt/print.c index 2187747..a54be37 100644 --- a/sys/src/lib/c/fmt/print.c +++ b/sys/src/lib/c/fmt/print.c @@ -11,13 +11,13 @@ #include int -print(const char *fmt, ...) +jehanne_print(const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = vfprint(1, fmt, args); + n = jehanne_vfprint(1, fmt, args); va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/runefmtstr.c b/sys/src/lib/c/fmt/runefmtstr.c index aa0d003..45c6b1e 100644 --- a/sys/src/lib/c/fmt/runefmtstr.c +++ b/sys/src/lib/c/fmt/runefmtstr.c @@ -11,7 +11,7 @@ #include Rune* -runefmtstrflush(Fmt *f) +jehanne_runefmtstrflush(Fmt *f) { if(f->start == nil) return nil; diff --git a/sys/src/lib/c/fmt/runeseprint.c b/sys/src/lib/c/fmt/runeseprint.c index ff0d51c..a68147f 100644 --- a/sys/src/lib/c/fmt/runeseprint.c +++ b/sys/src/lib/c/fmt/runeseprint.c @@ -11,13 +11,13 @@ #include Rune* -runeseprint(Rune *buf, Rune *e, const char *fmt, ...) +jehanne_runeseprint(Rune *buf, Rune *e, const char *fmt, ...) { Rune *p; va_list args; va_start(args, fmt); - p = runevseprint(buf, e, fmt, args); + p = jehanne_runevseprint(buf, e, fmt, args); va_end(args); return p; } diff --git a/sys/src/lib/c/fmt/runesmprint.c b/sys/src/lib/c/fmt/runesmprint.c index 337d0d3..8df14fb 100644 --- a/sys/src/lib/c/fmt/runesmprint.c +++ b/sys/src/lib/c/fmt/runesmprint.c @@ -11,13 +11,13 @@ #include Rune* -runesmprint(const char *fmt, ...) +jehanne_runesmprint(const char *fmt, ...) { va_list args; Rune *p; va_start(args, fmt); - p = runevsmprint(fmt, args); + p = jehanne_runevsmprint(fmt, args); va_end(args); return p; } diff --git a/sys/src/lib/c/fmt/runesnprint.c b/sys/src/lib/c/fmt/runesnprint.c index 6478727..3fff3d3 100644 --- a/sys/src/lib/c/fmt/runesnprint.c +++ b/sys/src/lib/c/fmt/runesnprint.c @@ -11,13 +11,13 @@ #include int -runesnprint(Rune *buf, int len, const char *fmt, ...) +jehanne_runesnprint(Rune *buf, int len, const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = runevsnprint(buf, len, fmt, args); + n = jehanne_runevsnprint(buf, len, fmt, args); va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/runesprint.c b/sys/src/lib/c/fmt/runesprint.c index c7128fd..abbf139 100644 --- a/sys/src/lib/c/fmt/runesprint.c +++ b/sys/src/lib/c/fmt/runesprint.c @@ -11,13 +11,13 @@ #include int -runesprint(Rune *buf, const char *fmt, ...) +jehanne_runesprint(Rune *buf, const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = runevsnprint(buf, 256, fmt, args); + n = jehanne_runevsnprint(buf, 256, fmt, args); va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/runevseprint.c b/sys/src/lib/c/fmt/runevseprint.c index de6eebc..72ed8e4 100644 --- a/sys/src/lib/c/fmt/runevseprint.c +++ b/sys/src/lib/c/fmt/runevseprint.c @@ -11,7 +11,7 @@ #include Rune* -runevseprint(Rune *buf, Rune *e, const char *fmt, va_list args) +jehanne_runevseprint(Rune *buf, Rune *e, const char *fmt, va_list args) { Fmt f; @@ -26,7 +26,7 @@ runevseprint(Rune *buf, Rune *e, const char *fmt, va_list args) f.nfmt = 0; //f.args = args; va_copy(f.args,args); - dofmt(&f, fmt); + jehanne_dofmt(&f, fmt); va_end(f.args); *(Rune*)f.to = '\0'; return f.to; diff --git a/sys/src/lib/c/fmt/runevsmprint.c b/sys/src/lib/c/fmt/runevsmprint.c index 2446d92..21f1aea 100644 --- a/sys/src/lib/c/fmt/runevsmprint.c +++ b/sys/src/lib/c/fmt/runevsmprint.c @@ -22,12 +22,12 @@ runeFmtStrFlush(Fmt *f) n = (int)(uintptr_t)f->farg; n *= 2; s = f->start; - f->start = realloc(s, sizeof(Rune)*n); + f->start = jehanne_realloc(s, sizeof(Rune)*n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; - free(s); + jehanne_free(s); return 0; } f->farg = (void*)(uintptr_t)n; @@ -37,17 +37,17 @@ runeFmtStrFlush(Fmt *f) } int -runefmtstrinit(Fmt *f) +jehanne_runefmtstrinit(Fmt *f) { int n; - memset(f, 0, sizeof *f); + jehanne_memset(f, 0, sizeof *f); f->runes = 1; n = 32; - f->start = malloc(sizeof(Rune)*n); + f->start = jehanne_malloc(sizeof(Rune)*n); if(f->start == nil) return -1; - setmalloctag(f->start, getcallerpc()); + jehanne_setmalloctag(f->start, jehanne_getcallerpc()); f->to = f->start; f->stop = (Rune*)f->start + n - 1; f->flush = runeFmtStrFlush; @@ -60,24 +60,24 @@ runefmtstrinit(Fmt *f) * print into an allocated string buffer */ Rune* -runevsmprint(const char *fmt, va_list args) +jehanne_runevsmprint(const char *fmt, va_list args) { Fmt f; int n; - if(runefmtstrinit(&f) < 0) + if(jehanne_runefmtstrinit(&f) < 0) return nil; //f.args = args; va_copy(f.args,args); - n = dofmt(&f, fmt); + n = jehanne_dofmt(&f, fmt); va_end(f.args); if(f.start == nil) /* realloc failed? */ return nil; if(n < 0){ - free(f.start); + jehanne_free(f.start); return nil; } - setmalloctag(f.start, getcallerpc()); + jehanne_setmalloctag(f.start, jehanne_getcallerpc()); *(Rune*)f.to = '\0'; return f.start; } diff --git a/sys/src/lib/c/fmt/runevsnprint.c b/sys/src/lib/c/fmt/runevsnprint.c index c7cec2d..81963c0 100644 --- a/sys/src/lib/c/fmt/runevsnprint.c +++ b/sys/src/lib/c/fmt/runevsnprint.c @@ -11,7 +11,7 @@ #include int -runevsnprint(Rune *buf, int len, const char *fmt, va_list args) +jehanne_runevsnprint(Rune *buf, int len, const char *fmt, va_list args) { Fmt f; @@ -26,7 +26,7 @@ runevsnprint(Rune *buf, int len, const char *fmt, va_list args) f.nfmt = 0; //f.args = args; va_copy(f.args,args); - dofmt(&f, fmt); + jehanne_dofmt(&f, fmt); va_end(f.args); *(Rune*)f.to = '\0'; return (Rune*)f.to - buf; diff --git a/sys/src/lib/c/fmt/seprint.c b/sys/src/lib/c/fmt/seprint.c index 614be35..0f1865c 100644 --- a/sys/src/lib/c/fmt/seprint.c +++ b/sys/src/lib/c/fmt/seprint.c @@ -11,13 +11,13 @@ #include char* -seprint(char *buf, char *e, const char *fmt, ...) +jehanne_seprint(char *buf, char *e, const char *fmt, ...) { char *p; va_list args; va_start(args, fmt); - p = vseprint(buf, e, fmt, args); + p = jehanne_vseprint(buf, e, fmt, args); va_end(args); return p; } diff --git a/sys/src/lib/c/fmt/smprint.c b/sys/src/lib/c/fmt/smprint.c index 2dc9c7c..b97efd6 100644 --- a/sys/src/lib/c/fmt/smprint.c +++ b/sys/src/lib/c/fmt/smprint.c @@ -11,14 +11,14 @@ #include char* -smprint(const char *fmt, ...) +jehanne_smprint(const char *fmt, ...) { va_list args; char *p; va_start(args, fmt); - p = vsmprint(fmt, args); + p = jehanne_vsmprint(fmt, args); va_end(args); - setmalloctag(p, getcallerpc()); + jehanne_setmalloctag(p, jehanne_getcallerpc()); return p; } diff --git a/sys/src/lib/c/fmt/snprint.c b/sys/src/lib/c/fmt/snprint.c index 528fedc..b1f50c8 100644 --- a/sys/src/lib/c/fmt/snprint.c +++ b/sys/src/lib/c/fmt/snprint.c @@ -11,13 +11,13 @@ #include int -snprint(char *buf, int len, const char *fmt, ...) +jehanne_snprint(char *buf, int len, const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = vsnprint(buf, len, fmt, args); + n = jehanne_vsnprint(buf, len, fmt, args); va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/sprint.c b/sys/src/lib/c/fmt/sprint.c index 7cb4915..96de505 100644 --- a/sys/src/lib/c/fmt/sprint.c +++ b/sys/src/lib/c/fmt/sprint.c @@ -11,13 +11,13 @@ #include int -sprint(char *buf, const char *fmt, ...) +jehanne_sprint(char *buf, const char *fmt, ...) { int n; va_list args; va_start(args, fmt); - n = vsnprint(buf, 65536, fmt, args); /* big number, but sprint is deprecated anyway */ + n = jehanne_vsnprint(buf, 65536, fmt, args); /* big number, but sprint is deprecated anyway */ va_end(args); return n; } diff --git a/sys/src/lib/c/fmt/vfprint.c b/sys/src/lib/c/fmt/vfprint.c index 3d5d8a9..308f735 100644 --- a/sys/src/lib/c/fmt/vfprint.c +++ b/sys/src/lib/c/fmt/vfprint.c @@ -28,16 +28,16 @@ _fmtFdFlush(Fmt *f) } int -vfprint(int fd, const char *fmt, va_list args) +jehanne_vfprint(int fd, const char *fmt, va_list args) { Fmt f; char buf[256]; int n; - fmtfdinit(&f, fd, buf, sizeof(buf)); + jehanne_fmtfdinit(&f, fd, buf, sizeof(buf)); //f.args = args; va_copy(f.args,args); - n = dofmt(&f, fmt); + n = jehanne_dofmt(&f, fmt); va_end(f.args); if(n > 0 && _fmtFdFlush(&f) == 0) return -1; diff --git a/sys/src/lib/c/fmt/vseprint.c b/sys/src/lib/c/fmt/vseprint.c index 3f69275..214f409 100644 --- a/sys/src/lib/c/fmt/vseprint.c +++ b/sys/src/lib/c/fmt/vseprint.c @@ -11,7 +11,7 @@ #include char* -vseprint(char *buf, char *e, const char *fmt, va_list args) +jehanne_vseprint(char *buf, char *e, const char *fmt, va_list args) { Fmt f; @@ -26,7 +26,7 @@ vseprint(char *buf, char *e, const char *fmt, va_list args) f.nfmt = 0; //f.args = args; va_copy(f.args,args); - dofmt(&f, fmt); + jehanne_dofmt(&f, fmt); va_end(f.args); *(char*)f.to = '\0'; return f.to; diff --git a/sys/src/lib/c/fmt/vsmprint.c b/sys/src/lib/c/fmt/vsmprint.c index 562bcf5..8a8cd79 100644 --- a/sys/src/lib/c/fmt/vsmprint.c +++ b/sys/src/lib/c/fmt/vsmprint.c @@ -22,12 +22,12 @@ fmtStrFlush(Fmt *f) n = (int)(uintptr_t)f->farg; n *= 2; s = f->start; - f->start = realloc(s, n); + f->start = jehanne_realloc(s, n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; - free(s); + jehanne_free(s); return 0; } f->farg = (void*)(uintptr_t)n; @@ -37,17 +37,17 @@ fmtStrFlush(Fmt *f) } int -fmtstrinit(Fmt *f) +jehanne_fmtstrinit(Fmt *f) { int n; - memset(f, 0, sizeof *f); + jehanne_memset(f, 0, sizeof *f); f->runes = 0; n = 32; - f->start = malloc(n); + f->start = jehanne_malloc(n); if(f->start == nil) return -1; - setmalloctag(f->start, getcallerpc()); + jehanne_setmalloctag(f->start, jehanne_getcallerpc()); f->to = f->start; f->stop = (char*)f->start + n - 1; f->flush = fmtStrFlush; @@ -60,24 +60,24 @@ fmtstrinit(Fmt *f) * print into an allocated string buffer */ char* -vsmprint(const char *fmt, va_list args) +jehanne_vsmprint(const char *fmt, va_list args) { Fmt f; int n; - if(fmtstrinit(&f) < 0) + if(jehanne_fmtstrinit(&f) < 0) return nil; //f.args = args; va_copy(f.args,args); - n = dofmt(&f, fmt); + n = jehanne_dofmt(&f, fmt); va_end(f.args); if(f.start == nil) /* realloc failed? */ return nil; if(n < 0){ - free(f.start); + jehanne_free(f.start); return nil; } - setmalloctag(f.start, getcallerpc()); + jehanne_setmalloctag(f.start, jehanne_getcallerpc()); *(char*)f.to = '\0'; return f.start; } diff --git a/sys/src/lib/c/fmt/vsnprint.c b/sys/src/lib/c/fmt/vsnprint.c index f22c1dc..c1f6b4c 100644 --- a/sys/src/lib/c/fmt/vsnprint.c +++ b/sys/src/lib/c/fmt/vsnprint.c @@ -11,7 +11,7 @@ #include int -vsnprint(char *buf, int len, const char *fmt, va_list args) +jehanne_vsnprint(char *buf, int len, const char *fmt, va_list args) { Fmt f; @@ -26,7 +26,7 @@ vsnprint(char *buf, int len, const char *fmt, va_list args) f.nfmt = 0; //f.args = args; va_copy(f.args,args); - dofmt(&f, fmt); + jehanne_dofmt(&f, fmt); va_end(f.args); *(char*)f.to = '\0'; return (char*)f.to - buf; diff --git a/sys/src/lib/c/lib9.c b/sys/src/lib/c/lib9.c new file mode 100644 index 0000000..ac19d10 --- /dev/null +++ b/sys/src/lib/c/lib9.c @@ -0,0 +1,42 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ + +/* Lib9.c can be included in plan9 programs to provide functions that + * are expected by autogenerated code (eg via yacc) + */ + +#include +#include + +void* +memcpy(void* a, const void* b, size_t c) +{ + return jehanne_memcpy(a,b,c); +} + +void* +malloc(size_t s) +{ + return jehanne_malloc(s); +} + +void +free(void* p) +{ + return jehanne_free(p); +} diff --git a/sys/src/lib/c/port/_assert.c b/sys/src/lib/c/port/_assert.c index 0f456de..8ed076e 100644 --- a/sys/src/lib/c/port/_assert.c +++ b/sys/src/lib/c/port/_assert.c @@ -13,11 +13,11 @@ void (*__assert)(char*); void -_assert(const char *s) +jehanne__assert(const char *s) { if(__assert) (*__assert)((char*)s); - fprint(2, "assert failed: %s\n", s); + jehanne_fprint(2, "assert failed: %s\n", s); abort(); __builtin_unreachable(); } diff --git a/sys/src/lib/c/port/abs.c b/sys/src/lib/c/port/abs.c index 5fba73e..f59b727 100644 --- a/sys/src/lib/c/port/abs.c +++ b/sys/src/lib/c/port/abs.c @@ -11,7 +11,7 @@ #include int -abs(int a) +jehanne_abs(int a) { if(a < 0) return -a; @@ -19,7 +19,7 @@ abs(int a) } int32_t -labs(int32_t a) +jehanne_labs(int32_t a) { if(a < 0) return -a; diff --git a/sys/src/lib/c/port/asin.c b/sys/src/lib/c/port/asin.c index 3be7660..af6a2f8 100644 --- a/sys/src/lib/c/port/asin.c +++ b/sys/src/lib/c/port/asin.c @@ -8,7 +8,7 @@ */ /* - * asin(arg) and acos(arg) return the arcsin, arccos, + * jehanne_asin(arg) and jehanne_acos(arg) return the arcsin, arccos, * respectively of their arguments. * * Arctan is called after appropriate range reduction. @@ -18,7 +18,7 @@ #include double -asin(double arg) +jehanne_asin(double arg) { double temp; int sign; @@ -29,21 +29,21 @@ asin(double arg) sign++; } if(arg > 1) - return NaN(); - temp = sqrt(1 - arg*arg); + return jehanne_NaN(); + temp = jehanne_sqrt(1 - arg*arg); if(arg > 0.7) - temp = PIO2 - atan(temp/arg); + temp = PIO2 - jehanne_atan(temp/arg); else - temp = atan(arg/temp); + temp = jehanne_atan(arg/temp); if(sign) temp = -temp; return temp; } double -acos(double arg) +jehanne_acos(double arg) { if(arg > 1 || arg < -1) - return NaN(); - return PIO2 - asin(arg); + return jehanne_NaN(); + return PIO2 - jehanne_asin(arg); } diff --git a/sys/src/lib/c/port/atan.c b/sys/src/lib/c/port/atan.c index 864d534..223883b 100644 --- a/sys/src/lib/c/port/atan.c +++ b/sys/src/lib/c/port/atan.c @@ -40,7 +40,7 @@ /* xatan evaluates a series valid in the - range [-0.414...,+0.414...]. (tan(pi/8)) + range [-0.414...,+0.414...]. (jehanne_tan(pi/8)) */ static @@ -78,7 +78,7 @@ satan(double arg) */ double -atan(double arg) +jehanne_atan(double arg) { if(arg > 0) diff --git a/sys/src/lib/c/port/atan2.c b/sys/src/lib/c/port/atan2.c index 14874e8..01c0de3 100644 --- a/sys/src/lib/c/port/atan2.c +++ b/sys/src/lib/c/port/atan2.c @@ -15,7 +15,7 @@ */ double -atan2(double arg1, double arg2) +jehanne_atan2(double arg1, double arg2) { if(arg1+arg2 == arg1) { @@ -23,7 +23,7 @@ atan2(double arg1, double arg2) return PIO2; return -PIO2; } - arg1 = atan(arg1/arg2); + arg1 = jehanne_atan(arg1/arg2); if(arg2 < 0) { if(arg1 <= 0) return arg1 + PI; diff --git a/sys/src/lib/c/port/atexit.c b/sys/src/lib/c/port/atexit.c index d6cb55a..5e478c8 100644 --- a/sys/src/lib/c/port/atexit.c +++ b/sys/src/lib/c/port/atexit.c @@ -22,28 +22,28 @@ static Lock onexlock; Onex onex[NEXIT]; int -atexit(void (*f)(void)) +jehanne_atexit(void (*f)(void)) { int i; - lock(&onexlock); + jehanne_lock(&onexlock); for(i=0; i= 0; i--) if((f = onex[i].f) && pid == onex[i].pid) { onex[i].f = 0; diff --git a/sys/src/lib/c/port/atnotify.c b/sys/src/lib/c/port/atnotify.c index e7bec33..9bfec62 100644 --- a/sys/src/lib/c/port/atnotify.c +++ b/sys/src/lib/c/port/atnotify.c @@ -29,7 +29,7 @@ notifier(void *v, char *s) } int -atnotify(int (*f)(void*, char*), int in) +jehanne_atnotify(int (*f)(void*, char*), int in) { int i, n, ret; static int init; @@ -39,7 +39,7 @@ atnotify(int (*f)(void*, char*), int in) init = 1; /* assign = */ } ret = 0; - lock(&onnotlock); + jehanne_lock(&onnotlock); if(in){ for(i=0; i double -atof(const char *cp) +jehanne_atof(const char *cp) { - return strtod(cp, 0); + return jehanne_strtod(cp, 0); } diff --git a/sys/src/lib/c/port/atol.c b/sys/src/lib/c/port/atol.c index a72a2be..f75bf4e 100644 --- a/sys/src/lib/c/port/atol.c +++ b/sys/src/lib/c/port/atol.c @@ -11,7 +11,7 @@ #include int32_t -atol(const char *s) +jehanne_atol(const char *s) { int32_t n; int f, c; @@ -55,8 +55,8 @@ atol(const char *s) } int -atoi(const char *s) +jehanne_atoi(const char *s) { - return atol(s); + return jehanne_atol(s); } diff --git a/sys/src/lib/c/port/atoll.c b/sys/src/lib/c/port/atoll.c index ae52759..e6dac13 100644 --- a/sys/src/lib/c/port/atoll.c +++ b/sys/src/lib/c/port/atoll.c @@ -11,7 +11,7 @@ #include int64_t -atoll(const char *s) +jehanne_atoll(const char *s) { - return strtoll(s, nil, 0); + return jehanne_strtoll(s, nil, 0); } diff --git a/sys/src/lib/c/port/bsearch.c b/sys/src/lib/c/port/bsearch.c index 17f751b..729f9e7 100644 --- a/sys/src/lib/c/port/bsearch.c +++ b/sys/src/lib/c/port/bsearch.c @@ -18,7 +18,7 @@ #include void* -bsearch(const void* key, const void* base, long nmemb, int size, +jehanne_bsearch(const void* key, const void* base, long nmemb, int size, int (*compar)(const void*, const void*)) { long i, bot, top, new; diff --git a/sys/src/lib/c/port/charstod.c b/sys/src/lib/c/port/charstod.c index af169ad..2e69d23 100644 --- a/sys/src/lib/c/port/charstod.c +++ b/sys/src/lib/c/port/charstod.c @@ -17,10 +17,10 @@ * necessary to back up the input stream up one byte after calling charstod. */ -#define ADVANCE *s++ = c; if(s>=e) return NaN(); c = (*f)(vp) +#define ADVANCE *s++ = c; if(s>=e) return jehanne_NaN(); c = (*f)(vp) double -charstod(int(*f)(void*), void *vp) +jehanne_charstod(int(*f)(void*), void *vp) { char str[400], *s, *e, *start; int c; @@ -54,37 +54,37 @@ charstod(int(*f)(void*), void *vp) }else if(s == start && (c == 'i' || c == 'I')){ ADVANCE; if(c != 'n' && c != 'N') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'f' && c != 'F') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'i' && c != 'I') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'n' && c != 'N') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'i' && c != 'I') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 't' && c != 'T') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'y' && c != 'Y') - return NaN(); + return jehanne_NaN(); ADVANCE; /* so caller can back up uniformly */ USED(c); }else if(s == str && (c == 'n' || c == 'N')){ ADVANCE; if(c != 'a' && c != 'A') - return NaN(); + return jehanne_NaN(); ADVANCE; if(c != 'n' && c != 'N') - return NaN(); + return jehanne_NaN(); ADVANCE; /* so caller can back up uniformly */ USED(c); } *s = 0; - return strtod(str, (const char **)&s); + return jehanne_strtod(str, (const char **)&s); } diff --git a/sys/src/lib/c/port/cistrcmp.c b/sys/src/lib/c/port/cistrcmp.c index e664109..e65053e 100644 --- a/sys/src/lib/c/port/cistrcmp.c +++ b/sys/src/lib/c/port/cistrcmp.c @@ -11,7 +11,7 @@ #include int -cistrcmp(const char *s1, const char *s2) +jehanne_cistrcmp(const char *s1, const char *s2) { int c1, c2; diff --git a/sys/src/lib/c/port/cistrncmp.c b/sys/src/lib/c/port/cistrncmp.c index c1d0760..2795043 100644 --- a/sys/src/lib/c/port/cistrncmp.c +++ b/sys/src/lib/c/port/cistrncmp.c @@ -11,7 +11,7 @@ #include int -cistrncmp(const char *s1, const char *s2, int n) +jehanne_cistrncmp(const char *s1, const char *s2, int n) { int c1, c2; diff --git a/sys/src/lib/c/port/cistrstr.c b/sys/src/lib/c/port/cistrstr.c index fc41b6f..8cdd642 100644 --- a/sys/src/lib/c/port/cistrstr.c +++ b/sys/src/lib/c/port/cistrstr.c @@ -11,7 +11,7 @@ #include char* -cistrstr(const char *s, const char *sub) +jehanne_cistrstr(const char *s, const char *sub) { int c, csub, n; @@ -21,11 +21,11 @@ cistrstr(const char *s, const char *sub) if(csub >= 'A' && csub <= 'Z') csub -= 'A' - 'a'; sub++; - n = strlen(sub); + n = jehanne_strlen(sub); for(; c = *s; s++){ if(c >= 'A' && c <= 'Z') c -= 'A' - 'a'; - if(c == csub && cistrncmp(s+1, sub, n) == 0) + if(c == csub && jehanne_cistrncmp(s+1, sub, n) == 0) return (char*)s; } return nil; diff --git a/sys/src/lib/c/port/cleanname.c b/sys/src/lib/c/port/cleanname.c index 4270bd6..5432c53 100644 --- a/sys/src/lib/c/port/cleanname.c +++ b/sys/src/lib/c/port/cleanname.c @@ -17,7 +17,7 @@ */ #define SEP(x) ((x)=='/' || (x) == 0) char* -cleanname(char *name) +jehanne_cleanname(char *name) { char *s; /* source of copy */ char *d; /* destination of copy */ @@ -27,15 +27,15 @@ cleanname(char *name) assert(name != nil); if(name[0] == 0) - return strcpy(name, "."); + return jehanne_strcpy(name, "."); rooted = 0; d0 = name; if(d0[0] == '#'){ if(d0[1] == 0) return d0; - d0 += 1 + chartorune(&r, d0+1); /* ignore slash: #/ */ + d0 += 1 + jehanne_chartorune(&r, d0+1); /* ignore slash: #/ */ while(!SEP(*d0)) - d0 += chartorune(&r, d0); + d0 += jehanne_chartorune(&r, d0); if(*d0 == 0) return name; d0++; /* keep / after # */ @@ -104,6 +104,6 @@ cleanname(char *name) if(d-1 > name && d[-1] == '/') /* thanks to #/ */ *--d = 0; if(name[0] == 0) - strcpy(name, "."); + jehanne_strcpy(name, "."); return name; } diff --git a/sys/src/lib/c/port/encodefmt.c b/sys/src/lib/c/port/encodefmt.c index 1f06aaf..d390bc7 100644 --- a/sys/src/lib/c/port/encodefmt.c +++ b/sys/src/lib/c/port/encodefmt.c @@ -12,7 +12,7 @@ #include int -encodefmt(Fmt *f) +jehanne_encodefmt(Fmt *f) { char *out; char *buf; @@ -29,7 +29,7 @@ encodefmt(Fmt *f) b = va_arg(f->args, uint8_t*); if(b == 0) - return fmtstrcpy(f, ""); + return jehanne_fmtstrcpy(f, ""); ilen = f->prec; f->prec = 0; @@ -49,7 +49,7 @@ encodefmt(Fmt *f) } if(len > sizeof(obuf)){ - buf = malloc(len); + buf = jehanne_malloc(len); if(buf == nil) goto error; } else @@ -59,16 +59,16 @@ encodefmt(Fmt *f) out = buf; switch(f->r){ case '<': - rv = enc32(out, len, b, ilen); + rv = jehanne_enc32(out, len, b, ilen); break; case '[': - rv = enc64(out, len, b, ilen); + rv = jehanne_enc64(out, len, b, ilen); break; case 'H': - rv = enc16(out, len, b, ilen); + rv = jehanne_enc16(out, len, b, ilen); if(rv >= 0 && (f->flags & FmtLong)) for(p = buf; *p; p++) - *p = tolower(*p); + *p = jehanne_tolower(*p); break; default: rv = -1; @@ -77,13 +77,13 @@ encodefmt(Fmt *f) if(rv < 0) goto error; - fmtstrcpy(f, buf); + jehanne_fmtstrcpy(f, buf); if(buf != obuf) - free(buf); + jehanne_free(buf); return 0; error: if(out != nil) - free(out); - return fmtstrcpy(f, ""); + jehanne_free(out); + return jehanne_fmtstrcpy(f, ""); } diff --git a/sys/src/lib/c/port/execl.c b/sys/src/lib/c/port/execl.c index dd7c0dc..e4eaafd 100644 --- a/sys/src/lib/c/port/execl.c +++ b/sys/src/lib/c/port/execl.c @@ -12,7 +12,7 @@ int -execl(const char *f, ...) +jehanne_execl(const char *f, ...) { va_list va, va2; char *arg; @@ -25,7 +25,7 @@ execl(const char *f, ...) while((arg = va_arg(va, char *)) != nil) n++; - char **args = malloc(sizeof(char*)*(n+1)); + char **args = jehanne_malloc(sizeof(char*)*(n+1)); n = 0; while((arg = va_arg(va2, char *)) != nil) diff --git a/sys/src/lib/c/port/exp.c b/sys/src/lib/c/port/exp.c index 49cf0fb..ae98484 100644 --- a/sys/src/lib/c/port/exp.c +++ b/sys/src/lib/c/port/exp.c @@ -28,7 +28,7 @@ #define maxf 10000 double -exp(double arg) +jehanne_exp(double arg) { double fract, temp1, temp2, xsq; int ent; @@ -38,12 +38,12 @@ exp(double arg) if(arg < -maxf) return 0; if(arg > maxf) - return Inf(1); + return jehanne_Inf(1); arg *= log2e; - ent = floor(arg); + ent = jehanne_floor(arg); fract = (arg-ent) - 0.5; xsq = fract*fract; temp1 = ((p2*xsq+p1)*xsq+p0)*fract; temp2 = ((xsq+q2)*xsq+q1)*xsq + q0; - return ldexp(sqrt2*(temp2+temp1)/(temp2-temp1), ent); + return jehanne_ldexp(sqrt2*(temp2+temp1)/(temp2-temp1), ent); } diff --git a/sys/src/lib/c/port/fabs.c b/sys/src/lib/c/port/fabs.c index 27eef4e..942aa3d 100644 --- a/sys/src/lib/c/port/fabs.c +++ b/sys/src/lib/c/port/fabs.c @@ -11,7 +11,7 @@ #include double -fabs(double arg) +jehanne_fabs(double arg) { if(arg < 0) diff --git a/sys/src/lib/c/port/floor.c b/sys/src/lib/c/port/floor.c index 3e6761b..d09ac84 100644 --- a/sys/src/lib/c/port/floor.c +++ b/sys/src/lib/c/port/floor.c @@ -15,22 +15,22 @@ */ double -floor(double d) +jehanne_floor(double d) { double fract; if(d < 0) { - fract = modf(-d, &d); + fract = jehanne_modf(-d, &d); if(fract != 0.0) d += 1; d = -d; } else - modf(d, &d); + jehanne_modf(d, &d); return d; } double -ceil(double d) +jehanne_ceil(double d) { - return -floor(-d); + return -jehanne_floor(-d); } diff --git a/sys/src/lib/c/port/fmod.c b/sys/src/lib/c/port/fmod.c index 90669cc..1a29868 100644 --- a/sys/src/lib/c/port/fmod.c +++ b/sys/src/lib/c/port/fmod.c @@ -14,7 +14,7 @@ * floating-point mod function without infinity or NaN checking */ double -fmod (double x, double y) +jehanne_fmod(double x, double y) { int sign, yexp, rexp; double r, yfr, rfr; @@ -23,7 +23,7 @@ fmod (double x, double y) return x; if (y < 0) y = -y; - yfr = frexp(y, &yexp); + yfr = jehanne_frexp(y, &yexp); sign = 0; if(x < 0) { r = -x; @@ -31,8 +31,8 @@ fmod (double x, double y) } else r = x; while(r >= y) { - rfr = frexp(r, &rexp); - r -= ldexp(y, rexp - yexp - (rfr < yfr)); + rfr = jehanne_frexp(r, &rexp); + r -= jehanne_ldexp(y, rexp - yexp - (rfr < yfr)); } if(sign) r = -r; diff --git a/sys/src/lib/c/port/frand.c b/sys/src/lib/c/port/frand.c index ac14ab2..2d0d099 100644 --- a/sys/src/lib/c/port/frand.c +++ b/sys/src/lib/c/port/frand.c @@ -14,13 +14,13 @@ #define NORM (1.0/(1.0+MASK)) double -frand(void) +jehanne_frand(void) { double x; do { - x = lrand() * NORM; - x = (x + lrand()) * NORM; + x = jehanne_lrand() * NORM; + x = (x + jehanne_lrand()) * NORM; } while(x >= 1); return x; } diff --git a/sys/src/lib/c/port/frexp.c b/sys/src/lib/c/port/frexp.c index bc1a403..e9135d1 100644 --- a/sys/src/lib/c/port/frexp.c +++ b/sys/src/lib/c/port/frexp.c @@ -21,16 +21,16 @@ #define SIG 52 double -frexp(double d, int *ep) +jehanne_frexp(double d, int *ep) { FPdbleword x, a; *ep = 0; /* order matters: only isNaN can operate on NaN */ - if(isNaN(d) || isInf(d, 0) || d == 0) + if(jehanne_isNaN(d) || jehanne_isInf(d, 0) || d == 0) return d; x.x = d; - a.x = fabs(d); + a.x = jehanne_fabs(d); if((a.hi >> SHIFT) == 0){ /* normalize subnormal numbers */ x.x = (double)(1ULL<= MASK){ /* overflow */ if(d < 0) - return Inf(-1); - return Inf(1); + return jehanne_Inf(-1); + return jehanne_Inf(1); } }else{ /* underflow gracefully */ deltae = -deltae; @@ -93,7 +93,7 @@ ldexp(double d, int deltae) } double -modf(double d, double *ip) +jehanne_modf(double d, double *ip) { FPdbleword x; int e; @@ -110,7 +110,7 @@ modf(double d, double *ip) } if(d < 1) { if(d < 0) { - x.x = modf(-d, ip); + x.x = jehanne_modf(-d, ip); *ip = -*ip; return -x.x; } diff --git a/sys/src/lib/c/port/getcallerpc.c b/sys/src/lib/c/port/getcallerpc.c index bf0f588..ab2c9a3 100644 --- a/sys/src/lib/c/port/getcallerpc.c +++ b/sys/src/lib/c/port/getcallerpc.c @@ -11,7 +11,7 @@ #include uintptr_t -getcallerpc(void) +jehanne_getcallerpc(void) { return (uintptr_t)__builtin_return_address(2); } diff --git a/sys/src/lib/c/port/getfields.c b/sys/src/lib/c/port/getfields.c index 983c169..017e2b3 100644 --- a/sys/src/lib/c/port/getfields.c +++ b/sys/src/lib/c/port/getfields.c @@ -11,7 +11,7 @@ #include int -getfields(char *str, char **args, int max, int mflag, const char *set) +jehanne_getfields(char *str, char **args, int max, int mflag, const char *set) { Rune r; int nr, intok, narg; @@ -25,10 +25,10 @@ getfields(char *str, char **args, int max, int mflag, const char *set) narg++; intok = 0; for(;; str += nr) { - nr = chartorune(&r, str); + nr = jehanne_chartorune(&r, str); if(r == 0) break; - if(utfrune(set, r)) { + if(jehanne_utfrune(set, r)) { if(narg >= max) break; *str = 0; diff --git a/sys/src/lib/c/port/getuser.c b/sys/src/lib/c/port/getuser.c index d7b1d3d..5790a4c 100644 --- a/sys/src/lib/c/port/getuser.c +++ b/sys/src/lib/c/port/getuser.c @@ -11,7 +11,7 @@ #include char * -getuser(void) +jehanne_getuser(void) { static char user[64]; int fd; @@ -23,7 +23,7 @@ getuser(void) n = read(fd, user, (sizeof user)-1); close(fd); if(n <= 0) - strcpy(user, "none"); + jehanne_strcpy(user, "none"); else user[n] = 0; return user; diff --git a/sys/src/lib/c/port/hangup.c b/sys/src/lib/c/port/hangup.c index 5b3a2ec..30fb098 100644 --- a/sys/src/lib/c/port/hangup.c +++ b/sys/src/lib/c/port/hangup.c @@ -15,7 +15,7 @@ * force a connection to hangup */ int -hangup(int ctl) +jehanne_hangup(int ctl) { return write(ctl, "hangup", sizeof("hangup")-1) != sizeof("hangup")-1; } diff --git a/sys/src/lib/c/port/hypot.c b/sys/src/lib/c/port/hypot.c index 1bcf033..38adf22 100644 --- a/sys/src/lib/c/port/hypot.c +++ b/sys/src/lib/c/port/hypot.c @@ -8,7 +8,7 @@ */ /* - * hypot -- sqrt(p*p+q*q), but overflows only if the result does. + * hypot -- jehanne_sqrt(p*p+q*q), but overflows only if the result does. * See Cleve Moler and Donald Morrison, * ``Replacing Square Roots by Pythagorean Sums,'' * IBM Journal of Research and Development, @@ -19,7 +19,7 @@ #include double -hypot(double p, double q) +jehanne_hypot(double p, double q) { double r, s, pfac; diff --git a/sys/src/lib/c/port/lnrand.c b/sys/src/lib/c/port/lnrand.c index 7a96228..8ee71c2 100644 --- a/sys/src/lib/c/port/lnrand.c +++ b/sys/src/lib/c/port/lnrand.c @@ -13,7 +13,7 @@ #define MASK 0x7fffffffL int32_t -lnrand(int32_t n) +jehanne_lnrand(int32_t n) { int32_t slop, v; @@ -21,7 +21,7 @@ lnrand(int32_t n) return n; slop = MASK % n; do - v = lrand(); + v = jehanne_lrand(); while(v <= slop); return v % n; } diff --git a/sys/src/lib/c/port/lock.c b/sys/src/lib/c/port/lock.c index 4e7afde..3af191d 100644 --- a/sys/src/lib/c/port/lock.c +++ b/sys/src/lib/c/port/lock.c @@ -13,9 +13,9 @@ #include void -lock(Lock *l) +jehanne_lock(Lock *l) { - if(ainc(&l->key) == 1) + if(jehanne_ainc(&l->key) == 1) return; /* changed from 0 -> 1: we hold lock */ /* otherwise wait in kernel */ while(semacquire(&l->sem, 1) < 0){ @@ -24,40 +24,40 @@ lock(Lock *l) } void -unlock(Lock *l) +jehanne_unlock(Lock *l) { - if(adec(&l->key) == 0) + if(jehanne_adec(&l->key) == 0) return; /* changed from 1 -> 0: no contention */ semrelease(&l->sem, 1); } int -canlock(Lock *l) +jehanne_canlock(Lock *l) { - if(ainc(&l->key) == 1) + if(jehanne_ainc(&l->key) == 1) return 1; /* changed from 0 -> 1: success */ /* Undo increment (but don't miss wakeup) */ - if(adec(&l->key) == 0) + if(jehanne_adec(&l->key) == 0) return 0; /* changed from 1 -> 0: no contention */ semrelease(&l->sem, 1); return 0; } int -lockt(Lock *l, uint32_t ms) +jehanne_lockt(Lock *l, uint32_t ms) { int semr; int64_t start, end; - if(ainc(&l->key) == 1) + if(jehanne_ainc(&l->key) == 1) return 1; /* changed from 0 -> 1: we hold lock */ /* otherwise wait in kernel */ semr = 0; - start = nsec() / (1000 * 1000); + start = jehanne_nsec() / (1000 * 1000); end = start + ms; while(start < end && (semr = tsemacquire(&l->sem, ms)) < 0){ /* interrupted; try again */ - start = nsec() / (1000 * 1000); + start = jehanne_nsec() / (1000 * 1000); ms = end - start; } /* copy canlock semantic for return values */ diff --git a/sys/src/lib/c/port/log.c b/sys/src/lib/c/port/log.c index 7499552..e3c1ff4 100644 --- a/sys/src/lib/c/port/log.c +++ b/sys/src/lib/c/port/log.c @@ -31,14 +31,14 @@ #define q2 -.891110902798312337e1 double -log(double arg) +jehanne_log(double arg) { double x, z, zsq, temp; int exp; if(arg <= 0) - return NaN(); - x = frexp(arg, &exp); + return jehanne_NaN(); + x = jehanne_frexp(arg, &exp); while(x < 0.5) { x *= 2; exp--; @@ -58,10 +58,10 @@ log(double arg) } double -log10(double arg) +jehanne_log10(double arg) { if(arg <= 0) - return NaN(); - return log(arg) * ln10o1; + return jehanne_NaN(); + return jehanne_log(arg) * ln10o1; } diff --git a/sys/src/lib/c/port/lrand.c b/sys/src/lib/c/port/lrand.c index a2d4693..eb6bc96 100644 --- a/sys/src/lib/c/port/lrand.c +++ b/sys/src/lib/c/port/lrand.c @@ -58,19 +58,19 @@ isrand(int32_t seed) } void -srand(int32_t seed) +jehanne_srand(int32_t seed) { - lock(&lk); + jehanne_lock(&lk); isrand(seed); - unlock(&lk); + jehanne_unlock(&lk); } int32_t -lrand(void) +jehanne_lrand(void) { uint32_t x; - lock(&lk); + jehanne_lock(&lk); rng_tap--; if(rng_tap < rng_vec) { @@ -86,7 +86,7 @@ lrand(void) x = (*rng_feed + *rng_tap) & MASK; *rng_feed = x; - unlock(&lk); + jehanne_unlock(&lk); return x; } diff --git a/sys/src/lib/c/port/malloc.c b/sys/src/lib/c/port/malloc.c index 34d2fb7..9b04714 100644 --- a/sys/src/lib/c/port/malloc.c +++ b/sys/src/lib/c/port/malloc.c @@ -87,10 +87,10 @@ plock(Pool *p) { Private *pv; pv = p->private; - lock(&pv->lk); + jehanne_lock(&pv->lk); if(pv->pid != 0) abort(); - pv->pid = getmainpid(); + pv->pid = jehanne_getmainpid(); } static void @@ -98,10 +98,10 @@ punlock(Pool *p) { Private *pv; pv = p->private; - if(pv->pid != getmainpid()) + if(pv->pid != jehanne_getmainpid()) abort(); pv->pid = 0; - unlock(&pv->lk); + jehanne_unlock(&pv->lk); } static int @@ -120,7 +120,7 @@ checkenv(void) if(n >= sizeof buf) n = sizeof(buf)-1; buf[n] = 0; - n = atoi(buf); + n = jehanne_atoi(buf); if(n == 0) n = -1; return n; @@ -140,7 +140,7 @@ pprint(Pool *p, char *fmt, ...) pv->printfd = 2; va_start(v, fmt); - vfprint(pv->printfd, fmt, v); + jehanne_vfprint(pv->printfd, fmt, v); va_end(v); } @@ -154,7 +154,7 @@ ppanic(Pool *p, char *fmt, ...) Private *pv; pv = p->private; - assert(canlock(&pv->lk)==0); + assert(jehanne_canlock(&pv->lk)==0); if(pv->printfd == 0) pv->printfd = checkenv(); @@ -163,7 +163,7 @@ ppanic(Pool *p, char *fmt, ...) msg = panicbuf; va_start(v, fmt); - n = vseprint(msg, msg+sizeof panicbuf, fmt, v) - msg; + n = jehanne_vseprint(msg, msg+sizeof panicbuf, fmt, v) - msg; write(2, "panic: ", 7); write(2, msg, n); write(2, "\n", 1); @@ -173,12 +173,12 @@ ppanic(Pool *p, char *fmt, ...) write(pv->printfd, "\n", 1); } va_end(v); -// unlock(&pv->lk); +// jehanne_unlock(&pv->lk); abort(); } /* - everything from here down should be the same in libc, libdebugmalloc, and the kernel - */ -/* - except the code for malloc(), which alternately doesn't clear or does. - */ +/* - except the code for jehanne_malloc(), which alternately doesn't clear or does. - */ /* * Npadlong is the number of uintptrs to leave at the beginning of @@ -201,37 +201,37 @@ enum { }; void* -malloc(size_t size) +jehanne_malloc(size_t size) { void *v; v = poolalloc(mainmem, size+Npadlong*sizeof(uintptr_t)); if(Npadlong && v != nil) { v = (uintptr_t*)v+Npadlong; - setmalloctag(v, getcallerpc()); - setrealloctag(v, 0); + jehanne_setmalloctag(v, jehanne_getcallerpc()); + jehanne_setrealloctag(v, 0); } return v; } void* -mallocz(uint32_t size, int clr) +jehanne_mallocz(uint32_t size, int clr) { void *v; v = poolalloc(mainmem, size+Npadlong*sizeof(uintptr_t)); if(Npadlong && v != nil){ v = (uintptr_t*)v+Npadlong; - setmalloctag(v, getcallerpc()); - setrealloctag(v, 0); + jehanne_setmalloctag(v, jehanne_getcallerpc()); + jehanne_setrealloctag(v, 0); } if(clr && v != nil) - memset(v, 0, size); + jehanne_memset(v, 0, size); return v; } void* -mallocalign(uint32_t size, uint32_t align, int32_t offset, uint32_t span) +jehanne_mallocalign(uint32_t size, uint32_t align, int32_t offset, uint32_t span) { void *v; @@ -239,26 +239,26 @@ mallocalign(uint32_t size, uint32_t align, int32_t offset, uint32_t span) offset-Npadlong*sizeof(uintptr_t), span); if(Npadlong && v != nil){ v = (uintptr_t*)v+Npadlong; - setmalloctag(v, getcallerpc()); - setrealloctag(v, 0); + jehanne_setmalloctag(v, jehanne_getcallerpc()); + jehanne_setrealloctag(v, 0); } return v; } void -free(void *v) +jehanne_free(void *v) { if(v != nil) poolfree(mainmem, (uintptr_t*)v-Npadlong); } void* -realloc(void *v, size_t size) +jehanne_realloc(void *v, size_t size) { void *nv; if(size == 0){ - free(v); + jehanne_free(v); return nil; } @@ -268,33 +268,33 @@ realloc(void *v, size_t size) if((nv = poolrealloc(mainmem, v, size))){ nv = (uintptr_t*)nv+Npadlong; - setrealloctag(nv, getcallerpc()); + jehanne_setrealloctag(nv, jehanne_getcallerpc()); if(v == nil) - setmalloctag(nv, getcallerpc()); + jehanne_setmalloctag(nv, jehanne_getcallerpc()); } return nv; } uint32_t -msize(void *v) +jehanne_msize(void *v) { return poolmsize(mainmem, (uintptr_t*)v-Npadlong)-Npadlong*sizeof(uintptr_t); } void* -calloc(uint32_t n, size_t szelem) +jehanne_calloc(uint32_t n, size_t szelem) { void *v; if(n > 1 && ((uint64_t)-1)/n < szelem) return nil; - if((v = mallocz(n*szelem, 1))) - setmalloctag(v, getcallerpc()); + if((v = jehanne_mallocz(n*szelem, 1))) + jehanne_setmalloctag(v, jehanne_getcallerpc()); return v; } void -setmalloctag(void *v, uintptr_t pc) +jehanne_setmalloctag(void *v, uintptr_t pc) { if(Npadlong <= MallocOffset || v == nil) return; @@ -302,7 +302,7 @@ setmalloctag(void *v, uintptr_t pc) } void -setrealloctag(void *v, uintptr_t pc) +jehanne_setrealloctag(void *v, uintptr_t pc) { if(Npadlong <= ReallocOffset || v == nil) return; @@ -310,7 +310,7 @@ setrealloctag(void *v, uintptr_t pc) } uintptr_t -getmalloctag(void *v) +jehanne_getmalloctag(void *v) { if(Npadlong <= MallocOffset) return ~0; @@ -318,7 +318,7 @@ getmalloctag(void *v) } uintptr_t -getrealloctag(void *v) +jehanne_getrealloctag(void *v) { if(Npadlong <= ReallocOffset) return ~0; @@ -326,7 +326,7 @@ getrealloctag(void *v) } void* -malloctopoolblock(void *v) +jehanne_malloctopoolblock(void *v) { if(v == nil) return nil; diff --git a/sys/src/lib/c/port/memccpy.c b/sys/src/lib/c/port/memccpy.c index d257185..0a9a09b 100644 --- a/sys/src/lib/c/port/memccpy.c +++ b/sys/src/lib/c/port/memccpy.c @@ -11,7 +11,7 @@ #include void* -memccpy(void *a1, const void *a2, int c, uint32_t n) +jehanne_memccpy(void *a1, const void *a2, int c, uint32_t n) { uint8_t *s1; const uint8_t *s2; diff --git a/sys/src/lib/c/port/memchr.c b/sys/src/lib/c/port/memchr.c index 18fddb6..db9d105 100644 --- a/sys/src/lib/c/port/memchr.c +++ b/sys/src/lib/c/port/memchr.c @@ -11,7 +11,7 @@ #include void* -memchr(const void *ap, int c, uint32_t n) +jehanne_memchr(const void *ap, int c, uint32_t n) { const char *sp; diff --git a/sys/src/lib/c/port/memcmp.c b/sys/src/lib/c/port/memcmp.c index a173f59..7c64311 100644 --- a/sys/src/lib/c/port/memcmp.c +++ b/sys/src/lib/c/port/memcmp.c @@ -11,7 +11,7 @@ #include int -memcmp(const void *a1, const void *a2, uint32_t n) +jehanne_memcmp(const void *a1, const void *a2, uint32_t n) { const char *s1, *s2; uint32_t c1, c2; diff --git a/sys/src/lib/c/port/memmove.c b/sys/src/lib/c/port/memmove.c index b1cbdb9..7ebf9cd 100644 --- a/sys/src/lib/c/port/memmove.c +++ b/sys/src/lib/c/port/memmove.c @@ -11,7 +11,7 @@ #include void* -memmove(void *a1, const void *a2, size_t n) +jehanne_memmove(void *a1, const void *a2, size_t n) { char *s1; const char *s2; @@ -39,7 +39,7 @@ back: } void* -memcpy(void *a1, const void *a2, size_t n) +jehanne_memcpy(void *a1, const void *a2, size_t n) { - return memmove(a1, a2, n); + return jehanne_memmove(a1, a2, n); } diff --git a/sys/src/lib/c/port/memset.c b/sys/src/lib/c/port/memset.c index 68fb415..69b4ca6 100644 --- a/sys/src/lib/c/port/memset.c +++ b/sys/src/lib/c/port/memset.c @@ -11,7 +11,7 @@ #include void* -memset(void *ap, int c, uint32_t n) +jehanne_memset(void *ap, int c, uint32_t n) { char *p; diff --git a/sys/src/lib/c/port/mktemp.c b/sys/src/lib/c/port/mktemp.c index b181359..2ab050b 100644 --- a/sys/src/lib/c/port/mktemp.c +++ b/sys/src/lib/c/port/mktemp.c @@ -11,14 +11,14 @@ #include char* -mktemp(char *as) +jehanne_mktemp(char *as) { char *s; unsigned pid; int i; char err[ERRMAX]; - pid = getpid(); + pid = jehanne_getpid(); s = as; while(*s++) ; @@ -29,7 +29,7 @@ mktemp(char *as) } s++; i = 'a'; - while(access(as, AEXIST) != -1) { + while(jehanne_access(as, AEXIST) != -1) { if (i == 'z') return "/"; *s = i++; diff --git a/sys/src/lib/c/port/muldiv.c b/sys/src/lib/c/port/muldiv.c index 81723ac..87e41c2 100644 --- a/sys/src/lib/c/port/muldiv.c +++ b/sys/src/lib/c/port/muldiv.c @@ -11,7 +11,7 @@ #include uint32_t -umuldiv(uint32_t a, uint32_t b, uint32_t c) +jehanne_umuldiv(uint32_t a, uint32_t b, uint32_t c) { double d; @@ -22,7 +22,7 @@ umuldiv(uint32_t a, uint32_t b, uint32_t c) } int32_t -muldiv(int32_t a, int32_t b, int32_t c) +jehanne_muldiv(int32_t a, int32_t b, int32_t c) { int s; int32_t v; @@ -40,7 +40,7 @@ muldiv(int32_t a, int32_t b, int32_t c) s = !s; c = -c; } - v = umuldiv(a, b, c); + v = jehanne_umuldiv(a, b, c); if(s) v = -v; return v; diff --git a/sys/src/lib/c/port/nan.c b/sys/src/lib/c/port/nan.c index ef75391..a4faaa1 100644 --- a/sys/src/lib/c/port/nan.c +++ b/sys/src/lib/c/port/nan.c @@ -15,7 +15,7 @@ #define NANSIGN (1<<31) double -NaN(void) +jehanne_NaN(void) { FPdbleword a; @@ -25,18 +25,18 @@ NaN(void) } int -isNaN(double d) +jehanne_isNaN(double d) { FPdbleword a; a.x = d; if((a.hi & NANMASK) != NANEXP) return 0; - return !isInf(d, 0); + return !jehanne_isInf(d, 0); } double -Inf(int sign) +jehanne_Inf(int sign) { FPdbleword a; @@ -48,7 +48,7 @@ Inf(int sign) } int -isInf(double d, int sign) +jehanne_isInf(double d, int sign) { FPdbleword a; diff --git a/sys/src/lib/c/port/needsrcquote.c b/sys/src/lib/c/port/needsrcquote.c index a0c3130..1084114 100644 --- a/sys/src/lib/c/port/needsrcquote.c +++ b/sys/src/lib/c/port/needsrcquote.c @@ -11,11 +11,11 @@ #include int -needsrcquote(int c) +jehanne_needsrcquote(int c) { if(c <= ' ') return 1; - if(utfrune("`^#*[]=|\\?${}()'<>&;", c)) + if(jehanne_utfrune("`^#*[]=|\\?${}()'<>&;", c)) return 1; return 0; } diff --git a/sys/src/lib/c/port/netmkaddr.c b/sys/src/lib/c/port/netmkaddr.c index ce18fcb..330bf61 100644 --- a/sys/src/lib/c/port/netmkaddr.c +++ b/sys/src/lib/c/port/netmkaddr.c @@ -15,7 +15,7 @@ * make an address, add the defaults */ char * -netmkaddr(const char *linear, const char *defnet, const char *defsrv) +jehanne_netmkaddr(const char *linear, const char *defnet, const char *defsrv) { static char addr[256]; char *cp; @@ -23,21 +23,21 @@ netmkaddr(const char *linear, const char *defnet, const char *defsrv) /* * dump network name */ - cp = strchr(linear, '!'); + cp = jehanne_strchr(linear, '!'); if(cp == 0){ if(defnet==0){ if(defsrv) - snprint(addr, sizeof(addr), "net!%s!%s", + jehanne_snprint(addr, sizeof(addr), "net!%s!%s", linear, defsrv); else - snprint(addr, sizeof(addr), "net!%s", linear); + jehanne_snprint(addr, sizeof(addr), "net!%s", linear); } else { if(defsrv) - snprint(addr, sizeof(addr), "%s!%s!%s", defnet, + jehanne_snprint(addr, sizeof(addr), "%s!%s!%s", defnet, linear, defsrv); else - snprint(addr, sizeof(addr), "%s!%s", defnet, + jehanne_snprint(addr, sizeof(addr), "%s!%s", defnet, linear); } return addr; @@ -46,7 +46,7 @@ netmkaddr(const char *linear, const char *defnet, const char *defsrv) /* * if there is already a service, use it */ - cp = strchr(cp+1, '!'); + cp = jehanne_strchr(cp+1, '!'); if(cp) return (char *)linear; @@ -55,7 +55,7 @@ netmkaddr(const char *linear, const char *defnet, const char *defsrv) */ if(defsrv == 0) return (char *)linear; - snprint(addr, sizeof(addr), "%s!%s", linear, defsrv); + jehanne_snprint(addr, sizeof(addr), "%s!%s", linear, defsrv); return addr; } diff --git a/sys/src/lib/c/port/nrand.c b/sys/src/lib/c/port/nrand.c index 6e005a4..a39aaa3 100644 --- a/sys/src/lib/c/port/nrand.c +++ b/sys/src/lib/c/port/nrand.c @@ -13,7 +13,7 @@ #define MASK 0x7fffffffL int -nrand(int n) +jehanne_nrand(int n) { int32_t slop, v; @@ -24,7 +24,7 @@ nrand(int n) /* and if n == 0, you deserve what you get */ slop = MASK % n; do - v = lrand(); + v = jehanne_lrand(); while(v <= slop); return v % n; } diff --git a/sys/src/lib/c/port/ntruerand.c b/sys/src/lib/c/port/ntruerand.c index 8bdfdb3..6bc5c37 100644 --- a/sys/src/lib/c/port/ntruerand.c +++ b/sys/src/lib/c/port/ntruerand.c @@ -11,7 +11,7 @@ #include uint32_t -ntruerand(uint32_t n) +jehanne_ntruerand(uint32_t n) { uint32_t m, r; @@ -25,7 +25,7 @@ ntruerand(uint32_t n) /* 2^32 - 2^32%n - 1 = (2^32 - 1) - (2*(2^31%n))%n */ m = 0xFFFFFFFFUL - (2*((1UL<<31)%n))%n; - while((r = truerand()) > m) + while((r = jehanne_truerand()) > m) ; return r%n; diff --git a/sys/src/lib/c/port/perror.c b/sys/src/lib/c/port/perror.c index 76ae90f..d4b2905 100644 --- a/sys/src/lib/c/port/perror.c +++ b/sys/src/lib/c/port/perror.c @@ -11,14 +11,14 @@ #include void -perror(const char *s) +jehanne_perror(const char *s) { char buf[ERRMAX]; buf[0] = '\0'; errstr(buf, sizeof buf); if(s && *s) - fprint(2, "%s: %s\n", s, buf); + jehanne_fprint(2, "%s: %s\n", s, buf); else - fprint(2, "%s\n", buf); + jehanne_fprint(2, "%s\n", buf); } diff --git a/sys/src/lib/c/port/pool.c b/sys/src/lib/c/port/pool.c index d04ab4b..4fe9641 100644 --- a/sys/src/lib/c/port/pool.c +++ b/sys/src/lib/c/port/pool.c @@ -558,7 +558,7 @@ poolnewarena(Pool *p, uint32_t asize) if(poolcompactl(p) == 0){ LOG(p, "pool too big: %llud+%lud > %llud\n", (uint64_t)p->cursize, asize, (uint64_t)p->maxsize); - werrstr("memory pool too large"); + jehanne_werrstr("memory pool too large"); } return; } @@ -828,7 +828,7 @@ arenacompact(Pool *p, Arena *a) break; case ALLOC_MAGIC: if(wb != b) { - memmove(wb, b, b->size); + jehanne_memmove(wb, b, b->size); p->move(_B2D(b), _B2D(wb)); compacted = 1; } @@ -935,7 +935,7 @@ poolallocl(Pool *p, uint32_t dsize) Alloc *ab; if(dsize >= 0x80000000UL){ /* for sanity, overflow */ - werrstr("invalid allocation size"); + jehanne_werrstr("invalid allocation size"); return nil; } @@ -953,7 +953,7 @@ poolallocl(Pool *p, uint32_t dsize) ab = trim(p, pooldel(p, fb), dsize); p->curalloc += ab->size; antagonism { - memset(B2D(p, ab), 0xDF, dsize); + jehanne_memset(B2D(p, ab), 0xDF, dsize); } return B2D(p, ab); } @@ -986,7 +986,7 @@ poolreallocl(Pool *p, void *v, uint32_t ndsize) if(nbsize <= a->size) { Returnblock: if(v != _B2D(a)) - memmove(_B2D(a), v, odsize); + jehanne_memmove(_B2D(a), v, odsize); a = trim(p, a, ndsize); p->curalloc -= obsize; p->curalloc += a->size; @@ -1031,9 +1031,9 @@ poolreallocl(Pool *p, void *v, uint32_t ndsize) } /* enough cleverness */ - memmove(nv, v, odsize); + jehanne_memmove(nv, v, odsize); antagonism { - memset((char*)nv+odsize, 0xDE, ndsize-odsize); + jehanne_memset((char*)nv+odsize, 0xDE, ndsize-odsize); } poolfreel(p, v); return nv; @@ -1109,7 +1109,7 @@ poolallocalignl(Pool *p, uint32_t dsize, uint32_t align, long offset, uint32_t s c = alignptr(c, align, offset); if((uintptr_t)c/span != (uintptr_t)(c+dsize-1)/span){ poolfreel(p, v); - werrstr("cannot satisfy dsize %lud span %lud with align %lud+%ld", dsize, span, align, offset); + jehanne_werrstr("cannot satisfy dsize %lud span %lud with align %lud+%ld", dsize, span, align, offset); return nil; } } @@ -1133,7 +1133,7 @@ poolallocalignl(Pool *p, uint32_t dsize, uint32_t align, long offset, uint32_t s p->curalloc += b->size; assert(D2B(p, c) == b); antagonism { - memset(c, 0xDD, dsize); + jehanne_memset(c, 0xDD, dsize); } return c; } @@ -1157,7 +1157,7 @@ poolfreel(Pool *p, void *v) ab->magic = DEAD_MAGIC; n = getdsize(ab)-8; if(n > 0) - memset((uint8_t*)v+8, 0xDA, n); + jehanne_memset((uint8_t*)v+8, 0xDA, n); return; } diff --git a/sys/src/lib/c/port/pow.c b/sys/src/lib/c/port/pow.c index 1c31159..32dea1e 100644 --- a/sys/src/lib/c/port/pow.c +++ b/sys/src/lib/c/port/pow.c @@ -11,7 +11,7 @@ #include double -pow(double x, double y) /* return x ^ y (exponentiation) */ +jehanne_pow(double x, double y) /* return x ^ y (exponentiation) */ { double xy, y1, ye; int32_t i; @@ -25,7 +25,7 @@ pow(double x, double y) /* return x ^ y (exponentiation) */ y = -y; flip = 1; } - y1 = modf(y, &ye); + y1 = jehanne_modf(y, &ye); if(y1 != 0.0){ if(x <= 0.) goto zreturn; @@ -33,7 +33,7 @@ pow(double x, double y) /* return x ^ y (exponentiation) */ y1 -= 1.; ye += 1.; } - xy = exp(y1 * log(x)); + xy = jehanne_exp(y1 * jehanne_log(x)); }else xy = 1.0; if(ye > 0x7FFFFFFF){ /* should be ~0UL but compiler can't convert double to ulong */ @@ -41,17 +41,17 @@ pow(double x, double y) /* return x ^ y (exponentiation) */ zreturn: if(x==0. && !flip) return 0.; - return NaN(); + return jehanne_NaN(); } if(flip){ if(y == .5) - return 1./sqrt(x); + return 1./jehanne_sqrt(x); y = -y; }else if(y == .5) - return sqrt(x); - return exp(y * log(x)); + return jehanne_sqrt(x); + return jehanne_exp(y * jehanne_log(x)); } - x = frexp(x, &ex); + x = jehanne_frexp(x, &ex); ey = 0; i = ye; if(i) @@ -74,5 +74,5 @@ pow(double x, double y) /* return x ^ y (exponentiation) */ xy = 1. / xy; ey = -ey; } - return ldexp(xy, ey); + return jehanne_ldexp(xy, ey); } diff --git a/sys/src/lib/c/port/pow10.c b/sys/src/lib/c/port/pow10.c index 59bb975..cec4868 100644 --- a/sys/src/lib/c/port/pow10.c +++ b/sys/src/lib/c/port/pow10.c @@ -40,7 +40,7 @@ double tab[] = }; double -pow10(int n) +jehanne_pow10(int n) { int m; @@ -49,10 +49,10 @@ pow10(int n) if(n < sizeof(tab)/sizeof(tab[0])) return 1/tab[n]; m = n/2; - return 1/(pow10(m) * pow10(n-m)); + return 1/(jehanne_pow10(m) * jehanne_pow10(n-m)); } if(n < sizeof(tab)/sizeof(tab[0])) return tab[n]; m = n/2; - return pow10(m) * pow10(n-m); + return jehanne_pow10(m) * jehanne_pow10(n-m); } diff --git a/sys/src/lib/c/port/qsort.c b/sys/src/lib/c/port/qsort.c index 6261ba7..dc2353f 100644 --- a/sys/src/lib/c/port/qsort.c +++ b/sys/src/lib/c/port/qsort.c @@ -120,7 +120,7 @@ qsorts(char *a, long n, Sort *p) } void -qsort(void *va, long n, int es, int (*cmp)(const void*, const void*)) +jehanne_qsort(void *va, long n, int es, int (*cmp)(const void*, const void*)) { Sort s; diff --git a/sys/src/lib/c/port/quote.c b/sys/src/lib/c/port/quote.c index 42b2f61..d210c55 100644 --- a/sys/src/lib/c/port/quote.c +++ b/sys/src/lib/c/port/quote.c @@ -16,12 +16,12 @@ extern int _needsquotes(const char*, int*); extern int _runeneedsquotes(const Rune*, int*); char* -unquotestrdup(const char *s) +jehanne_unquotestrdup(const char *s) { char *s1, *t, *ret; int quoting; - ret = s1 = strdup(s); /* return unquoted copy */ + ret = s1 = jehanne_strdup(s); /* return unquoted copy */ if(ret == nil) return ret; quoting = 0; @@ -49,17 +49,17 @@ unquotestrdup(const char *s) *s1++ = *t++; } if(t != s1) - memmove(s1, t, strlen(t)+1); + jehanne_memmove(s1, t, jehanne_strlen(t)+1); return ret; } Rune* -unquoterunestrdup(const Rune *s) +jehanne_unquoterunestrdup(const Rune *s) { Rune *s1, *t, *ret; int quoting; - ret = s1 = runestrdup(s); /* return unquoted copy */ + ret = s1 = jehanne_runestrdup(s); /* return unquoted copy */ if(ret == nil) return ret; quoting = 0; @@ -87,12 +87,12 @@ unquoterunestrdup(const Rune *s) *s1++ = *t++; } if(t != s1) - memmove(s1, t, (runestrlen(t)+1)*sizeof(Rune)); + jehanne_memmove(s1, t, (jehanne_runestrlen(t)+1)*sizeof(Rune)); return ret; } char* -quotestrdup(const char *s) +jehanne_quotestrdup(const char *s) { const char *t; char *u, *ret; @@ -100,9 +100,9 @@ quotestrdup(const char *s) Rune r; if(_needsquotes(s, "elen) == 0) - return strdup(s); + return jehanne_strdup(s); - ret = malloc(quotelen+1); + ret = jehanne_malloc(quotelen+1); if(ret == nil) return nil; u = ret; @@ -119,7 +119,7 @@ quotestrdup(const char *s) } Rune* -quoterunestrdup(const Rune *s) +jehanne_quoterunestrdup(const Rune *s) { const Rune *t; Rune *u, *ret; @@ -127,9 +127,9 @@ quoterunestrdup(const Rune *s) Rune r; if(_runeneedsquotes(s, "elen) == 0) - return runestrdup(s); + return jehanne_runestrdup(s); - ret = malloc((quotelen+1)*sizeof(Rune)); + ret = jehanne_malloc((quotelen+1)*sizeof(Rune)); if(ret == nil) return nil; u = ret; diff --git a/sys/src/lib/c/port/rand.c b/sys/src/lib/c/port/rand.c index 78184f5..125a1e5 100644 --- a/sys/src/lib/c/port/rand.c +++ b/sys/src/lib/c/port/rand.c @@ -11,7 +11,7 @@ #include int -rand(void) +jehanne_rand(void) { - return lrand() & 0x7fff; + return jehanne_lrand() & 0x7fff; } diff --git a/sys/src/lib/c/port/readn.c b/sys/src/lib/c/port/readn.c index d826cb5..13acc0a 100644 --- a/sys/src/lib/c/port/readn.c +++ b/sys/src/lib/c/port/readn.c @@ -11,7 +11,7 @@ #include int32_t -readn(int f, void *av, int32_t n) +jehanne_readn(int f, void *av, int32_t n) { char *a; int32_t m, t; diff --git a/sys/src/lib/c/port/rune.c b/sys/src/lib/c/port/rune.c index 10fae11..77d9ea0 100644 --- a/sys/src/lib/c/port/rune.c +++ b/sys/src/lib/c/port/rune.c @@ -33,7 +33,7 @@ enum }; int -chartorune(Rune *rune, const char *str) +jehanne_chartorune(Rune *rune, const char *str) { int c[UTFmax], i; Rune l; @@ -82,7 +82,7 @@ bad: } int -runetochar(char *str, const Rune *rune) +jehanne_runetochar(char *str, const Rune *rune) { int i, j; Rune c; @@ -126,15 +126,15 @@ runetochar(char *str, const Rune *rune) } int -runelen(Rune c) +jehanne_runelen(Rune c) { char str[10]; - return runetochar(str, &c); + return jehanne_runetochar(str, &c); } int -runenlen(const Rune *r, int nrune) +jehanne_runenlen(const Rune *r, int nrune) { int nb, i; Rune c; @@ -156,7 +156,7 @@ runenlen(const Rune *r, int nrune) } int -fullrune(const char *str, int n) +jehanne_fullrune(const char *str, int n) { int i; Rune c; diff --git a/sys/src/lib/c/port/runebase.c b/sys/src/lib/c/port/runebase.c index 7c970fb..61eda90 100644 --- a/sys/src/lib/c/port/runebase.c +++ b/sys/src/lib/c/port/runebase.c @@ -1950,7 +1950,7 @@ static Rune _base2[] = }; Rune -tobaserune(Rune c) +jehanne_tobaserune(Rune c) { Rune *p; @@ -1961,7 +1961,7 @@ tobaserune(Rune c) } int -isbaserune(Rune c) +jehanne_isbaserune(Rune c) { - return tobaserune(c) == c; + return jehanne_tobaserune(c) == c; } diff --git a/sys/src/lib/c/port/runestrcat.c b/sys/src/lib/c/port/runestrcat.c index 72d6945..4b9e36a 100644 --- a/sys/src/lib/c/port/runestrcat.c +++ b/sys/src/lib/c/port/runestrcat.c @@ -11,9 +11,9 @@ #include Rune* -runestrcat(Rune *s1, const Rune *s2) +jehanne_runestrcat(Rune *s1, const Rune *s2) { - runestrcpy(runestrchr(s1, 0), s2); + jehanne_runestrcpy(jehanne_runestrchr(s1, 0), s2); return s1; } diff --git a/sys/src/lib/c/port/runestrchr.c b/sys/src/lib/c/port/runestrchr.c index 0d7d43f..0d9f694 100644 --- a/sys/src/lib/c/port/runestrchr.c +++ b/sys/src/lib/c/port/runestrchr.c @@ -11,7 +11,7 @@ #include Rune* -runestrchr(const Rune *s, Rune c) +jehanne_runestrchr(const Rune *s, Rune c) { Rune c0 = c; Rune c1; diff --git a/sys/src/lib/c/port/runestrcmp.c b/sys/src/lib/c/port/runestrcmp.c index a2138b6..d94e7b6 100644 --- a/sys/src/lib/c/port/runestrcmp.c +++ b/sys/src/lib/c/port/runestrcmp.c @@ -11,7 +11,7 @@ #include int -runestrcmp(const Rune *s1, const Rune *s2) +jehanne_runestrcmp(const Rune *s1, const Rune *s2) { Rune c1, c2; diff --git a/sys/src/lib/c/port/runestrcpy.c b/sys/src/lib/c/port/runestrcpy.c index 73ef8af..e5007e7 100644 --- a/sys/src/lib/c/port/runestrcpy.c +++ b/sys/src/lib/c/port/runestrcpy.c @@ -11,7 +11,7 @@ #include Rune* -runestrcpy(Rune *s1, const Rune *s2) +jehanne_runestrcpy(Rune *s1, const Rune *s2) { Rune *os1; diff --git a/sys/src/lib/c/port/runestrdup.c b/sys/src/lib/c/port/runestrdup.c index e4d3aed..851c99b 100644 --- a/sys/src/lib/c/port/runestrdup.c +++ b/sys/src/lib/c/port/runestrdup.c @@ -11,14 +11,14 @@ #include Rune* -runestrdup(const Rune *s) +jehanne_runestrdup(const Rune *s) { Rune *ns; - ns = malloc(sizeof(Rune)*(runestrlen(s) + 1)); + ns = jehanne_malloc(sizeof(Rune)*(jehanne_runestrlen(s) + 1)); if(ns == 0) return 0; - setmalloctag(ns, getcallerpc()); + jehanne_setmalloctag(ns, jehanne_getcallerpc()); - return runestrcpy(ns, s); + return jehanne_runestrcpy(ns, s); } diff --git a/sys/src/lib/c/port/runestrecpy.c b/sys/src/lib/c/port/runestrecpy.c index 32bb9b0..36d1957 100644 --- a/sys/src/lib/c/port/runestrecpy.c +++ b/sys/src/lib/c/port/runestrecpy.c @@ -11,7 +11,7 @@ #include Rune* -runestrecpy(Rune *s1, Rune *es1, const Rune *s2) +jehanne_runestrecpy(Rune *s1, Rune *es1, const Rune *s2) { if(s1 >= es1) return s1; diff --git a/sys/src/lib/c/port/runestrlen.c b/sys/src/lib/c/port/runestrlen.c index fe25e2c..dca2628 100644 --- a/sys/src/lib/c/port/runestrlen.c +++ b/sys/src/lib/c/port/runestrlen.c @@ -11,8 +11,8 @@ #include int32_t -runestrlen(const Rune *s) +jehanne_runestrlen(const Rune *s) { - return runestrchr(s, 0) - s; + return jehanne_runestrchr(s, 0) - s; } diff --git a/sys/src/lib/c/port/runestrncat.c b/sys/src/lib/c/port/runestrncat.c index 74b18dd..6849ad3 100644 --- a/sys/src/lib/c/port/runestrncat.c +++ b/sys/src/lib/c/port/runestrncat.c @@ -11,12 +11,12 @@ #include Rune* -runestrncat(Rune *s1, const Rune *s2, int32_t n) +jehanne_runestrncat(Rune *s1, const Rune *s2, int32_t n) { Rune *os1; os1 = s1; - s1 = runestrchr(s1, 0); + s1 = jehanne_runestrchr(s1, 0); while(*s1++ = *s2++) if(--n < 0) { s1[-1] = 0; diff --git a/sys/src/lib/c/port/runestrncmp.c b/sys/src/lib/c/port/runestrncmp.c index dade20c..a36f863 100644 --- a/sys/src/lib/c/port/runestrncmp.c +++ b/sys/src/lib/c/port/runestrncmp.c @@ -11,7 +11,7 @@ #include int -runestrncmp(const Rune *s1, const Rune *s2, int32_t n) +jehanne_runestrncmp(const Rune *s1, const Rune *s2, int32_t n) { Rune c1, c2; diff --git a/sys/src/lib/c/port/runestrncpy.c b/sys/src/lib/c/port/runestrncpy.c index 5ceb341..63b3f4b 100644 --- a/sys/src/lib/c/port/runestrncpy.c +++ b/sys/src/lib/c/port/runestrncpy.c @@ -11,7 +11,7 @@ #include Rune* -runestrncpy(Rune *s1, const Rune *s2, int32_t n) +jehanne_runestrncpy(Rune *s1, const Rune *s2, int32_t n) { int i; Rune *os1; diff --git a/sys/src/lib/c/port/runestrrchr.c b/sys/src/lib/c/port/runestrrchr.c index 65c85f2..907796c 100644 --- a/sys/src/lib/c/port/runestrrchr.c +++ b/sys/src/lib/c/port/runestrrchr.c @@ -11,14 +11,14 @@ #include Rune* -runestrrchr(const Rune *s, Rune c) +jehanne_runestrrchr(const Rune *s, Rune c) { const Rune *r; if(c == 0) - return runestrchr(s, 0); + return jehanne_runestrchr(s, 0); r = 0; - while(s = runestrchr(s, c)) + while(s = jehanne_runestrchr(s, c)) r = s++; return (Rune *)r; } diff --git a/sys/src/lib/c/port/runestrstr.c b/sys/src/lib/c/port/runestrstr.c index 53cc4fa..249dc00 100644 --- a/sys/src/lib/c/port/runestrstr.c +++ b/sys/src/lib/c/port/runestrstr.c @@ -15,7 +15,7 @@ * 0 if none */ Rune* -runestrstr(const Rune *s1, const Rune *s2) +jehanne_runestrstr(const Rune *s1, const Rune *s2) { const Rune *p, *pa, *pb; int c0, c; @@ -24,7 +24,7 @@ runestrstr(const Rune *s1, const Rune *s2) if(c0 == 0) return (Rune*)s1; s2++; - for(p=runestrchr(s1, c0); p; p=runestrchr(p+1, c0)) { + for(p=jehanne_runestrchr(s1, c0); p; p=jehanne_runestrchr(p+1, c0)) { pa = p; for(pb=s2;; pb++) { c = *pb; diff --git a/sys/src/lib/c/port/runetypebody-6.2.0.h b/sys/src/lib/c/port/runetypebody-6.2.0.h index 21d6a36..d1085f4 100755 --- a/sys/src/lib/c/port/runetypebody-6.2.0.h +++ b/sys/src/lib/c/port/runetypebody-6.2.0.h @@ -27,7 +27,7 @@ static Rune __isspacer[] = { }; int -isspacerune(Rune c) +jehanne_isspacerune(Rune c) { Rune *p; @@ -83,7 +83,7 @@ static Rune __isdigitr[] = { }; int -isdigitrune(Rune c) +jehanne_isdigitrune(Rune c) { Rune *p; @@ -586,7 +586,7 @@ static Rune __isalphas[] = { }; int -isalpharune(Rune c) +jehanne_isalpharune(Rune c) { Rune *p; @@ -758,7 +758,7 @@ static Rune __isuppers[] = { }; int -isupperrune(Rune c) +jehanne_isupperrune(Rune c) { Rune *p; @@ -941,7 +941,7 @@ static Rune __islowers[] = { }; int -islowerrune(Rune c) +jehanne_islowerrune(Rune c) { Rune *p; @@ -1072,7 +1072,7 @@ static Rune __istitles[] = { }; int -istitlerune(Rune c) +jehanne_istitlerune(Rune c) { Rune *p; @@ -1260,7 +1260,7 @@ static Rune __touppers[] = { }; Rune -toupperrune(Rune c) +jehanne_toupperrune(Rune c) { Rune *p; @@ -1446,7 +1446,7 @@ static Rune __tolowers[] = { }; Rune -tolowerrune(Rune c) +jehanne_tolowerrune(Rune c) { Rune *p; @@ -1632,7 +1632,7 @@ static Rune __totitles[] = { }; Rune -totitlerune(Rune c) +jehanne_totitlerune(Rune c) { Rune *p; diff --git a/sys/src/lib/c/port/sin.c b/sys/src/lib/c/port/sin.c index 7e1688f..b34af98 100644 --- a/sys/src/lib/c/port/sin.c +++ b/sys/src/lib/c/port/sin.c @@ -41,9 +41,9 @@ sinus(double arg, int quad) } x *= 1/PIO2; /* underflow? */ if(x > 32764) { - y = modf(x, &e); + y = jehanne_modf(x, &e); e += quad; - modf(0.25*e, &f); + jehanne_modf(0.25*e, &f); quad = e - 4*f; } else { k = x; @@ -63,7 +63,7 @@ sinus(double arg, int quad) } double -cos(double arg) +jehanne_cos(double arg) { if(arg < 0) arg = -arg; @@ -71,7 +71,7 @@ cos(double arg) } double -sin(double arg) +jehanne_sin(double arg) { return sinus(arg, 0); } diff --git a/sys/src/lib/c/port/sinh.c b/sys/src/lib/c/port/sinh.c index 85a8893..b8bf268 100644 --- a/sys/src/lib/c/port/sinh.c +++ b/sys/src/lib/c/port/sinh.c @@ -11,7 +11,7 @@ #include /* - * sinh(arg) returns the hyperbolic sine of its floating- + * jehanne_sinh(arg) returns the hyperbolic sine of its floating- * point argument. * * The exponential function is called for arguments @@ -20,7 +20,7 @@ * A series is used for arguments smaller in magnitude than 0.5. * The coefficients are #2029 from Hart & Cheney. (20.36D) * - * cosh(arg) is computed from the exponential function for + * jehanne_cosh(arg) is computed from the exponential function for * all arguments. */ @@ -33,7 +33,7 @@ static double q1 = 0.1521517378790019070696485176e+5; static double q2 = -0.173678953558233699533450911e+3; double -sinh(double arg) +jehanne_sinh(double arg) { double temp, argsq; int sign; @@ -44,11 +44,11 @@ sinh(double arg) sign++; } if(arg > 21) { - temp = exp(arg)/2; + temp = jehanne_exp(arg)/2; goto out; } if(arg > 0.5) { - temp = (exp(arg) - exp(-arg))/2; + temp = (jehanne_exp(arg) - jehanne_exp(-arg))/2; goto out; } argsq = arg*arg; @@ -61,11 +61,11 @@ out: } double -cosh(double arg) +jehanne_cosh(double arg) { if(arg < 0) arg = - arg; if(arg > 21) - return exp(arg)/2; - return (exp(arg) + exp(-arg))/2; + return jehanne_exp(arg)/2; + return (jehanne_exp(arg) + jehanne_exp(-arg))/2; } diff --git a/sys/src/lib/c/port/strcat.c b/sys/src/lib/c/port/strcat.c index ec2b6f0..02ab678 100644 --- a/sys/src/lib/c/port/strcat.c +++ b/sys/src/lib/c/port/strcat.c @@ -11,9 +11,9 @@ #include char* -strcat(char *s1, const char *s2) +jehanne_strcat(char *s1, const char *s2) { - strcpy(strchr(s1, 0), s2); + jehanne_strcpy(jehanne_strchr(s1, 0), s2); return s1; } diff --git a/sys/src/lib/c/port/strchr.c b/sys/src/lib/c/port/strchr.c index 5261ec7..1bac7da 100644 --- a/sys/src/lib/c/port/strchr.c +++ b/sys/src/lib/c/port/strchr.c @@ -11,7 +11,7 @@ #include char* -strchr(const char *s, int c) +jehanne_strchr(const char *s, int c) { char c0 = c; char c1; diff --git a/sys/src/lib/c/port/strcmp.c b/sys/src/lib/c/port/strcmp.c index dc492e3..06137d9 100644 --- a/sys/src/lib/c/port/strcmp.c +++ b/sys/src/lib/c/port/strcmp.c @@ -13,7 +13,7 @@ #include int -strcmp(const char *s1, const char *s2) +jehanne_strcmp(const char *s1, const char *s2) { unsigned char c1, c2; diff --git a/sys/src/lib/c/port/strcpy.c b/sys/src/lib/c/port/strcpy.c index bfa21c4..2388ae7 100644 --- a/sys/src/lib/c/port/strcpy.c +++ b/sys/src/lib/c/port/strcpy.c @@ -12,12 +12,12 @@ #define N 10000 char* -strcpy(char *s1, const char *s2) +jehanne_strcpy(char *s1, const char *s2) { char *os1; os1 = s1; - while(!memccpy(s1, s2, 0, N)) { + while(!jehanne_memccpy(s1, s2, 0, N)) { s1 += N; s2 += N; } diff --git a/sys/src/lib/c/port/strcspn.c b/sys/src/lib/c/port/strcspn.c index dfb1f73..37933a0 100644 --- a/sys/src/lib/c/port/strcspn.c +++ b/sys/src/lib/c/port/strcspn.c @@ -13,12 +13,12 @@ #define N 256 int32_t -strcspn(const char *s, const char *b) +jehanne_strcspn(const char *s, const char *b) { const char *os; char map[N]; - memset(map, 0, N); + jehanne_memset(map, 0, N); for(;;) { map[*(uint8_t*)b] = 1; if(*b++ == 0) diff --git a/sys/src/lib/c/port/strdup.c b/sys/src/lib/c/port/strdup.c index 8a8aa69..cb61553 100644 --- a/sys/src/lib/c/port/strdup.c +++ b/sys/src/lib/c/port/strdup.c @@ -11,14 +11,14 @@ #include char* -strdup(const char *s) +jehanne_strdup(const char *s) { char *ns; - ns = malloc(strlen(s) + 1); + ns = jehanne_malloc(jehanne_strlen(s) + 1); if(ns == 0) return 0; - setmalloctag(ns, getcallerpc()); + jehanne_setmalloctag(ns, jehanne_getcallerpc()); - return strcpy(ns, s); + return jehanne_strcpy(ns, s); } diff --git a/sys/src/lib/c/port/strecpy.c b/sys/src/lib/c/port/strecpy.c index 3c5f42d..2a81819 100644 --- a/sys/src/lib/c/port/strecpy.c +++ b/sys/src/lib/c/port/strecpy.c @@ -11,11 +11,11 @@ #include char* -strecpy(char *to, char *e, const char *from) +jehanne_strecpy(char *to, char *e, const char *from) { if(to >= e) return to; - to = memccpy(to, from, '\0', e - to); + to = jehanne_memccpy(to, from, '\0', e - to); if(to == nil){ to = e - 1; *to = '\0'; diff --git a/sys/src/lib/c/port/strlen.c b/sys/src/lib/c/port/strlen.c index 91f5599..25d5227 100644 --- a/sys/src/lib/c/port/strlen.c +++ b/sys/src/lib/c/port/strlen.c @@ -11,7 +11,7 @@ #include int -strlen(const char *s) +jehanne_strlen(const char *s) { - return strchr(s, 0) - s; + return jehanne_strchr(s, 0) - s; } diff --git a/sys/src/lib/c/port/strncat.c b/sys/src/lib/c/port/strncat.c index 8f858f4..2b005fe 100644 --- a/sys/src/lib/c/port/strncat.c +++ b/sys/src/lib/c/port/strncat.c @@ -11,7 +11,7 @@ #include char* -strncat(char *s1, const char *s2, int32_t n) +jehanne_strncat(char *s1, const char *s2, int32_t n) { char *os1; diff --git a/sys/src/lib/c/port/strncmp.c b/sys/src/lib/c/port/strncmp.c index 8bfa938..f67f8b9 100644 --- a/sys/src/lib/c/port/strncmp.c +++ b/sys/src/lib/c/port/strncmp.c @@ -13,7 +13,7 @@ #include int -strncmp(const char *s1, const char *s2, int32_t n) +jehanne_strncmp(const char *s1, const char *s2, int32_t n) { unsigned char c1, c2; diff --git a/sys/src/lib/c/port/strncpy.c b/sys/src/lib/c/port/strncpy.c index 553f015..2bfb2b2 100644 --- a/sys/src/lib/c/port/strncpy.c +++ b/sys/src/lib/c/port/strncpy.c @@ -11,7 +11,7 @@ #include char* -strncpy(char *s1, const char *s2, uint32_t n) +jehanne_strncpy(char *s1, const char *s2, uint32_t n) { int i; char *os1; diff --git a/sys/src/lib/c/port/strpbrk.c b/sys/src/lib/c/port/strpbrk.c index 7c78dd3..9997086 100644 --- a/sys/src/lib/c/port/strpbrk.c +++ b/sys/src/lib/c/port/strpbrk.c @@ -12,12 +12,12 @@ #define N 256 char* -strpbrk(const char *cs, const char *cb) +jehanne_strpbrk(const char *cs, const char *cb) { char map[N]; uint8_t *s=(uint8_t*)cs, *b=(uint8_t*)cb; - memset(map, 0, N); + jehanne_memset(map, 0, N); for(;;) { map[*b] = 1; if(*b++ == 0) diff --git a/sys/src/lib/c/port/strrchr.c b/sys/src/lib/c/port/strrchr.c index d5847cf..55d9d61 100644 --- a/sys/src/lib/c/port/strrchr.c +++ b/sys/src/lib/c/port/strrchr.c @@ -11,14 +11,14 @@ #include char* -strrchr(const char *s, int c) +jehanne_strrchr(const char *s, int c) { const char *r; if(c == 0) - return strchr(s, 0); + return jehanne_strchr(s, 0); r = 0; - while(s = strchr(s, c)) + while(s = jehanne_strchr(s, c)) r = s++; return (char *)r; } diff --git a/sys/src/lib/c/port/strspn.c b/sys/src/lib/c/port/strspn.c index 7c17d92..6da1bc9 100644 --- a/sys/src/lib/c/port/strspn.c +++ b/sys/src/lib/c/port/strspn.c @@ -13,12 +13,12 @@ #define N 256 int32_t -strspn(const char *s, const char *b) +jehanne_strspn(const char *s, const char *b) { const char *os; char map[N]; - memset(map, 0, N); + jehanne_memset(map, 0, N); while(*b) map[*(uint8_t *)b++] = 1; os = s; diff --git a/sys/src/lib/c/port/strstr.c b/sys/src/lib/c/port/strstr.c index f7d0089..14de654 100644 --- a/sys/src/lib/c/port/strstr.c +++ b/sys/src/lib/c/port/strstr.c @@ -15,7 +15,7 @@ * 0 if none */ char* -strstr(const char *s1, const char *s2) +jehanne_strstr(const char *s1, const char *s2) { const char *p, *pa, *pb; int c0, c; @@ -24,7 +24,7 @@ strstr(const char *s1, const char *s2) if(c0 == 0) return (char*)s1; s2++; - for(p=strchr(s1, c0); p; p=strchr(p+1, c0)) { + for(p=jehanne_strchr(s1, c0); p; p=jehanne_strchr(p+1, c0)) { pa = p; for(pb=s2;; pb++) { c = *pb; diff --git a/sys/src/lib/c/port/strtod.c b/sys/src/lib/c/port/strtod.c index 87a3884..3a66c75 100644 --- a/sys/src/lib/c/port/strtod.c +++ b/sys/src/lib/c/port/strtod.c @@ -65,7 +65,7 @@ struct Tab }; double -strtod(const char *as, const char **aas) +jehanne_strtod(const char *as, const char **aas) { int na, ona, ex, dp, bp, c, i, flag, state; uint32_t low[Prec], hig[Prec], mid[Prec], num, den; @@ -200,7 +200,7 @@ strtod(const char *as, const char **aas) if(flag & Fesign) ex = -ex; dp += ex; - if(dp < -Maxe-Nmant/3) /* actually -Nmant*log(2)/log(10), but Nmant/3 close enough */ + if(dp < -Maxe-Nmant/3) /* actually -Nmant*jehanne_log(2)/jehanne_log(10), but Nmant/3 close enough */ goto ret0; // underflow by exp else if(dp > +Maxe) @@ -225,8 +225,8 @@ strtod(const char *as, const char **aas) ona = na; divby(a, &na, -bp-Bias+1); if(na < ona){ - memmove(a+ona-na, a, na); - memset(a, '0', ona-na); + jehanne_memmove(a+ona-na, a, na); + jehanne_memset(a, '0', ona-na); na = ona; } a[na] = 0; @@ -240,8 +240,8 @@ strtod(const char *as, const char **aas) num = num*10 + (c-'0'); den *= 10; } - low[0] = umuldiv(num, One, den); - hig[0] = umuldiv(num+1, One, den); + low[0] = jehanne_umuldiv(num, One, den); + hig[0] = jehanne_umuldiv(num+1, One, den); for(i=1; ibp; - if(memcmp(a, t->cmp, t->siz) > 0) + if(jehanne_memcmp(a, t->cmp, t->siz) > 0) d--; *dp -= d; *bp += b; @@ -505,7 +505,7 @@ mulascii(char *a, int *na, int *dp, int *bp) d = nelem(tab2)-1; t = tab2 + d; b = t->bp; - if(memcmp(a, t->cmp, t->siz) < 0) + if(jehanne_memcmp(a, t->cmp, t->siz) < 0) d--; p = a + *na; *bp -= b; @@ -522,7 +522,7 @@ xcmp(const char *a, char *b) while(c1 = *b++) { c2 = *a++; if(isupper(c2)) - c2 = tolower(c2); + c2 = jehanne_tolower(c2); if(c1 != c2) return 1; } diff --git a/sys/src/lib/c/port/strtok.c b/sys/src/lib/c/port/strtok.c index 4957e01..8456672 100644 --- a/sys/src/lib/c/port/strtok.c +++ b/sys/src/lib/c/port/strtok.c @@ -13,12 +13,12 @@ #define N 256 char* -strtok(char *s, char *b) +jehanne_strtok(char *s, char *b) { static char *under_rock; char map[N], *os; - memset(map, 0, N); + jehanne_memset(map, 0, N); while(*b) map[*(uint8_t*)b++] = 1; if(s == 0) diff --git a/sys/src/lib/c/port/strtol.c b/sys/src/lib/c/port/strtol.c index fc5aae5..7d56e7d 100644 --- a/sys/src/lib/c/port/strtol.c +++ b/sys/src/lib/c/port/strtol.c @@ -14,7 +14,7 @@ #define LONG_MIN -2147483648L int32_t -strtol(const char *nptr, char **endptr, int base) +jehanne_strtol(const char *nptr, char **endptr, int base) { const char *p; int32_t n, nn, m; diff --git a/sys/src/lib/c/port/strtoll.c b/sys/src/lib/c/port/strtoll.c index 16f8fa6..51e3b5a 100644 --- a/sys/src/lib/c/port/strtoll.c +++ b/sys/src/lib/c/port/strtoll.c @@ -14,7 +14,7 @@ #define VLONG_MIN (1LL<<63) int64_t -strtoll(const char *nptr, char **endptr, int base) +jehanne_strtoll(const char *nptr, char **endptr, int base) { const char *p; int64_t n, nn, m; diff --git a/sys/src/lib/c/port/strtoul.c b/sys/src/lib/c/port/strtoul.c index b06c654..81059a0 100644 --- a/sys/src/lib/c/port/strtoul.c +++ b/sys/src/lib/c/port/strtoul.c @@ -13,7 +13,7 @@ #define ULONG_MAX 4294967295UL uint32_t -strtoul(const char *nptr, char **endptr, int base) +jehanne_strtoul(const char *nptr, char **endptr, int base) { const char *p; uint32_t n, nn, m; diff --git a/sys/src/lib/c/port/strtoull.c b/sys/src/lib/c/port/strtoull.c index 0f06b1f..662128d 100644 --- a/sys/src/lib/c/port/strtoull.c +++ b/sys/src/lib/c/port/strtoull.c @@ -13,7 +13,7 @@ #define UVLONG_MAX (1LL<<63) uint64_t -strtoull(const char *nptr, char **endptr, int base) +jehanne_strtoull(const char *nptr, char **endptr, int base) { const char *p; uint64_t n, nn, m; diff --git a/sys/src/lib/c/port/tan.c b/sys/src/lib/c/port/tan.c index 06178ca..8907fae 100644 --- a/sys/src/lib/c/port/tan.c +++ b/sys/src/lib/c/port/tan.c @@ -27,7 +27,7 @@ static double q1 = 0.4765751362916483698926655581e+4; static double q2 = -0.1555033164031709966900124574e+3; double -tan(double arg) +jehanne_tan(double arg) { double temp, e, x, xsq; int flag, sign, i; @@ -39,7 +39,7 @@ tan(double arg) sign++; } arg = 2*arg/PIO2; /* overflow? */ - x = modf(arg, &e); + x = jehanne_modf(arg, &e); i = e; switch(i%4) { case 1: @@ -67,7 +67,7 @@ tan(double arg) if(flag) { if(temp == 0) - return NaN(); + return jehanne_NaN(); temp = 1/temp; } if(sign) diff --git a/sys/src/lib/c/port/tanh.c b/sys/src/lib/c/port/tanh.c index 7397966..590a419 100644 --- a/sys/src/lib/c/port/tanh.c +++ b/sys/src/lib/c/port/tanh.c @@ -11,7 +11,7 @@ #include /* - tanh(arg) computes the hyperbolic tangent of its floating + jehanne_tanh(arg) computes the hyperbolic tangent of its floating point argument. sinh and cosh are called except for large arguments, which @@ -19,16 +19,16 @@ */ double -tanh(double arg) +jehanne_tanh(double arg) { if(arg < 0) { arg = -arg; if(arg > 21) return -1; - return -sinh(arg)/cosh(arg); + return -jehanne_sinh(arg)/jehanne_cosh(arg); } if(arg > 21) return 1; - return sinh(arg)/cosh(arg); + return jehanne_sinh(arg)/jehanne_cosh(arg); } diff --git a/sys/src/lib/c/port/tokenize.c b/sys/src/lib/c/port/tokenize.c index 9b40c3c..7fee2dd 100644 --- a/sys/src/lib/c/port/tokenize.c +++ b/sys/src/lib/c/port/tokenize.c @@ -20,7 +20,7 @@ qtoken(char *s, char *sep) quoting = 0; t = s; /* s is output string, t is input string */ - while(*t!='\0' && (quoting || utfrune(sep, *t)==nil)){ + while(*t!='\0' && (quoting || jehanne_utfrune(sep, *t)==nil)){ if(*t != '\''){ *s++ = *t++; continue; @@ -57,7 +57,7 @@ etoken(char *t, const char *sep) /* move to end of next token */ quoting = 0; - while(*t!='\0' && (quoting || utfrune(sep, *t)==nil)){ + while(*t!='\0' && (quoting || jehanne_utfrune(sep, *t)==nil)){ if(*t != '\''){ t++; continue; @@ -82,12 +82,12 @@ etoken(char *t, const char *sep) } int -gettokens(char *s, char **args, int maxargs, const char *sep) +jehanne_gettokens(char *s, char **args, int maxargs, const char *sep) { int nargs; for(nargs=0; nargs int -toupper(int c) +jehanne_toupper(int c) { if(c < 'a' || c > 'z') @@ -19,7 +19,7 @@ toupper(int c) } int -tolower(int c) +jehanne_tolower(int c) { if(c < 'A' || c > 'Z') diff --git a/sys/src/lib/c/port/u16.c b/sys/src/lib/c/port/u16.c index defbbe8..63076b3 100644 --- a/sys/src/lib/c/port/u16.c +++ b/sys/src/lib/c/port/u16.c @@ -12,7 +12,7 @@ static char t16e[] = "0123456789ABCDEF"; int -dec16(uint8_t *out, int lim, const char *in, int n) +jehanne_dec16(uint8_t *out, int lim, const char *in, int n) { int c, w = 0, i = 0; uint8_t *start = out; @@ -43,7 +43,7 @@ exhausted: } int -enc16(char *out, int lim, const uint8_t *in, int n) +jehanne_enc16(char *out, int lim, const uint8_t *in, int n) { uint32_t c; char *eout = out + lim; diff --git a/sys/src/lib/c/port/u32.c b/sys/src/lib/c/port/u32.c index 2f3c900..978c382 100644 --- a/sys/src/lib/c/port/u32.c +++ b/sys/src/lib/c/port/u32.c @@ -11,7 +11,7 @@ #include int -dec32(uint8_t *dest, int ndest, const char *src, int nsrc) +jehanne_dec32(uint8_t *dest, int ndest, const char *src, int nsrc) { char *s, *tab; uint8_t *start; @@ -23,7 +23,7 @@ dec32(uint8_t *dest, int ndest, const char *src, int nsrc) tab = "23456789abcdefghijkmnpqrstuvwxyz"; while(nsrc>=8){ for(i=0; i<8; i++){ - s = strchr(tab,(int)src[i]); + s = jehanne_strchr(tab,(int)src[i]); u[i] = s ? s-tab : 0; } *dest++ = (u[0]<<3) | (0x7 & (u[1]>>2)); @@ -38,7 +38,7 @@ dec32(uint8_t *dest, int ndest, const char *src, int nsrc) if(nsrc == 1 || nsrc == 3 || nsrc == 6) return -1; for(i=0; i>2)); @@ -57,7 +57,7 @@ out: } int -enc32(char *dest, int ndest, const uint8_t *src, int nsrc) +jehanne_enc32(char *dest, int ndest, const uint8_t *src, int nsrc) { char *tab, *start; int j; diff --git a/sys/src/lib/c/port/u64.c b/sys/src/lib/c/port/u64.c index cd2a0dd..1bf264e 100644 --- a/sys/src/lib/c/port/u64.c +++ b/sys/src/lib/c/port/u64.c @@ -35,7 +35,7 @@ static uint8_t t64d[256] = { static char t64e[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int -dec64(uint8_t *out, int lim, const char *in, int n) +jehanne_dec64(uint8_t *out, int lim, const char *in, int n) { uint32_t b24; uint8_t *start = out; @@ -90,7 +90,7 @@ exhausted: } int -enc64(char *out, int lim, const uint8_t *in, int n) +jehanne_enc64(char *out, int lim, const uint8_t *in, int n) { int i; uint32_t b24; diff --git a/sys/src/lib/c/port/utfecpy.c b/sys/src/lib/c/port/utfecpy.c index 0871ab7..a1c3c3e 100644 --- a/sys/src/lib/c/port/utfecpy.c +++ b/sys/src/lib/c/port/utfecpy.c @@ -11,13 +11,13 @@ #include char* -utfecpy(char *to, char *e, const char *from) +jehanne_utfecpy(char *to, char *e, const char *from) { char *end; if(to >= e) return to; - end = memccpy(to, from, '\0', e - to); + end = jehanne_memccpy(to, from, '\0', e - to); if(end == nil){ end = e; while(end>to && (*--end&0xC0)==0x80) diff --git a/sys/src/lib/c/port/utflen.c b/sys/src/lib/c/port/utflen.c index 95d63cf..e978311 100644 --- a/sys/src/lib/c/port/utflen.c +++ b/sys/src/lib/c/port/utflen.c @@ -11,7 +11,7 @@ #include int -utflen(const char *s) +jehanne_utflen(const char *s) { int c; int32_t n; @@ -25,7 +25,7 @@ utflen(const char *s) return n; s++; } else - s += chartorune(&rune, s); + s += jehanne_chartorune(&rune, s); n++; } } diff --git a/sys/src/lib/c/port/utfnlen.c b/sys/src/lib/c/port/utfnlen.c index 16f1f15..1758201 100644 --- a/sys/src/lib/c/port/utfnlen.c +++ b/sys/src/lib/c/port/utfnlen.c @@ -11,7 +11,7 @@ #include int -utfnlen(const char *s, int32_t m) +jehanne_utfnlen(const char *s, int32_t m) { int c; int32_t n; @@ -27,9 +27,9 @@ utfnlen(const char *s, int32_t m) s++; continue; } - if(!fullrune(s, es-s)) + if(!jehanne_fullrune(s, es-s)) break; - s += chartorune(&rune, s); + s += jehanne_chartorune(&rune, s); } return n; } diff --git a/sys/src/lib/c/port/utfrrune.c b/sys/src/lib/c/port/utfrrune.c index af769bf..e0d12e6 100644 --- a/sys/src/lib/c/port/utfrrune.c +++ b/sys/src/lib/c/port/utfrrune.c @@ -11,14 +11,14 @@ #include char* -utfrrune(const char *s, Rune c) +jehanne_utfrrune(const char *s, Rune c) { int32_t c1; Rune r; const char *s1; if(c < Runesync) /* not part of utf sequence */ - return strrchr(s, c); + return jehanne_strrchr(s, c); s1 = 0; for(;;) { @@ -31,7 +31,7 @@ utfrrune(const char *s, Rune c) s++; continue; } - c1 = chartorune(&r, s); + c1 = jehanne_chartorune(&r, s); if(r == c) s1 = s; s += c1; diff --git a/sys/src/lib/c/port/utfrune.c b/sys/src/lib/c/port/utfrune.c index 6d5a2b1..9453259 100644 --- a/sys/src/lib/c/port/utfrune.c +++ b/sys/src/lib/c/port/utfrune.c @@ -11,14 +11,14 @@ #include char* -utfrune(const char *s, Rune c) +jehanne_utfrune(const char *s, Rune c) { int32_t c1; Rune r; int n; if(c < Runesync) /* not part of utf sequence */ - return strchr(s, c); + return jehanne_strchr(s, c); for(;;) { c1 = *(uint8_t*)s; @@ -30,7 +30,7 @@ utfrune(const char *s, Rune c) s++; continue; } - n = chartorune(&r, s); + n = jehanne_chartorune(&r, s); if(r == c) return (char*)s; s += n; diff --git a/sys/src/lib/c/port/utfutf.c b/sys/src/lib/c/port/utfutf.c index 3c0ba2d..f757fd4 100644 --- a/sys/src/lib/c/port/utfutf.c +++ b/sys/src/lib/c/port/utfutf.c @@ -16,20 +16,20 @@ * 0 if none */ char* -utfutf(const char *s1, const char *s2) +jehanne_utfutf(const char *s1, const char *s2) { const char *p; int32_t f, n1, n2; Rune r; - n1 = chartorune(&r, s2); + n1 = jehanne_chartorune(&r, s2); f = r; if(f <= Runesync) /* represents self */ - return strstr(s1, s2); + return jehanne_strstr(s1, s2); - n2 = strlen(s2); - for(p=s1; p=utfrune(p, f); p+=n1) - if(strncmp(p, s2, n2) == 0) + n2 = jehanne_strlen(s2); + for(p=s1; p=jehanne_utfrune(p, f); p+=n1) + if(jehanne_strncmp(p, s2, n2) == 0) return (char*)p; return 0; } diff --git a/sys/src/lib/complete/complete.c b/sys/src/lib/complete/complete.c index 0303edc..b2519cc 100644 --- a/sys/src/lib/complete/complete.c +++ b/sys/src/lib/complete/complete.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "complete.h" static int diff --git a/sys/src/lib/control/box.c b/sys/src/lib/control/box.c index cedf48f..9afa577 100644 --- a/sys/src/lib/control/box.c +++ b/sys/src/lib/control/box.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/button.c b/sys/src/lib/control/button.c index b81f078..5d33af0 100644 --- a/sys/src/lib/control/button.c +++ b/sys/src/lib/control/button.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/cache.c b/sys/src/lib/control/cache.c index dc3b1e2..b09876e 100644 --- a/sys/src/lib/control/cache.c +++ b/sys/src/lib/control/cache.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/control.c b/sys/src/lib/control/control.c index a286746..f893383 100644 --- a/sys/src/lib/control/control.c +++ b/sys/src/lib/control/control.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/entry.c b/sys/src/lib/control/entry.c index 83dbf52..5634eaf 100644 --- a/sys/src/lib/control/entry.c +++ b/sys/src/lib/control/entry.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/group.c b/sys/src/lib/control/group.c index d89a479..fbd55af 100644 --- a/sys/src/lib/control/group.c +++ b/sys/src/lib/control/group.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/keyboard.c b/sys/src/lib/control/keyboard.c index 88fc9a6..9366c60 100644 --- a/sys/src/lib/control/keyboard.c +++ b/sys/src/lib/control/keyboard.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/label.c b/sys/src/lib/control/label.c index 45fa010..3659d8f 100644 --- a/sys/src/lib/control/label.c +++ b/sys/src/lib/control/label.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/menu.c b/sys/src/lib/control/menu.c index 0ff1ba4..c5e072e 100644 --- a/sys/src/lib/control/menu.c +++ b/sys/src/lib/control/menu.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/radiobutton.c b/sys/src/lib/control/radiobutton.c index 1afb7b8..2c4f4dc 100644 --- a/sys/src/lib/control/radiobutton.c +++ b/sys/src/lib/control/radiobutton.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/slider.c b/sys/src/lib/control/slider.c index 9fbc592..bc9b2be 100644 --- a/sys/src/lib/control/slider.c +++ b/sys/src/lib/control/slider.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/tabs.c b/sys/src/lib/control/tabs.c index fbd83d7..1900529 100644 --- a/sys/src/lib/control/tabs.c +++ b/sys/src/lib/control/tabs.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/text.c b/sys/src/lib/control/text.c index 8d89516..288666b 100644 --- a/sys/src/lib/control/text.c +++ b/sys/src/lib/control/text.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/textbutton.c b/sys/src/lib/control/textbutton.c index 359ef2c..de10aef 100644 --- a/sys/src/lib/control/textbutton.c +++ b/sys/src/lib/control/textbutton.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/control/textbutton3.c b/sys/src/lib/control/textbutton3.c index 240d278..9852f30 100644 --- a/sys/src/lib/control/textbutton3.c +++ b/sys/src/lib/control/textbutton3.c @@ -12,7 +12,7 @@ * codes are mostly from /sys/src/libcontrol/textbutton.c */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/disk/disk.c b/sys/src/lib/disk/disk.c index e43a419..1a709b7 100644 --- a/sys/src/lib/disk/disk.c +++ b/sys/src/lib/disk/disk.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/sys/src/lib/disk/proto.c b/sys/src/lib/disk/proto.c index fe3c987..90f7faa 100644 --- a/sys/src/lib/disk/proto.c +++ b/sys/src/lib/disk/proto.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include <9P2000.h> diff --git a/sys/src/lib/disk/scsi.c b/sys/src/lib/disk/scsi.c index 9410272..bf530e3 100644 --- a/sys/src/lib/disk/scsi.c +++ b/sys/src/lib/disk/scsi.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include enum { diff --git a/sys/src/lib/disk/scsierrs.c b/sys/src/lib/disk/scsierrs.c index 8bc31cc..1bf68fe 100644 --- a/sys/src/lib/disk/scsierrs.c +++ b/sys/src/lib/disk/scsierrs.c @@ -2,7 +2,7 @@ * But the errors almost never change, so there's no hurry. */ #include -#include +#include typedef struct Err Err; struct Err diff --git a/sys/src/lib/disk/test.c b/sys/src/lib/disk/test.c index eed3713..b1c7d87 100644 --- a/sys/src/lib/disk/test.c +++ b/sys/src/lib/disk/test.c @@ -1,5 +1,5 @@ #include -#include +#include #include char *src[] = { "part", "disk", "guess" }; diff --git a/sys/src/lib/draw/alloc.c b/sys/src/lib/draw/alloc.c index 7e6ef83..a101ece 100644 --- a/sys/src/lib/draw/alloc.c +++ b/sys/src/lib/draw/alloc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Image* diff --git a/sys/src/lib/draw/allocimagemix.c b/sys/src/lib/draw/allocimagemix.c index 17a8e16..ef14bbd 100644 --- a/sys/src/lib/draw/allocimagemix.c +++ b/sys/src/lib/draw/allocimagemix.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Image* diff --git a/sys/src/lib/draw/arith.c b/sys/src/lib/draw/arith.c index f1420dd..b7b80a9 100644 --- a/sys/src/lib/draw/arith.c +++ b/sys/src/lib/draw/arith.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Point diff --git a/sys/src/lib/draw/bezier.c b/sys/src/lib/draw/bezier.c index 40a7bb8..e0753bd 100644 --- a/sys/src/lib/draw/bezier.c +++ b/sys/src/lib/draw/bezier.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #define PINC 32 /* realloc granularity */ diff --git a/sys/src/lib/draw/border.c b/sys/src/lib/draw/border.c index cbd5a2e..af069de 100644 --- a/sys/src/lib/draw/border.c +++ b/sys/src/lib/draw/border.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/buildfont.c b/sys/src/lib/draw/buildfont.c index bc15627..e2969b4 100644 --- a/sys/src/lib/draw/buildfont.c +++ b/sys/src/lib/draw/buildfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static char* diff --git a/sys/src/lib/draw/bytesperline.c b/sys/src/lib/draw/bytesperline.c index c829665..212dcfa 100644 --- a/sys/src/lib/draw/bytesperline.c +++ b/sys/src/lib/draw/bytesperline.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static diff --git a/sys/src/lib/draw/chan.c b/sys/src/lib/draw/chan.c index 16ee58f..0d40f95 100644 --- a/sys/src/lib/draw/chan.c +++ b/sys/src/lib/draw/chan.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static char channames[] = "rgbkamx"; diff --git a/sys/src/lib/draw/cloadimage.c b/sys/src/lib/draw/cloadimage.c index d45a070..878e28d 100644 --- a/sys/src/lib/draw/cloadimage.c +++ b/sys/src/lib/draw/cloadimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/computil.c b/sys/src/lib/draw/computil.c index b1d6f9e..35d53f4 100644 --- a/sys/src/lib/draw/computil.c +++ b/sys/src/lib/draw/computil.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/creadimage.c b/sys/src/lib/draw/creadimage.c index f4e5d23..707f26a 100644 --- a/sys/src/lib/draw/creadimage.c +++ b/sys/src/lib/draw/creadimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Image * diff --git a/sys/src/lib/draw/debug.c b/sys/src/lib/draw/debug.c index efac4cb..9f6624d 100644 --- a/sys/src/lib/draw/debug.c +++ b/sys/src/lib/draw/debug.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/defont.c b/sys/src/lib/draw/defont.c index d8676ff..a280ae6 100644 --- a/sys/src/lib/draw/defont.c +++ b/sys/src/lib/draw/defont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/draw.c b/sys/src/lib/draw/draw.c index cf353d5..9e35fc3 100644 --- a/sys/src/lib/draw/draw.c +++ b/sys/src/lib/draw/draw.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/drawrepl.c b/sys/src/lib/draw/drawrepl.c index ecb9458..4133a60 100644 --- a/sys/src/lib/draw/drawrepl.c +++ b/sys/src/lib/draw/drawrepl.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/egetrect.c b/sys/src/lib/draw/egetrect.c index b9bdc26..07baf4f 100644 --- a/sys/src/lib/draw/egetrect.c +++ b/sys/src/lib/draw/egetrect.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/ellipse.c b/sys/src/lib/draw/ellipse.c index 2fa2d83..fae9150 100644 --- a/sys/src/lib/draw/ellipse.c +++ b/sys/src/lib/draw/ellipse.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static diff --git a/sys/src/lib/draw/emenuhit.c b/sys/src/lib/draw/emenuhit.c index bfcb488..248be05 100644 --- a/sys/src/lib/draw/emenuhit.c +++ b/sys/src/lib/draw/emenuhit.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/draw/event.c b/sys/src/lib/draw/event.c index 97d2378..c4b8d83 100644 --- a/sys/src/lib/draw/event.c +++ b/sys/src/lib/draw/event.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/fmt.c b/sys/src/lib/draw/fmt.c index e1b8904..b94a27b 100644 --- a/sys/src/lib/draw/fmt.c +++ b/sys/src/lib/draw/fmt.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/font.c b/sys/src/lib/draw/font.c index 6e173ab..2a47a2d 100644 --- a/sys/src/lib/draw/font.c +++ b/sys/src/lib/draw/font.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static int fontresize(Font*, int, int, int); diff --git a/sys/src/lib/draw/freesubfont.c b/sys/src/lib/draw/freesubfont.c index a2abc2e..5661b75 100644 --- a/sys/src/lib/draw/freesubfont.c +++ b/sys/src/lib/draw/freesubfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/getdefont.c b/sys/src/lib/draw/getdefont.c index b3fde95..965a43f 100644 --- a/sys/src/lib/draw/getdefont.c +++ b/sys/src/lib/draw/getdefont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Subfont* diff --git a/sys/src/lib/draw/getrect.c b/sys/src/lib/draw/getrect.c index 8be56d2..64d4eed 100644 --- a/sys/src/lib/draw/getrect.c +++ b/sys/src/lib/draw/getrect.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/getsubfont.c b/sys/src/lib/draw/getsubfont.c index ef443e2..ca20413 100644 --- a/sys/src/lib/draw/getsubfont.c +++ b/sys/src/lib/draw/getsubfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/init.c b/sys/src/lib/draw/init.c index f182d76..5de4e81 100644 --- a/sys/src/lib/draw/init.c +++ b/sys/src/lib/draw/init.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Display *display; diff --git a/sys/src/lib/draw/keyboard.c b/sys/src/lib/draw/keyboard.c index 0cb86a2..1729d47 100644 --- a/sys/src/lib/draw/keyboard.c +++ b/sys/src/lib/draw/keyboard.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/line.c b/sys/src/lib/draw/line.c index 1a96f75..17d6e13 100644 --- a/sys/src/lib/draw/line.c +++ b/sys/src/lib/draw/line.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/loadimage.c b/sys/src/lib/draw/loadimage.c index 6d4c959..a779cb3 100644 --- a/sys/src/lib/draw/loadimage.c +++ b/sys/src/lib/draw/loadimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/menuhit.c b/sys/src/lib/draw/menuhit.c index 862b871..c635e90 100644 --- a/sys/src/lib/draw/menuhit.c +++ b/sys/src/lib/draw/menuhit.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/mkfont.c b/sys/src/lib/draw/mkfont.c index 2f6ced9..2fbb13c 100644 --- a/sys/src/lib/draw/mkfont.c +++ b/sys/src/lib/draw/mkfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/mouse.c b/sys/src/lib/draw/mouse.c index 2cd460a..5c3826b 100644 --- a/sys/src/lib/draw/mouse.c +++ b/sys/src/lib/draw/mouse.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/draw/namedimage.c b/sys/src/lib/draw/namedimage.c index 67174fb..02c426e 100644 --- a/sys/src/lib/draw/namedimage.c +++ b/sys/src/lib/draw/namedimage.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include Image* diff --git a/sys/src/lib/draw/newwindow.c b/sys/src/lib/draw/newwindow.c index 40bb524..b15c557 100644 --- a/sys/src/lib/draw/newwindow.c +++ b/sys/src/lib/draw/newwindow.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* Connect us to new window, if possible */ diff --git a/sys/src/lib/draw/openfont.c b/sys/src/lib/draw/openfont.c index 4f17a2e..ac59a2f 100644 --- a/sys/src/lib/draw/openfont.c +++ b/sys/src/lib/draw/openfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Font* diff --git a/sys/src/lib/draw/poly.c b/sys/src/lib/draw/poly.c index 0177128..106445b 100644 --- a/sys/src/lib/draw/poly.c +++ b/sys/src/lib/draw/poly.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static diff --git a/sys/src/lib/draw/readcolmap.c b/sys/src/lib/draw/readcolmap.c index a73c975..4a4d3ca 100644 --- a/sys/src/lib/draw/readcolmap.c +++ b/sys/src/lib/draw/readcolmap.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/draw/readimage.c b/sys/src/lib/draw/readimage.c index 42aa261..e98c2aa 100644 --- a/sys/src/lib/draw/readimage.c +++ b/sys/src/lib/draw/readimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Image* diff --git a/sys/src/lib/draw/readsubfont.c b/sys/src/lib/draw/readsubfont.c index b696adc..9aae121 100644 --- a/sys/src/lib/draw/readsubfont.c +++ b/sys/src/lib/draw/readsubfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Subfont* diff --git a/sys/src/lib/draw/rectclip.c b/sys/src/lib/draw/rectclip.c index f22a74f..82e39af 100644 --- a/sys/src/lib/draw/rectclip.c +++ b/sys/src/lib/draw/rectclip.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/replclipr.c b/sys/src/lib/draw/replclipr.c index 9bafd32..2b86809 100644 --- a/sys/src/lib/draw/replclipr.c +++ b/sys/src/lib/draw/replclipr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/draw/rgb.c b/sys/src/lib/draw/rgb.c index 3fcc7ed..7aef30a 100644 --- a/sys/src/lib/draw/rgb.c +++ b/sys/src/lib/draw/rgb.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/scroll.c b/sys/src/lib/draw/scroll.c index 5cf1ee3..7253671 100644 --- a/sys/src/lib/draw/scroll.c +++ b/sys/src/lib/draw/scroll.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/string.c b/sys/src/lib/draw/string.c index 9cea647..b7b5097 100644 --- a/sys/src/lib/draw/string.c +++ b/sys/src/lib/draw/string.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include enum diff --git a/sys/src/lib/draw/stringbg.c b/sys/src/lib/draw/stringbg.c index a556dea..b43a863 100644 --- a/sys/src/lib/draw/stringbg.c +++ b/sys/src/lib/draw/stringbg.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Point diff --git a/sys/src/lib/draw/stringsubfont.c b/sys/src/lib/draw/stringsubfont.c index b53efbf..bc9467f 100644 --- a/sys/src/lib/draw/stringsubfont.c +++ b/sys/src/lib/draw/stringsubfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Point diff --git a/sys/src/lib/draw/stringwidth.c b/sys/src/lib/draw/stringwidth.c index 37ec380..d5cf223 100644 --- a/sys/src/lib/draw/stringwidth.c +++ b/sys/src/lib/draw/stringwidth.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static Rune empty[] = { 0 }; diff --git a/sys/src/lib/draw/subfont.c b/sys/src/lib/draw/subfont.c index b1ca11e..3854059 100644 --- a/sys/src/lib/draw/subfont.c +++ b/sys/src/lib/draw/subfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include Subfont* diff --git a/sys/src/lib/draw/subfontcache.c b/sys/src/lib/draw/subfontcache.c index fae1cce..28e185e 100644 --- a/sys/src/lib/draw/subfontcache.c +++ b/sys/src/lib/draw/subfontcache.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/subfontname.c b/sys/src/lib/draw/subfontname.c index 19fdd6f..1d40047 100644 --- a/sys/src/lib/draw/subfontname.c +++ b/sys/src/lib/draw/subfontname.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/test.c b/sys/src/lib/draw/test.c index 763ff54..1fe6726 100644 --- a/sys/src/lib/draw/test.c +++ b/sys/src/lib/draw/test.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include diff --git a/sys/src/lib/draw/unloadimage.c b/sys/src/lib/draw/unloadimage.c index e11638c..de5cdac 100644 --- a/sys/src/lib/draw/unloadimage.c +++ b/sys/src/lib/draw/unloadimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/draw/window.c b/sys/src/lib/draw/window.c index a805a0b..1a8791b 100644 --- a/sys/src/lib/draw/window.c +++ b/sys/src/lib/draw/window.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include typedef struct Memimage Memimage; diff --git a/sys/src/lib/draw/writecolmap.c b/sys/src/lib/draw/writecolmap.c index 25aea9b..7a272b8 100644 --- a/sys/src/lib/draw/writecolmap.c +++ b/sys/src/lib/draw/writecolmap.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/draw/writeimage.c b/sys/src/lib/draw/writeimage.c index 73fc005..2f206c6 100644 --- a/sys/src/lib/draw/writeimage.c +++ b/sys/src/lib/draw/writeimage.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #define HSHIFT 3 /* HSHIFT==5 runs slightly faster, but hash table is 64x bigger */ diff --git a/sys/src/lib/draw/writesubfont.c b/sys/src/lib/draw/writesubfont.c index 04e372b..6913f55 100644 --- a/sys/src/lib/draw/writesubfont.c +++ b/sys/src/lib/draw/writesubfont.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static diff --git a/sys/src/lib/flate/adler.c b/sys/src/lib/flate/adler.c index 464ad25..ce5f132 100644 --- a/sys/src/lib/flate/adler.c +++ b/sys/src/lib/flate/adler.c @@ -1,5 +1,5 @@ #include -#include +#include #include enum diff --git a/sys/src/lib/flate/crc.c b/sys/src/lib/flate/crc.c index c4978bd..7674b02 100644 --- a/sys/src/lib/flate/crc.c +++ b/sys/src/lib/flate/crc.c @@ -1,5 +1,5 @@ #include -#include +#include #include uint32_t* diff --git a/sys/src/lib/flate/deflate.c b/sys/src/lib/flate/deflate.c index 359e990..deeeb9e 100644 --- a/sys/src/lib/flate/deflate.c +++ b/sys/src/lib/flate/deflate.c @@ -1,5 +1,5 @@ #include -#include +#include #include typedef struct Chain Chain; diff --git a/sys/src/lib/flate/deflateblock.c b/sys/src/lib/flate/deflateblock.c index f004b45..dcaaa1f 100644 --- a/sys/src/lib/flate/deflateblock.c +++ b/sys/src/lib/flate/deflateblock.c @@ -1,5 +1,5 @@ #include -#include +#include #include typedef struct Block Block; diff --git a/sys/src/lib/flate/deflatezlib.c b/sys/src/lib/flate/deflatezlib.c index 1b22539..c834f4a 100644 --- a/sys/src/lib/flate/deflatezlib.c +++ b/sys/src/lib/flate/deflatezlib.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "zlib.h" diff --git a/sys/src/lib/flate/deflatezlibblock.c b/sys/src/lib/flate/deflatezlibblock.c index 35c992f..89d0247 100644 --- a/sys/src/lib/flate/deflatezlibblock.c +++ b/sys/src/lib/flate/deflatezlibblock.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "zlib.h" diff --git a/sys/src/lib/flate/flateerr.c b/sys/src/lib/flate/flateerr.c index e442fd5..564ac85 100644 --- a/sys/src/lib/flate/flateerr.c +++ b/sys/src/lib/flate/flateerr.c @@ -1,5 +1,5 @@ #include -#include +#include #include char * diff --git a/sys/src/lib/flate/inflate.c b/sys/src/lib/flate/inflate.c index dd7d754..04fd970 100644 --- a/sys/src/lib/flate/inflate.c +++ b/sys/src/lib/flate/inflate.c @@ -1,5 +1,5 @@ #include -#include +#include #include enum { diff --git a/sys/src/lib/flate/inflateblock.c b/sys/src/lib/flate/inflateblock.c index eaef859..0b05d68 100644 --- a/sys/src/lib/flate/inflateblock.c +++ b/sys/src/lib/flate/inflateblock.c @@ -1,5 +1,5 @@ #include -#include +#include #include typedef struct Block Block; diff --git a/sys/src/lib/flate/inflatezlib.c b/sys/src/lib/flate/inflatezlib.c index b08d3b5..db897d1 100644 --- a/sys/src/lib/flate/inflatezlib.c +++ b/sys/src/lib/flate/inflatezlib.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "zlib.h" diff --git a/sys/src/lib/flate/inflatezlibblock.c b/sys/src/lib/flate/inflatezlibblock.c index c046224..963e22f 100644 --- a/sys/src/lib/flate/inflatezlibblock.c +++ b/sys/src/lib/flate/inflatezlibblock.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "zlib.h" diff --git a/sys/src/lib/frame/frbox.c b/sys/src/lib/frame/frbox.c index b77ab0b..4ab7d1d 100644 --- a/sys/src/lib/frame/frbox.c +++ b/sys/src/lib/frame/frbox.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frdelete.c b/sys/src/lib/frame/frdelete.c index 2b2c529..07294ec 100644 --- a/sys/src/lib/frame/frdelete.c +++ b/sys/src/lib/frame/frdelete.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frdraw.c b/sys/src/lib/frame/frdraw.c index 9a89fee..673792e 100644 --- a/sys/src/lib/frame/frdraw.c +++ b/sys/src/lib/frame/frdraw.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frinit.c b/sys/src/lib/frame/frinit.c index 5f96bc6..c1a01fc 100644 --- a/sys/src/lib/frame/frinit.c +++ b/sys/src/lib/frame/frinit.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frinsert.c b/sys/src/lib/frame/frinsert.c index 1951e4d..ea046cd 100644 --- a/sys/src/lib/frame/frinsert.c +++ b/sys/src/lib/frame/frinsert.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frptofchar.c b/sys/src/lib/frame/frptofchar.c index 2edc4e1..6425171 100644 --- a/sys/src/lib/frame/frptofchar.c +++ b/sys/src/lib/frame/frptofchar.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frselect.c b/sys/src/lib/frame/frselect.c index 473e0ce..ea77c85 100644 --- a/sys/src/lib/frame/frselect.c +++ b/sys/src/lib/frame/frselect.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frstr.c b/sys/src/lib/frame/frstr.c index ab4527d..1b40657 100644 --- a/sys/src/lib/frame/frstr.c +++ b/sys/src/lib/frame/frstr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/frame/frutil.c b/sys/src/lib/frame/frutil.c index 3ab8947..f297642 100644 --- a/sys/src/lib/frame/frutil.c +++ b/sys/src/lib/frame/frutil.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ip/bo.c b/sys/src/lib/ip/bo.c index 1819dbe..bc9dfa1 100644 --- a/sys/src/lib/ip/bo.c +++ b/sys/src/lib/ip/bo.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/ip/classmask.c b/sys/src/lib/ip/classmask.c index e058fc0..9b5b6f7 100644 --- a/sys/src/lib/ip/classmask.c +++ b/sys/src/lib/ip/classmask.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static uint8_t classmask[4][16] = { diff --git a/sys/src/lib/ip/eipfmt.c b/sys/src/lib/ip/eipfmt.c index aca30ef..fc74930 100644 --- a/sys/src/lib/ip/eipfmt.c +++ b/sys/src/lib/ip/eipfmt.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include enum diff --git a/sys/src/lib/ip/equivip.c b/sys/src/lib/ip/equivip.c index d20ce6a..d6c9ed6 100644 --- a/sys/src/lib/ip/equivip.c +++ b/sys/src/lib/ip/equivip.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/ip/ipaux.c b/sys/src/lib/ip/ipaux.c index 4150a77..80d996a 100644 --- a/sys/src/lib/ip/ipaux.c +++ b/sys/src/lib/ip/ipaux.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include /* diff --git a/sys/src/lib/ip/myetheraddr.c b/sys/src/lib/ip/myetheraddr.c index dd844ec..4e5ccbe 100644 --- a/sys/src/lib/ip/myetheraddr.c +++ b/sys/src/lib/ip/myetheraddr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include int diff --git a/sys/src/lib/ip/myipaddr.c b/sys/src/lib/ip/myipaddr.c index 6ed196e..03b46de 100644 --- a/sys/src/lib/ip/myipaddr.c +++ b/sys/src/lib/ip/myipaddr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static uint8_t loopbacknet[IPaddrlen] = { diff --git a/sys/src/lib/ip/parseether.c b/sys/src/lib/ip/parseether.c index 2a146ce..435d936 100644 --- a/sys/src/lib/ip/parseether.c +++ b/sys/src/lib/ip/parseether.c @@ -8,7 +8,7 @@ */ #include -#include +#include int parseether(uint8_t *to, char *from) diff --git a/sys/src/lib/ip/parseip.c b/sys/src/lib/ip/parseip.c index ea1ec6d..da832ce 100644 --- a/sys/src/lib/ip/parseip.c +++ b/sys/src/lib/ip/parseip.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ip/readipifc.c b/sys/src/lib/ip/readipifc.c index ff441af..59df146 100644 --- a/sys/src/lib/ip/readipifc.c +++ b/sys/src/lib/ip/readipifc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ip/testreadipifc.c b/sys/src/lib/ip/testreadipifc.c index 155894c..ea857f5 100644 --- a/sys/src/lib/ip/testreadipifc.c +++ b/sys/src/lib/ip/testreadipifc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include void diff --git a/sys/src/lib/memdraw/alloc.c b/sys/src/lib/memdraw/alloc.c index 9830390..2a94b00 100644 --- a/sys/src/lib/memdraw/alloc.c +++ b/sys/src/lib/memdraw/alloc.c @@ -20,7 +20,7 @@ memimagemove(void *from, void *to) md = *(Memdata**)to; if(md->base != from){ - print("compacted data not right: #%p\n", md->base); + jehanne_print("compacted data not right: #%p\n", md->base); abort(); } md->base = to; @@ -37,17 +37,17 @@ allocmemimaged(Rectangle r, uint32_t chan, Memdata *md) Memimage *i; if(Dx(r) <= 0 || Dy(r) <= 0){ - werrstr("bad rectangle %R", r); + jehanne_werrstr("bad rectangle %R", r); return nil; } if((d = chantodepth(chan)) == 0) { - werrstr("bad channel descriptor %.8lux", chan); + jehanne_werrstr("bad channel descriptor %.8lux", chan); return nil; } l = wordsperline(r, d); - i = mallocz(sizeof(Memimage), 1); + i = jehanne_mallocz(sizeof(Memimage), 1); if(i == nil) return nil; @@ -66,7 +66,7 @@ allocmemimaged(Rectangle r, uint32_t chan, Memdata *md) i->layer = nil; i->cmap = memdefcmap; if(memsetchan(i, chan) < 0){ - free(i); + jehanne_free(i); return nil; } return i; @@ -82,13 +82,13 @@ allocmemimage(Rectangle r, uint32_t chan) Memimage *i; if((d = chantodepth(chan)) == 0) { - werrstr("bad channel descriptor %.8lux", chan); + jehanne_werrstr("bad channel descriptor %.8lux", chan); return nil; } l = wordsperline(r, d); nw = l*Dy(r); - md = malloc(sizeof(Memdata)); + md = jehanne_malloc(sizeof(Memdata)); if(md == nil) return nil; @@ -96,7 +96,7 @@ allocmemimage(Rectangle r, uint32_t chan) md->base = poolalloc(imagmem, sizeof(Memdata*)+(1+nw)*sizeof(uint32_t)); if(md->base == nil){ - free(md); + jehanne_free(md); return nil; } @@ -104,7 +104,7 @@ allocmemimage(Rectangle r, uint32_t chan) *(Memdata**)p = md; p += sizeof(Memdata*); - *(uint32_t*)p = getcallerpc(); + *(uint32_t*)p = jehanne_getcallerpc(); p += sizeof(uint32_t); /* if this changes, memimagemove must change too */ @@ -114,7 +114,7 @@ allocmemimage(Rectangle r, uint32_t chan) i = allocmemimaged(r, chan, md); if(i == nil){ poolfree(imagmem, md->base); - free(md); + jehanne_free(md); return nil; } md->imref = i; @@ -129,9 +129,9 @@ freememimage(Memimage *i) if(i->data->ref-- == 1 && i->data->allocd){ if(i->data->base) poolfree(imagmem, i->data->base); - free(i->data); + jehanne_free(i->data); } - free(i); + jehanne_free(i); } /* @@ -175,7 +175,7 @@ memsetchan(Memimage *i, uint32_t chan) int bytes; if((d = chantodepth(chan)) == 0) { - werrstr("bad channel descriptor"); + jehanne_werrstr("bad channel descriptor"); return -1; } @@ -186,7 +186,7 @@ memsetchan(Memimage *i, uint32_t chan) for(cc=chan, j=0, k=0; cc; j+=NBITS(cc), cc>>=8, k++){ t=TYPE(cc); if(t < 0 || t >= NChan){ - werrstr("bad channel string"); + jehanne_werrstr("bad channel string"); return -1; } if(t == CGrey) diff --git a/sys/src/lib/memdraw/arctest.c b/sys/src/lib/memdraw/arctest.c index a9e4d25..58572e7 100644 --- a/sys/src/lib/memdraw/arctest.c +++ b/sys/src/lib/memdraw/arctest.c @@ -30,24 +30,24 @@ main(int argc, char **argv) int64_t del; if (argc != 2) { - fprint(2, "usage: arctest number\n"); - exits("usage"); + jehanne_fprint(2, "usage: arctest number\n"); + jehanne_exits("usage"); } memimageinit(); x = allocmemimage(Rect(0,0,1000,1000), CMAP8); - n = atoi(argv[1]); + n = jehanne_atoi(argv[1]); - t0 = nsec(); - t0 = nsec(); - t0 = nsec(); - t1 = nsec(); + t0 = jehanne_nsec(); + t0 = jehanne_nsec(); + t0 = jehanne_nsec(); + t1 = jehanne_nsec(); del = t1-t0; - t0 = nsec(); + t0 = jehanne_nsec(); for(i=0; i3){ - werrstr("creadimage: bad ldepth %d", ldepth); + jehanne_werrstr("creadimage: bad ldepth %d", ldepth); return nil; } chan = drawld2chan[ldepth]; } - r.min.x=atoi(hdr+1*12); - r.min.y=atoi(hdr+2*12); - r.max.x=atoi(hdr+3*12); - r.max.y=atoi(hdr+4*12); + r.min.x=jehanne_atoi(hdr+1*12); + r.min.y=jehanne_atoi(hdr+2*12); + r.max.x=jehanne_atoi(hdr+3*12); + r.max.y=jehanne_atoi(hdr+4*12); if(r.min.x>r.max.x || r.min.y>r.max.y){ - werrstr("creadimage: bad rectangle"); + jehanne_werrstr("creadimage: bad rectangle"); return nil; } @@ -70,36 +70,36 @@ creadmemimage(int fd) if(i == nil) return nil; ncblock = _compblocksize(r, i->depth); - buf = malloc(ncblock); + buf = jehanne_malloc(ncblock); if(buf == nil) goto Errout; miny = r.min.y; while(miny != r.max.y){ - if(readn(fd, hdr, 2*12) != 2*12){ + if(jehanne_readn(fd, hdr, 2*12) != 2*12){ Shortread: - werrstr("readmemimage: short read"); + jehanne_werrstr("readmemimage: short read"); Errout: freememimage(i); - free(buf); + jehanne_free(buf); return nil; } - maxy = atoi(hdr+0*12); - nb = atoi(hdr+1*12); + maxy = jehanne_atoi(hdr+0*12); + nb = jehanne_atoi(hdr+1*12); if(maxy<=miny || r.max.ywidth*sizeof(uint32_t); - n = atoi(hdr); + n = jehanne_atoi(hdr); p = hdr+3*12; - fc = malloc(sizeof(Fontchar)*(n+1)); + fc = jehanne_malloc(sizeof(Fontchar)*(n+1)); if(fc == 0){ freememimage(i); return 0; } _unpackinfo(fc, (uint8_t*)p, n); - f = allocmemsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i); + f = allocmemsubfont("*default*", n, jehanne_atoi(hdr+12), jehanne_atoi(hdr+24), fc, i); if(f == 0){ freememimage(i); - free(fc); + jehanne_free(fc); return 0; } return f; diff --git a/sys/src/lib/memdraw/draw.c b/sys/src/lib/memdraw/draw.c index 0ad7ab6..1f5cd4b 100644 --- a/sys/src/lib/memdraw/draw.c +++ b/sys/src/lib/memdraw/draw.c @@ -61,15 +61,15 @@ memimageinit(void) didinit = 1; - if(strcmp(imagmem->name, "Image") == 0 || strcmp(imagmem->name, "image") == 0) + if(jehanne_strcmp(imagmem->name, "Image") == 0 || jehanne_strcmp(imagmem->name, "image") == 0) imagmem->move = memimagemove; mktables(); _memmkcmap(); - fmtinstall('R', Rfmt); - fmtinstall('P', Pfmt); - fmtinstall('b', _ifmt); + jehanne_fmtinstall('R', Rfmt); + jehanne_fmtinstall('P', Pfmt); + jehanne_fmtinstall('b', _ifmt); memones = allocmemimage(Rect(0,0,1,1), GREY1); memones->flags |= Frepl; @@ -103,7 +103,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask if(mask == nil) mask = memopaque; - DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1); + DBG jehanne_print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1); if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){ return; @@ -130,7 +130,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask par.srgba = imgtorgba(src, par.sval); par.sdval = rgbatoimg(dst, par.srgba); if((par.srgba&0xFF) == 0 && (op&DoutS)){ - DBG print("fill with transparent source\n"); + DBG jehanne_print("fill with transparent source\n"); return; /* no-op successfully handled */ } } @@ -141,7 +141,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask if(Dx(mask->r)==1 && Dy(mask->r)==1){ par.mval = pixelbits(mask, mask->r.min); if(par.mval == 0 && (op&DoutS)){ - DBG print("fill with zero mask\n"); + DBG jehanne_print("fill with zero mask\n"); return; /* no-op successfully handled */ } par.state |= Simplemask; @@ -151,7 +151,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask } } - DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); + DBG jehanne_print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); /* * Now that we've clipped the parameters down to be consistent, we @@ -165,17 +165,17 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask * which checks to see if there is anything it can help with. * There could be an if around this checking to see if dst is in video memory. */ - DBG print("test hwdraw\n"); + DBG jehanne_print("test hwdraw\n"); if(hwdraw(&par)){ - DBG print("hwdraw handled\n"); + DBG jehanne_print("hwdraw handled\n"); return; } /* * Optimizations using memmove and memset. */ - DBG print("test memoptdraw\n"); + DBG jehanne_print("test memoptdraw\n"); if(memoptdraw(&par)){ - DBG print("memopt handled\n"); + DBG jehanne_print("memopt handled\n"); return; } @@ -183,18 +183,18 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask * Character drawing. * Solid source color being painted through a boolean mask onto a high res image. */ - DBG print("test chardraw\n"); + DBG jehanne_print("test chardraw\n"); if(chardraw(&par)){ - DBG print("chardraw handled\n"); + DBG jehanne_print("chardraw handled\n"); return; } /* * General calculation-laden case that does alpha for each pixel. */ - DBG print("do alphadraw\n"); + DBG jehanne_print("do alphadraw\n"); alphadraw(&par); - DBG print("alphadraw handled\n"); + DBG jehanne_print("alphadraw handled\n"); } #undef DBG @@ -343,8 +343,8 @@ mktables(void) if(tablesbuilt) return; - fmtinstall('R', Rfmt); - fmtinstall('P', Pfmt); + jehanne_fmtinstall('R', Rfmt); + jehanne_fmtinstall('P', Pfmt); tablesbuilt = 1; /* bit replication up to 8 bits */ @@ -501,7 +501,7 @@ allocdbuf(void) for(i=0; iimg = img; p->r = r; @@ -561,32 +561,32 @@ dumpbuf(char *s, Buffer b, int n) int i; uint8_t *p; - print("%s", s); + jehanne_print("%s", s); for(i=0; iflags&Falpha, mask->chan, GREY1, dst->depth); + DBG jehanne_print("flag %lud mchan %lux=?%x dd %d\n", src->flags&Falpha, mask->chan, GREY1, dst->depth); if(!(src->flags&Falpha) && mask->chan == GREY1 && dst->depth >= 8 && op == SoverD){ - DBG print("boolcopy..."); + DBG jehanne_print("boolcopy..."); rdsrc = convfn(dst, &z->dpar, src, &z->spar, &ndrawbuf); rddst = readptr; rdmask = readfn(mask); @@ -724,8 +724,8 @@ alphadraw(Memdrawparam *par) } if(z->n < ndrawbuf){ - free(z->p); - if((z->p = mallocz(ndrawbuf, 0)) == nil){ + jehanne_free(z->p); + if((z->p = jehanne_mallocz(ndrawbuf, 0)) == nil){ z->inuse = 0; return 0; } @@ -770,9 +770,9 @@ alphadraw(Memdrawparam *par) clipy(mask, &masky); bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy); - DBG print("["); + DBG jehanne_print("["); bmask = rdmask(&z->mpar, z->mpar.bufbase, masky); - DBG print("]\n"); + DBG jehanne_print("]\n"); bdst = rddst(&z->dpar, z->dpar.bufbase, dsty); DBG dumpbuf("src", bsrc, dx); DBG dumpbuf("mask", bmask, dx); @@ -793,7 +793,7 @@ alphacalc0(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op) USED(op); USED(b1); USED(b2); - memset(bdst.rgba, 0, dx*bdst.delta); + jehanne_memset(bdst.rgba, 0, dx*bdst.delta); return bdst; } @@ -1262,22 +1262,22 @@ readnbit(Param *p, uint8_t *buf, int y) n = p->img->r.max.x - x; r = p->bytermin + y*p->bwidth; - DBG print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n); + DBG jehanne_print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n); bits = *r++; nbits = 8; if(i=x&(npack-1)){ - DBG print("throwaway %d...", i); + DBG jehanne_print("throwaway %d...", i); bits <<= depth*i; nbits -= depth*i; } for(i=0; i>sh]; - DBG print("bit %x...", repl[bits>>sh]); + DBG jehanne_print("bit %x...", repl[bits>>sh]); bits <<= depth; nbits -= depth; } @@ -1294,24 +1294,24 @@ readnbit(Param *p, uint8_t *buf, int y) n = p->r.min.x - x; r = p->bytey0s + y*p->bwidth; - DBG print("x=%d r=%p...", x, r); + DBG jehanne_print("x=%d r=%p...", x, r); bits = *r++; nbits = 8; if(i=x&(npack-1)){ bits <<= depth*i; nbits -= depth*i; } - DBG print("nbits=%d...", nbits); + DBG jehanne_print("nbits=%d...", nbits); for(i=0; i>sh]; - DBG print("bit %x...", repl[bits>>sh]); + DBG jehanne_print("bit %x...", repl[bits>>sh]); bits <<= depth; nbits -= depth; - DBG print("bits %x nbits %d...", bits, nbits); + DBG jehanne_print("bits %x nbits %d...", bits, nbits); } dx -= n; if(dx == 0) @@ -1350,7 +1350,7 @@ writenbit(Param *p, uint8_t *w, Buffer src) for(; x> sh); nbits += depth; if(nbits == 8){ @@ -1365,7 +1365,7 @@ writenbit(Param *p, uint8_t *w, Buffer src) bits |= *w & ((1<alphaonly; copyalpha = (img->flags&Falpha) ? 1 : 0; - DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey); + DBG jehanne_print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey); /* if we can, avoid processing everything */ if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){ - memset(&b, 0, sizeof b); + jehanne_memset(&b, 0, sizeof b); if(p->needbuf){ - memmove(buf, r, dx*nb); + jehanne_memmove(buf, r, dx*nb); r = buf; } b.rgba = (uint32_t*)r; @@ -1504,7 +1504,7 @@ readbyte(Param *p, uint8_t *buf, int y) return b; } - DBG print("2\n"); + DBG jehanne_print("2\n"); rrepl = replbit[img->nbits[CRed]]; grepl = replbit[img->nbits[CGreen]]; brepl = replbit[img->nbits[CBlue]]; @@ -1515,7 +1515,7 @@ readbyte(Param *p, uint8_t *buf, int y) u = r[0] | (r[1]<<8) | (r[2]<<16) | (r[3]<<24); if(copyalpha) { *w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]]; - DBG print("a %x\n", w[-1]); + DBG jehanne_print("a %x\n", w[-1]); } if(isgrey) @@ -1525,9 +1525,9 @@ readbyte(Param *p, uint8_t *buf, int y) ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]]; ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]]; if(convgrey){ - DBG print("g %x %x %x\n", ured, ugrn, ublu); + DBG jehanne_print("g %x %x %x\n", ured, ugrn, ublu); *w++ = RGB2K(ured, ugrn, ublu); - DBG print("%x\n", w[-1]); + DBG jehanne_print("%x\n", w[-1]); }else{ *w++ = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]]; *w++ = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]]; @@ -1550,7 +1550,7 @@ readbyte(Param *p, uint8_t *buf, int y) b.grey = buf+copyalpha; b.red = b.grn = b.blu = buf+copyalpha; b.delta = copyalpha+1; - DBG print("alpha %x grey %x\n", b.alpha ? *b.alpha : 0xFF, *b.grey); + DBG jehanne_print("alpha %x grey %x\n", b.alpha ? *b.alpha : 0xFF, *b.grey); }else{ b.blu = buf+copyalpha; b.grn = buf+copyalpha+1; @@ -1596,12 +1596,12 @@ writebyte(Param *p, uint8_t *w, Buffer src) for(i=0; i> (8-img->nbits[CGrey])) & img->mask[CGrey]) << img->shift[CGrey]; - DBG print("|grey %.8lux...", u); + DBG jehanne_print("|grey %.8lux...", u); grey += delta; }else{ u |= ((*red >> (8-img->nbits[CRed])) & img->mask[CRed]) << img->shift[CRed]; @@ -1610,13 +1610,13 @@ writebyte(Param *p, uint8_t *w, Buffer src) red += delta; grn += delta; blu += delta; - DBG print("|rgb %.8lux...", u); + DBG jehanne_print("|rgb %.8lux...", u); } if(isalpha){ u |= ((*alpha >> (8-img->nbits[CAlpha])) & img->mask[CAlpha]) << img->shift[CAlpha]; alpha += adelta; - DBG print("|alpha %.8lux...", u); + DBG jehanne_print("|alpha %.8lux...", u); } w[0] = u; @@ -1685,7 +1685,7 @@ boolmemmove(Buffer bdst, Buffer bsrc, Buffer b1, int dx, int i, int o) USED(o); USED(b1); USED(bsrc); - memmove(bdst.red, bsrc.red, dx*bdst.delta); + jehanne_memmove(bdst.red, bsrc.red, dx*bdst.delta); return bdst; } @@ -2030,7 +2030,7 @@ rgbatoimg(Memimage *img, uint32_t rgba) } d += nb; } -// print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v); +// jehanne_print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v); return v; } @@ -2049,7 +2049,7 @@ memoptdraw(Memdrawparam *par) dst = par->dst; op = par->op; - DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); + DBG jehanne_print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); /* * If we have an opaque mask and source is one opaque pixel we can convert to the * destination format and just replicate with memset. @@ -2060,11 +2060,11 @@ memoptdraw(Memdrawparam *par) int d, dwid, ppb, np, nb; unsigned char lm, rm; - DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata); + DBG jehanne_print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata); dwid = dst->width*sizeof(uint32_t); dp = byteaddr(dst, par->r.min); v = par->sdval; - DBG print("sdval %lud, depth %d\n", v, dst->depth); + DBG jehanne_print("sdval %lud, depth %d\n", v, dst->depth); switch(dst->depth){ case 1: case 2: @@ -2078,16 +2078,16 @@ memoptdraw(Memdrawparam *par) dx -= (ppb-np); nb = 8 - np * dst->depth; /* no. bits used on right side of word */ lm = (1<r.min.x, nb, lm, ppb, m); + DBG jehanne_print("np %d x %d nb %d lm %ux ppb %d m %ux\n", np, par->r.min.x, nb, lm, ppb, m); /* right edge */ np = par->r.max.x&m; /* no. pixels used on left side of word */ dx -= np; nb = 8 - np * dst->depth; /* no. bits unused on right side of word */ rm = ~((1<r.max.x, nb, rm, ppb, m); + DBG jehanne_print("np %d x %d nb %d rm %ux ppb %d m %ux\n", np, par->r.max.x, nb, rm, ppb, m); - DBG print("dx %d Dx %d\n", dx, Dx(par->r)); + DBG jehanne_print("dx %d Dx %d\n", dx, Dx(par->r)); /* lm, rm are masks that are 1 where we should touch the bits */ if(dx < 0){ /* just one byte */ lm &= rm; @@ -2099,7 +2099,7 @@ memoptdraw(Memdrawparam *par) for(y=0; y>8; v = *(uint16_t*)p; - DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", dp, dx, dy, dwid); + DBG jehanne_print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", dp, dx, dy, dwid); for(y=0; ydepth)/8; for(y=0; ymask->flags, par->mask->depth, par->src->flags, Dx(par->src->r), Dy(par->src->r), par->dst->depth, par->dst->data, par->src->data); @@ -2326,7 +2326,7 @@ DBG print("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n wp = byteaddr(dst, r.min); dstwid = dst->width*sizeof(uint32_t); - DBG print("bsh %d\n", bsh); + DBG jehanne_print("bsh %d\n", bsh); dy = Dy(r); dx = Dx(r); @@ -2363,7 +2363,7 @@ DBG print("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n i = x&7; if(i == 8-1) bits = *q++; - DBG print("bits %lux sh %d...", bits, i); + DBG jehanne_print("bits %lux sh %d...", bits, i); if((bits>>i)&1) *wc = v; } @@ -2375,7 +2375,7 @@ DBG print("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n i = x&7; if(i == 8-1) bits = *q++; - DBG print("bits %lux sh %d...", bits, i); + DBG jehanne_print("bits %lux sh %d...", bits, i); if((bits>>i)&1) *ws = v; } @@ -2386,7 +2386,7 @@ DBG print("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n i = x&7; if(i == 8-1) bits = *q++; - DBG print("bits %lux sh %d...", bits, i); + DBG jehanne_print("bits %lux sh %d...", bits, i); if((bits>>i)&1){ wc[0] = sp[0]; wc[1] = sp[1]; @@ -2409,7 +2409,7 @@ DBG print("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n } } - DBG print("\n"); + DBG jehanne_print("\n"); return 1; } #undef DBG diff --git a/sys/src/lib/memdraw/drawtest.c b/sys/src/lib/memdraw/drawtest.c index d9b270e..ade089c 100644 --- a/sys/src/lib/memdraw/drawtest.c +++ b/sys/src/lib/memdraw/drawtest.c @@ -71,7 +71,7 @@ iprint(char *fmt, ...) char buf[1024]; va_start(va, fmt); - n = vseprint(buf, buf+sizeof buf, fmt, va) - buf; + n = jehanne_vseprint(buf, buf+sizeof buf, fmt, va) - buf; va_end(va); write(1,buf,n); @@ -82,20 +82,20 @@ void main(int argc, char *argv[]) { memimageinit(); - seed = time(0); + seed = jehanne_time(0); ARGBEGIN{ case 'x': - Xrange = atoi(ARGF()); + Xrange = jehanne_atoi(ARGF()); break; case 'y': - Yrange = atoi(ARGF()); + Yrange = jehanne_atoi(ARGF()); break; case 'n': - niters = atoi(ARGF()); + niters = jehanne_atoi(ARGF()); break; case 's': - seed = atoi(ARGF()); + seed = jehanne_atoi(ARGF()); break; }ARGEND @@ -109,14 +109,14 @@ main(int argc, char *argv[]) case 0: break; default: goto Usage; Usage: - fprint(2, "usage: dtest [dchan [schan [mchan]]]\n"); - exits("usage"); + jehanne_fprint(2, "usage: dtest [dchan [schan [mchan]]]\n"); + jehanne_exits("usage"); } -// fmtinstall('b', numbconv); /* binary! */ +// jehanne_fmtinstall('b', numbconv); /* binary! */ - fprint(2, "%s -x %d -y %d -s 0x%x %s %s %s\n", argv0, Xrange, Yrange, seed, dchan, schan, mchan); - srand(seed); + jehanne_fprint(2, "%s -x %d -y %d -s 0x%x %s %s %s\n", argv0, Xrange, Yrange, seed, dchan, schan, mchan); + jehanne_srand(seed); dst = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(dchan)); src = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(schan)); @@ -124,45 +124,45 @@ main(int argc, char *argv[]) stmp = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(schan)); mtmp = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(mchan)); ones = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(mchan)); -// print("chan %lux %lux %lux %lux %lux %lux\n", dst->chan, src->chan, mask->chan, stmp->chan, mtmp->chan, ones->chan); +// jehanne_print("chan %lux %lux %lux %lux %lux %lux\n", dst->chan, src->chan, mask->chan, stmp->chan, mtmp->chan, ones->chan); if(dst==0 || src==0 || mask==0 || mtmp==0 || ones==0) { Alloc: - fprint(2, "dtest: allocation failed: %r\n"); - exits("alloc"); + jehanne_fprint(2, "dtest: allocation failed: %r\n"); + jehanne_exits("alloc"); } nbytes = (4*Xrange+4)*Yrange; - srcbits = malloc(nbytes); - dstbits = malloc(nbytes); - maskbits = malloc(nbytes); - savedstbits = malloc(nbytes); + srcbits = jehanne_malloc(nbytes); + dstbits = jehanne_malloc(nbytes); + maskbits = jehanne_malloc(nbytes); + savedstbits = jehanne_malloc(nbytes); if(dstbits==0 || srcbits==0 || maskbits==0 || savedstbits==0) goto Alloc; dbpp = dst->depth; sbpp = src->depth; mbpp = mask->depth; dpm = 0xFF ^ (0xFF>>dbpp); - memset(ones->data->bdata, 0xFF, ones->width*sizeof(ulong)*Yrange); + jehanne_memset(ones->data->bdata, 0xFF, ones->width*sizeof(ulong)*Yrange); - fprint(2, "dtest: verify single pixel operation\n"); + jehanne_fprint(2, "dtest: verify single pixel operation\n"); verifyone(); - fprint(2, "dtest: verify full line non-replicated\n"); + jehanne_fprint(2, "dtest: verify full line non-replicated\n"); verifyline(); - fprint(2, "dtest: verify full rectangle non-replicated\n"); + jehanne_fprint(2, "dtest: verify full rectangle non-replicated\n"); verifyrect(); - fprint(2, "dtest: verify full rectangle source replicated\n"); + jehanne_fprint(2, "dtest: verify full rectangle source replicated\n"); verifyrectrepl(1, 0); - fprint(2, "dtest: verify full rectangle mask replicated\n"); + jehanne_fprint(2, "dtest: verify full rectangle mask replicated\n"); verifyrectrepl(0, 1); - fprint(2, "dtest: verify full rectangle source and mask replicated\n"); + jehanne_fprint(2, "dtest: verify full rectangle source and mask replicated\n"); verifyrectrepl(1, 1); - exits(0); + jehanne_exits(0); } /* @@ -234,7 +234,7 @@ dumpimage(char *name, Memimage *img, void *vdata, Point labelpt) break; } if(fmt == nil){ - fprint(2, "bad format\n"); + jehanne_fprint(2, "bad format\n"); abort(); } @@ -272,7 +272,7 @@ dumpimage(char *name, Memimage *img, void *vdata, Point labelpt) nb += 8; } nb -= bpp; -// print("bpp %d v %.8lux mask %.8lux nb %d\n", bpp, v, mask, nb); +// jehanne_print("bpp %d v %.8lux mask %.8lux nb %d\n", bpp, v, mask, nb); fmt(&b, arg, (v>>nb)&mask); } Bprint(&b, "\n"); @@ -295,11 +295,11 @@ checkone(Point p, Point sp, Point mp) dp = (uint8_t*)dst->data->bdata+delta; sdp = (uint8_t*)savedstbits+delta; - if(memcmp(dp, sdp, (dst->depth+7)/8) != 0) { - fprint(2, "dtest: one bad pixel drawing at dst %P from source %P mask %P\n", p, sp, mp); - fprint(2, " %.2ux %.2ux %.2ux %.2ux should be %.2ux %.2ux %.2ux %.2ux\n", + if(jehanne_memcmp(dp, sdp, (dst->depth+7)/8) != 0) { + jehanne_fprint(2, "dtest: one bad pixel drawing at dst %P from source %P mask %P\n", p, sp, mp); + jehanne_fprint(2, " %.2ux %.2ux %.2ux %.2ux should be %.2ux %.2ux %.2ux %.2ux\n", dp[0], dp[1], dp[2], dp[3], sdp[0], sdp[1], sdp[2], sdp[3]); - fprint(2, "addresses dst %p src %p mask %p\n", dp, byteaddr(src, sp), byteaddr(mask, mp)); + jehanne_fprint(2, "addresses dst %p src %p mask %p\n", dp, byteaddr(src, sp), byteaddr(mask, mp)); dumpimage("src", src, src->data->bdata, sp); dumpimage("mask", mask, mask->data->bdata, mp); dumpimage("origdst", dst, dstbits, p); @@ -326,9 +326,9 @@ checkline(Rectangle r, Point sp, Point mp, int y, Memimage *stmp, Memimage *mtmp nb = Xrange/(8/dst->depth); else nb = Xrange*(dst->depth/8); - if(memcmp(dp, saved, nb) != 0){ - fprint(2, "dtest: bad line at y=%d; saved %p dp %p\n", y, saved, dp); - fprint(2, "draw dst %R src %P mask %P\n", r, sp, mp); + if(jehanne_memcmp(dp, saved, nb) != 0){ + jehanne_fprint(2, "dtest: bad line at y=%d; saved %p dp %p\n", y, saved, dp); + jehanne_fprint(2, "draw dst %R src %P mask %P\n", r, sp, mp); dumpimage("src", src, src->data->bdata, sp); if(stmp) dumpimage("stmp", stmp, stmp->data->bdata, sp); dumpimage("mask", mask, mask->data->bdata, mp); @@ -356,19 +356,19 @@ fill(Memimage *img, uint8_t *ucbits) if((img->flags&Falpha) == 0){ up = (uint16_t*)ucbits; for(i=0; i> 7; + *up++ = jehanne_lrand() >> 7; if(i+i != nbytes) - *(uint8_t*)up = lrand() >> 7; + *(uint8_t*)up = jehanne_lrand() >> 7; }else{ data = img->data->bdata; img->data->bdata = ucbits; for(x=img->r.min.x; xr.max.x; x++) for(y=img->r.min.y; yr.max.y; y++){ - alpha = rand() >> 4; - r = rand()%(alpha+1); - g = rand()%(alpha+1); - b = rand()%(alpha+1); + alpha = jehanne_rand() >> 4; + r = jehanne_rand()%(alpha+1); + g = jehanne_rand()%(alpha+1); + b = jehanne_rand()%(alpha+1); putpixel(img, Pt(x,y), rgbatopix(r,g,b,alpha)); } img->data->bdata = data; @@ -386,29 +386,29 @@ verifyonemask(void) fill(dst, dstbits); fill(src, srcbits); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); - memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); - dp.x = nrand(Xrange); - dp.y = nrand(Yrange); + dp.x = jehanne_nrand(Xrange); + dp.y = jehanne_nrand(Yrange); - sp.x = nrand(Xrange); - sp.y = nrand(Yrange); + sp.x = jehanne_nrand(Xrange); + sp.y = jehanne_nrand(Yrange); - mp.x = nrand(Xrange); - mp.y = nrand(Yrange); + mp.x = jehanne_nrand(Xrange); + mp.y = jehanne_nrand(Yrange); drawonepixel(dst, dp, src, sp, mask, mp); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); - memmove(savedstbits, dst->data->bdata, + jehanne_memmove(savedstbits, dst->data->bdata, dst->width*sizeof(uint32_t)*Yrange); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); memimagedraw(dst, Rect(dp.x, dp.y, dp.x+1, dp.y+1), src, sp, mask, mp, SoverD); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); checkone(dp, sp, mp); @@ -420,12 +420,12 @@ verifyone(void) int i; /* mask all zeros */ - memset(maskbits, 0, nbytes); + jehanne_memset(maskbits, 0, nbytes); for(i=0; idata->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); - memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); - dr.min.x = nrand(Xrange-1); - dr.min.y = nrand(Yrange-1); - dr.max.x = dr.min.x + 1 + nrand(Xrange-1-dr.min.x); + dr.min.x = jehanne_nrand(Xrange-1); + dr.min.y = jehanne_nrand(Yrange-1); + dr.max.x = dr.min.x + 1 + jehanne_nrand(Xrange-1-dr.min.x); dr.max.y = dr.min.y + 1; - sp.x = nrand(Xrange); - sp.y = nrand(Yrange); + sp.x = jehanne_nrand(Xrange); + sp.y = jehanne_nrand(Yrange); - mp.x = nrand(Xrange); - mp.y = nrand(Yrange); + mp.x = jehanne_nrand(Xrange); + mp.y = jehanne_nrand(Yrange); tp = sp; up = mp; for(x=dr.min.x; xdata->bdata, + jehanne_memmove(savedstbits, dst->data->bdata, dst->width*sizeof(uint32_t)*Yrange); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); memimagedraw(dst, dr, src, sp, mask, mp, SoverD); checkline(dr, drawrepl(src->r, sp), drawrepl(mask->r, mp), dr.min.y, nil, nil); @@ -483,12 +483,12 @@ verifyline(void) int i; /* mask all ones */ - memset(maskbits, 0xFF, nbytes); + jehanne_memset(maskbits, 0xFF, nbytes); for(i=0; idata->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); - memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); - dr.min.x = nrand(Xrange-1); - dr.min.y = nrand(Yrange-1); - dr.max.x = dr.min.x + 1 + nrand(Xrange-1-dr.min.x); - dr.max.y = dr.min.y + 1 + nrand(Yrange-1-dr.min.y); + dr.min.x = jehanne_nrand(Xrange-1); + dr.min.y = jehanne_nrand(Yrange-1); + dr.max.x = dr.min.x + 1 + jehanne_nrand(Xrange-1-dr.min.x); + dr.max.y = dr.min.y + 1 + jehanne_nrand(Yrange-1-dr.min.y); - sp.x = nrand(Xrange); - sp.y = nrand(Yrange); + sp.x = jehanne_nrand(Xrange); + sp.y = jehanne_nrand(Yrange); - mp.x = nrand(Xrange); - mp.y = nrand(Yrange); + mp.x = jehanne_nrand(Xrange); + mp.y = jehanne_nrand(Yrange); tp = sp; up = mp; @@ -535,10 +535,10 @@ verifyrectmask(void) tp.x = sp.x; up.x = mp.x; } - memmove(savedstbits, dst->data->bdata, + jehanne_memmove(savedstbits, dst->data->bdata, dst->width*sizeof(uint32_t)*Yrange); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); memimagedraw(dst, dr, src, sp, mask, mp, SoverD); for(y=0; yr) */ - r.min.x = nrand(Xrange-1); - r.min.y = nrand(Yrange-1); + r.min.x = jehanne_nrand(Xrange-1); + r.min.y = jehanne_nrand(Yrange-1); /* make it trivial more often than pure chance allows */ - switch(lrand()&0){ + switch(jehanne_lrand()&0){ case 1: r.max.x = r.min.x + 2; r.max.y = r.min.y + 2; @@ -618,12 +618,12 @@ replicate(Memimage *i, Memimage *tmp) if(r.min.x+3 >= Xrange) r.max.x = Xrange; else - r.max.x = r.min.x+3 + nrand(Xrange-(r.min.x+3)); + r.max.x = r.min.x+3 + jehanne_nrand(Xrange-(r.min.x+3)); if(r.min.y+3 >= Yrange) r.max.y = Yrange; else - r.max.y = r.min.y+3 + nrand(Yrange-(r.min.y+3)); + r.max.y = r.min.y+3 + jehanne_nrand(Yrange-(r.min.y+3)); } assert(r.min.x >= 0); assert(r.max.x <= Xrange); @@ -631,12 +631,12 @@ replicate(Memimage *i, Memimage *tmp) assert(r.max.y <= Yrange); /* copy from i to tmp so we have just the replicated bits */ nb = tmp->width*sizeof(uint32_t)*Yrange; - memset(tmp->data->bdata, 0, nb); + jehanne_memset(tmp->data->bdata, 0, nb); memimagedraw(tmp, r, i, r.min, ones, r.min, SoverD); - memmove(i->data->bdata, tmp->data->bdata, nb); + jehanne_memmove(i->data->bdata, tmp->data->bdata, nb); /* i is now a non-replicated instance of the replication */ /* replicate it by hand through tmp */ - memset(tmp->data->bdata, 0, nb); + jehanne_memset(tmp->data->bdata, 0, nb); x = -(tilexy(r.min.x, r.max.x, 0)-r.min.x); for(; xflags |= Frepl; i->r = r; i->clipr = randrect(); -// fprint(2, "replicate [[%d %d] [%d %d]] [[%d %d][%d %d]]\n", r.min.x, r.min.y, r.max.x, r.max.y, +// jehanne_fprint(2, "replicate [[%d %d] [%d %d]] [[%d %d][%d %d]]\n", r.min.x, r.min.y, r.max.x, r.max.y, // i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y); tmp->clipr = i->clipr; } @@ -668,7 +668,7 @@ verifyrectmaskrepl(int srcrepl, int maskrepl) int x, y; Memimage *s, *m; -// print("verfrect %d %d\n", srcrepl, maskrepl); +// jehanne_print("verfrect %d %d\n", srcrepl, maskrepl); src->flags &= ~Frepl; src->r = Rect(0, 0, Xrange, Yrange); src->clipr = src->r; @@ -685,9 +685,9 @@ verifyrectmaskrepl(int srcrepl, int maskrepl) fill(dst, dstbits); fill(src, srcbits); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); - memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); - memmove(mask->data->bdata, maskbits, + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(src->data->bdata, srcbits, src->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(mask->data->bdata, maskbits, mask->width*sizeof(uint32_t)*Yrange); if(srcrepl){ @@ -703,22 +703,22 @@ verifyrectmaskrepl(int srcrepl, int maskrepl) dr = randrect(); - sp.x = nrand(Xrange); - sp.y = nrand(Yrange); + sp.x = jehanne_nrand(Xrange); + sp.y = jehanne_nrand(Yrange); - mp.x = nrand(Xrange); - mp.y = nrand(Yrange); + mp.x = jehanne_nrand(Xrange); + mp.y = jehanne_nrand(Yrange); -DBG print("smalldraws\n"); +DBG jehanne_print("smalldraws\n"); for(tp.y=sp.y,up.y=mp.y,y=dr.min.y; ydata->bdata, + jehanne_memmove(savedstbits, dst->data->bdata, dst->width*sizeof(uint32_t)*Yrange); - memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); + jehanne_memmove(dst->data->bdata, dstbits, dst->width*sizeof(uint32_t)*Yrange); -DBG print("bigdraw\n"); +DBG jehanne_print("bigdraw\n"); memimagedraw(dst, dr, src, sp, mask, mp, SoverD); for(y=0; yr, sp), drawrepl(mask->r, mp), y, srcrepl?stmp:nil, maskrepl?mtmp:nil); @@ -730,12 +730,12 @@ verifyrectrepl(int srcrepl, int maskrepl) int i; /* mask all ones */ - memset(maskbits, 0xFF, nbytes); + jehanne_memset(maskbits, 0xFF, nbytes); for(i=0; idepth; -DBG print("v %.8lux...", v); +DBG jehanne_print("v %.8lux...", v); if(bpp < 8){ /* * Sub-byte greyscale pixels. We need to skip the leftmost pt.x%npack pixels, @@ -921,13 +921,13 @@ DBG print("v %.8lux...", v); npack = 8/bpp; sh = bpp*(npack - pt.x%npack - 1); bits = RGB2K(r,g,b); -DBG print("repl %lux 8 %d = %lux...", bits, bpp, replbits(bits, 8, bpp)); +DBG jehanne_print("repl %lux 8 %d = %lux...", bits, bpp, replbits(bits, 8, bpp)); bits = replbits(bits, 8, bpp); mask = (1<>8; p[2] = v>>16; @@ -995,7 +995,7 @@ drawonepixel(Memimage *dst, Point dp, Memimage *src, Point sp, Memimage *mask, P m = getmask(mask, mp); M = 255-(sa*m)/255; -DBG print("dst %x %x %x %x src %x %x %x %x m %x = ", dr,dg,db,da, sr,sg,sb,sa, m); +DBG jehanne_print("dst %x %x %x %x src %x %x %x %x m %x = ", dr,dg,db,da, sr,sg,sb,sa, m); if(dst->flags&Fgrey){ /* * We need to do the conversion to grey before the alpha calculation @@ -1018,6 +1018,6 @@ DBG print("dst %x %x %x %x src %x %x %x %x m %x = ", dr,dg,db,da, sr,sg,sb,sa, m da = (sa*m + da*M)/255; } -DBG print("%x %x %x %x\n", dr,dg,db,da); +DBG jehanne_print("%x %x %x %x\n", dr,dg,db,da); putpixel(dst, dp, rgbatopix(dr, dg, db, da)); } diff --git a/sys/src/lib/memdraw/ellipse.c b/sys/src/lib/memdraw/ellipse.c index 9dc05c7..e49693a 100644 --- a/sys/src/lib/memdraw/ellipse.c +++ b/sys/src/lib/memdraw/ellipse.c @@ -218,7 +218,7 @@ erect(int x0, int y0, int x1, int y1, Param *p) { Rectangle r; -/* print("R %d,%d %d,%d\n", x0, y0, x1, y1); */ +/* jehanne_print("R %d,%d %d,%d\n", x0, y0, x1, y1); */ r = Rect(p->c.x+x0, p->c.y+y0, p->c.x+x1+1, p->c.y+y1+1); memdraw(p->dst, r, p->src, addpt(p->sp, r.min), memopaque, p00, p->op); } @@ -233,7 +233,7 @@ epoint(int x, int y, Param *p) Point p0; Rectangle r; -/* print("P%d %d,%d\n", p->t, x, y); */ +/* jehanne_print("P%d %d,%d\n", p->t, x, y); */ p0 = Pt(p->c.x+x, p->c.y+y); r = Rpt(addpt(p0, p->disc->r.min), addpt(p0, p->disc->r.max)); memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op); @@ -246,7 +246,7 @@ static void eline(int x0, int y0, int x1, int y1, Param *p) { -/* print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); */ +/* jehanne_print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); */ if(x1 > x0+1) erect(x0+1, y0-p->t, x1-1, y1+p->t, p); else if(y1 > y0+1) diff --git a/sys/src/lib/memdraw/fillpoly.c b/sys/src/lib/memdraw/fillpoly.c index 8332dba..98e9788 100644 --- a/sys/src/lib/memdraw/fillpoly.c +++ b/sys/src/lib/memdraw/fillpoly.c @@ -79,12 +79,12 @@ _memfillpolysc(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Poin if(nvert == 0) return; - seg = malloc((nvert+2)*sizeof(Seg*)); + seg = jehanne_malloc((nvert+2)*sizeof(Seg*)); if(seg == nil) return; - segtab = malloc((nvert+1)*sizeof(Seg)); + segtab = jehanne_malloc((nvert+1)*sizeof(Seg)); if(segtab == nil) { - free(seg); + jehanne_free(seg); return; } @@ -112,8 +112,8 @@ _memfillpolysc(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Poin if(detail) yscan(dst, seg, segtab, nvert, w, src, sp, fixshift, op); - free(seg); - free(segtab); + jehanne_free(seg); + jehanne_free(segtab); } static int32_t @@ -190,7 +190,7 @@ xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, if(n == 0) return; *p = 0; - qsort(seg, p-seg , sizeof(Seg*), ycompare); + jehanne_qsort(seg, p-seg , sizeof(Seg*), ycompare); onehalf = 0; if(fixshift) @@ -219,7 +219,7 @@ xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, s->z++; s->zerr -= s->den; if(s->zerr < 0 || s->zerr >= s->den) - print("bad ratzerr1: %ld den %ld dzrem %ld\n", s->zerr, s->den, s->dzrem); + jehanne_print("bad ratzerr1: %ld den %ld dzrem %ld\n", s->zerr, s->den, s->dzrem); } *q++ = s; } @@ -233,7 +233,7 @@ xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, s->z = s->p0.x; s->z += smuldivmod(y - s->p0.y, s->num, s->den, &s->zerr); if(s->zerr < 0 || s->zerr >= s->den) - print("bad ratzerr2: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); + jehanne_print("bad ratzerr2: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); *q++ = s; } ep = q; @@ -263,7 +263,7 @@ xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, p++; for(;;) { if(p == ep) { - print("xscan: fill to infinity"); + jehanne_print("xscan: fill to infinity"); return; } cnt += p[0]->d; @@ -320,7 +320,7 @@ yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, if(n == 0) return; *p = 0; - qsort(seg, n , sizeof(Seg*), xcompare); + jehanne_qsort(seg, n , sizeof(Seg*), xcompare); onehalf = 0; if(fixshift) @@ -349,7 +349,7 @@ yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, s->z++; s->zerr -= s->den; if(s->zerr < 0 || s->zerr >= s->den) - print("bad ratzerr1: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); + jehanne_print("bad ratzerr1: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); } *q++ = s; } @@ -363,7 +363,7 @@ yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, s->z = s->p0.y; s->z += smuldivmod(x - s->p0.x, s->num, s->den, &s->zerr); if(s->zerr < 0 || s->zerr >= s->den) - print("bad ratzerr2: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); + jehanne_print("bad ratzerr2: %ld den %ld ratdzrem %ld\n", s->zerr, s->den, s->dzrem); *q++ = s; } ep = q; @@ -393,7 +393,7 @@ yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, p++; for(;;) { if(p == ep) { - print("yscan: fill to infinity"); + jehanne_print("yscan: fill to infinity"); return; } cnt += p[0]->d; @@ -444,7 +444,7 @@ zsort(Seg **seg, Seg **ep) q = ep-1; for(p = seg; p < q; p++) { if(p[0]->z > p[1]->z) { - qsort(seg, ep-seg, sizeof(Seg*), zcompare); + jehanne_qsort(seg, ep-seg, sizeof(Seg*), zcompare); break; } } diff --git a/sys/src/lib/memdraw/line.c b/sys/src/lib/memdraw/line.c index ade0698..f1b1ac2 100644 --- a/sys/src/lib/memdraw/line.c +++ b/sys/src/lib/memdraw/line.c @@ -347,7 +347,7 @@ _memimageline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, if((src->flags&Frepl)==0 && rectclip(&clipr, rectsubpt(src->r, d))==0) return; /* this means that only verline() handles degenerate lines (p0==p1) */ - hor = (abs(p1.x-p0.x) > abs(p1.y-p0.y)); + hor = (jehanne_abs(p1.x-p0.x) > jehanne_abs(p1.y-p0.y)); /* * Clipping is a little peculiar. We can't use Sutherland-Cohen * clipping because lines are wide. But this is probably just fine: diff --git a/sys/src/lib/memdraw/load.c b/sys/src/lib/memdraw/load.c index a8a167d..9cc37ab 100644 --- a/sys/src/lib/memdraw/load.c +++ b/sys/src/lib/memdraw/load.c @@ -42,7 +42,7 @@ loadmemimage(Memimage *i, Rectangle r, uint8_t *data, int ndata) } if(lpart==0 && rpart==0){ /* easy case */ for(y=r.min.y; ywidth*sizeof(uint32_t); data += l; } @@ -53,7 +53,7 @@ loadmemimage(Memimage *i, Rectangle r, uint8_t *data, int ndata) for(y=r.min.y; y 1) - memmove(q+1, data+1, l-1); + jehanne_memmove(q+1, data+1, l-1); q += i->width*sizeof(uint32_t); data += l; } @@ -62,7 +62,7 @@ loadmemimage(Memimage *i, Rectangle r, uint8_t *data, int ndata) if(lpart==0 && rpart!=0){ for(y=r.min.y; y 1) - memmove(q, data, l-1); + jehanne_memmove(q, data, l-1); q[l-1] ^= (data[l-1]^q[l-1]) & mr; q += i->width*sizeof(uint32_t); data += l; @@ -72,7 +72,7 @@ loadmemimage(Memimage *i, Rectangle r, uint8_t *data, int ndata) for(y=r.min.y; y 2) - memmove(q+1, data+1, l-2); + jehanne_memmove(q+1, data+1, l-2); q[l-1] ^= (data[l-1]^q[l-1]) & mr; q += i->width*sizeof(uint32_t); data += l; diff --git a/sys/src/lib/memdraw/mkcmap.c b/sys/src/lib/memdraw/mkcmap.c index b69a24a..46e517a 100644 --- a/sys/src/lib/memdraw/mkcmap.c +++ b/sys/src/lib/memdraw/mkcmap.c @@ -59,30 +59,30 @@ main(int argc, char **argv) memimageinit(); c = mkcmap(); if(!inferno) - print("#include \n#include \n"); + jehanne_print("#include \n#include \n"); else - print("#include \"lib9.h\"\n"); - print("#include \n"); - print("#include \n\n"); - print("static Memcmap def = {\n"); - print("/* cmap2rgb */ {\n"); + jehanne_print("#include \"lib9.h\"\n"); + jehanne_print("#include \n"); + jehanne_print("#include \n\n"); + jehanne_print("static Memcmap def = {\n"); + jehanne_print("/* cmap2rgb */ {\n"); for(i=0; icmap2rgb); ){ - print("\t"); + jehanne_print("\t"); for(j=0; j<16; j++, i++) - print("0x%2.2ux,", c->cmap2rgb[i]); - print("\n"); + jehanne_print("0x%2.2ux,", c->cmap2rgb[i]); + jehanne_print("\n"); } - print("},\n"); - print("/* rgb2cmap */ {\n"); + jehanne_print("},\n"); + jehanne_print("/* rgb2cmap */ {\n"); for(i=0; irgb2cmap);){ - print("\t"); + jehanne_print("\t"); for(j=0; j<16; j++, i++) - print("0x%2.2ux,", c->rgb2cmap[i]); - print("\n"); + jehanne_print("0x%2.2ux,", c->rgb2cmap[i]); + jehanne_print("\n"); } - print("}\n"); - print("};\n"); - print("Memcmap *memdefcmap = &def;\n"); - print("void _memmkcmap(void){}\n"); - exits(0); + jehanne_print("}\n"); + jehanne_print("};\n"); + jehanne_print("Memcmap *memdefcmap = &def;\n"); + jehanne_print("void _memmkcmap(void){}\n"); + jehanne_exits(0); } diff --git a/sys/src/lib/memdraw/openmemsubfont.c b/sys/src/lib/memdraw/openmemsubfont.c index c84301b..4670afc 100644 --- a/sys/src/lib/memdraw/openmemsubfont.c +++ b/sys/src/lib/memdraw/openmemsubfont.c @@ -30,33 +30,33 @@ openmemsubfont(char *name) if(i == nil) goto Err; if(read(fd, hdr, 3*12) != 3*12){ - werrstr("openmemsubfont: header read error: %r"); + jehanne_werrstr("openmemsubfont: header read error: %r"); goto Err; } - n = atoi(hdr); - p = malloc(6*(n+1)); + n = jehanne_atoi(hdr); + p = jehanne_malloc(6*(n+1)); if(p == nil) goto Err; if(read(fd, p, 6*(n+1)) != 6*(n+1)){ - werrstr("openmemsubfont: fontchar read error: %r"); + jehanne_werrstr("openmemsubfont: fontchar read error: %r"); goto Err; } - fc = malloc(sizeof(Fontchar)*(n+1)); + fc = jehanne_malloc(sizeof(Fontchar)*(n+1)); if(fc == nil) goto Err; _unpackinfo(fc, p, n); - sf = allocmemsubfont(name, n, atoi(hdr+12), atoi(hdr+24), fc, i); + sf = allocmemsubfont(name, n, jehanne_atoi(hdr+12), jehanne_atoi(hdr+24), fc, i); if(sf == nil){ - free(fc); + jehanne_free(fc); goto Err; } - free(p); + jehanne_free(p); return sf; Err: close(fd); if (i != nil) freememimage(i); if (p != nil) - free(p); + jehanne_free(p); return nil; } diff --git a/sys/src/lib/memdraw/read.c b/sys/src/lib/memdraw/read.c index 772f7b9..2d14c11 100644 --- a/sys/src/lib/memdraw/read.c +++ b/sys/src/lib/memdraw/read.c @@ -26,14 +26,14 @@ readmemimage(int fd) int ldepth, chunk; Memimage *i; - if(readn(fd, hdr, 11) != 11){ - werrstr("readimage: short header"); + if(jehanne_readn(fd, hdr, 11) != 11){ + jehanne_werrstr("readimage: short header"); return nil; } - if(memcmp(hdr, "compressed\n", 11) == 0) + if(jehanne_memcmp(hdr, "compressed\n", 11) == 0) return creadmemimage(fd); - if(readn(fd, hdr+11, 5*12-11) != 5*12-11){ - werrstr("readimage: short header (2)"); + if(jehanne_readn(fd, hdr+11, 5*12-11) != 5*12-11){ + jehanne_werrstr("readimage: short header (2)"); return nil; } @@ -50,30 +50,30 @@ readmemimage(int fd) } } if(hdr[11] != ' '){ - werrstr("readimage: bad format"); + jehanne_werrstr("readimage: bad format"); return nil; } if(new){ hdr[11] = '\0'; if((chan = strtochan(hdr)) == 0){ - werrstr("readimage: bad channel string %s", hdr); + jehanne_werrstr("readimage: bad channel string %s", hdr); return nil; } }else{ ldepth = ((int)hdr[10])-'0'; if(ldepth<0 || ldepth>3){ - werrstr("readimage: bad ldepth %d", ldepth); + jehanne_werrstr("readimage: bad ldepth %d", ldepth); return nil; } chan = drawld2chan[ldepth]; } - r.min.x = atoi(hdr+1*12); - r.min.y = atoi(hdr+2*12); - r.max.x = atoi(hdr+3*12); - r.max.y = atoi(hdr+4*12); + r.min.x = jehanne_atoi(hdr+1*12); + r.min.y = jehanne_atoi(hdr+2*12); + r.max.x = jehanne_atoi(hdr+3*12); + r.max.y = jehanne_atoi(hdr+4*12); if(r.min.x>r.max.x || r.min.y>r.max.y){ - werrstr("readimage: bad rectangle"); + jehanne_werrstr("readimage: bad rectangle"); return nil; } @@ -87,7 +87,7 @@ readmemimage(int fd) chunk = 32*1024; if(chunk < l) chunk = l; - tmp = malloc(chunk); + tmp = jehanne_malloc(chunk); if(tmp == nil) goto Err; while(maxy > miny){ @@ -95,16 +95,16 @@ readmemimage(int fd) if(dy*l > chunk) dy = chunk/l; if(dy <= 0){ - werrstr("readmemimage: image too wide for buffer"); + jehanne_werrstr("readmemimage: image too wide for buffer"); goto Err; } n = dy*l; - m = readn(fd, tmp, n); + m = jehanne_readn(fd, tmp, n); if(m != n){ - werrstr("readmemimage: read count %d not %d: %r", m, n); + jehanne_werrstr("readmemimage: read count %d not %d: %r", m, n); Err: freememimage(i); - free(tmp); + jehanne_free(tmp); return nil; } if(!new) /* an old image: must flip all the bits */ @@ -115,6 +115,6 @@ readmemimage(int fd) goto Err; miny += dy; } - free(tmp); + jehanne_free(tmp); return i; } diff --git a/sys/src/lib/memdraw/string.c b/sys/src/lib/memdraw/string.c index 61409bf..ca146c3 100644 --- a/sys/src/lib/memdraw/string.c +++ b/sys/src/lib/memdraw/string.c @@ -28,7 +28,7 @@ memimagestring(Memimage *b, Point p, Memimage *color, Point cp, Memsubfont *f, if(c < Runeself) s++; else{ - w = chartorune(&c, (char*)s); + w = jehanne_chartorune(&c, (char*)s); if(w == 0){ s++; continue; @@ -61,7 +61,7 @@ memsubfontwidth(Memsubfont *f, char *cs) if(c < Runeself) s++; else{ - w = chartorune(&c, (char*)s); + w = jehanne_chartorune(&c, (char*)s); if(w == 0){ s++; continue; diff --git a/sys/src/lib/memdraw/subfont.c b/sys/src/lib/memdraw/subfont.c index 00a2663..001df7e 100644 --- a/sys/src/lib/memdraw/subfont.c +++ b/sys/src/lib/memdraw/subfont.c @@ -18,7 +18,7 @@ allocmemsubfont(char *name, int n, int height, int ascent, { Memsubfont *f; - f = malloc(sizeof(Memsubfont)); + f = jehanne_malloc(sizeof(Memsubfont)); if(f == 0) return 0; f->n = n; @@ -27,7 +27,7 @@ allocmemsubfont(char *name, int n, int height, int ascent, f->info = info; f->bits = i; if(name) - f->name = strdup(name); + f->name = jehanne_strdup(name); else f->name = 0; return f; @@ -38,7 +38,7 @@ freememsubfont(Memsubfont *f) { if(f == 0) return; - free(f->info); /* note: f->info must have been malloc'ed! */ + jehanne_free(f->info); /* note: f->info must have been malloc'ed! */ freememimage(f->bits); - free(f); + jehanne_free(f); } diff --git a/sys/src/lib/memdraw/unload.c b/sys/src/lib/memdraw/unload.c index 8db842e..49743ed 100644 --- a/sys/src/lib/memdraw/unload.c +++ b/sys/src/lib/memdraw/unload.c @@ -26,7 +26,7 @@ unloadmemimage(Memimage *i, Rectangle r, uint8_t *data, int ndata) ndata = l*Dy(r); q = byteaddr(i, r.min); for(y=r.min.y; ywidth*sizeof(uint32_t); data += l; } diff --git a/sys/src/lib/memdraw/write.c b/sys/src/lib/memdraw/write.c index 04d1f55..b58c443 100644 --- a/sys/src/lib/memdraw/write.c +++ b/sys/src/lib/memdraw/write.c @@ -51,17 +51,17 @@ writememimage(int fd, Memimage *i) r = i->r; bpl = bytesperline(r, i->depth); n = Dy(r)*bpl; - data = malloc(n); + data = jehanne_malloc(n); ncblock = _compblocksize(r, i->depth); - outbuf = malloc(ncblock); - hash = malloc(NHASH*sizeof(Hlist)); - chain = malloc(NMEM*sizeof(Hlist)); + outbuf = jehanne_malloc(ncblock); + hash = jehanne_malloc(NHASH*sizeof(Hlist)); + chain = jehanne_malloc(NMEM*sizeof(Hlist)); if(data == 0 || outbuf == 0 || hash == 0 || chain == 0){ ErrOut: - free(data); - free(outbuf); - free(hash); - free(chain); + jehanne_free(data); + jehanne_free(outbuf); + jehanne_free(hash); + jehanne_free(chain); return -1; } for(miny = r.min.y; miny != r.max.y; miny += dy){ @@ -73,7 +73,7 @@ writememimage(int fd, Memimage *i) if(nb != dy*bpl) goto ErrOut; } - sprint(hdr, "compressed\n%11s %11d %11d %11d %11d ", + jehanne_sprint(hdr, "compressed\n%11s %11d %11d %11d %11d ", chantostr(cbuf, i->chan), r.min.x, r.min.y, r.max.x, r.max.y); if(write(fd, hdr, 11+5*12) != 11+5*12) goto ErrOut; @@ -82,8 +82,8 @@ writememimage(int fd, Memimage *i) line = data; r.max.y = r.min.y; while(line != edata){ - memset(hash, 0, NHASH*sizeof(Hlist)); - memset(chain, 0, NMEM*sizeof(Hlist)); + jehanne_memset(hash, 0, NHASH*sizeof(Hlist)); + jehanne_memset(chain, 0, NMEM*sizeof(Hlist)); cp = chain; h = 0; outp = outbuf; @@ -127,7 +127,7 @@ writememimage(int fd, Memimage *i) if(eout-outp < ndump+1) goto Bfull; *outp++ = ndump-1+128; - memmove(outp, dumpbuf, ndump); + jehanne_memmove(outp, dumpbuf, ndump); outp += ndump; ndump = 0; } @@ -139,7 +139,7 @@ writememimage(int fd, Memimage *i) if(eout-outp < ndump+1) goto Bfull; *outp++ = ndump-1+128; - memmove(outp, dumpbuf, ndump); + jehanne_memmove(outp, dumpbuf, ndump); outp += ndump; ndump = 0; } @@ -168,7 +168,7 @@ writememimage(int fd, Memimage *i) if(eout-outp < ndump+1) goto Bfull; *outp++ = ndump-1+128; - memmove(outp, dumpbuf, ndump); + jehanne_memmove(outp, dumpbuf, ndump); outp += ndump; } line = eline; @@ -179,14 +179,14 @@ writememimage(int fd, Memimage *i) if(loutp == outbuf) goto ErrOut; n = loutp-outbuf; - sprint(hdr, "%11d %11ld ", r.max.y, n); + jehanne_sprint(hdr, "%11d %11ld ", r.max.y, n); write(fd, hdr, 2*12); write(fd, outbuf, n); r.min.y = r.max.y; } - free(data); - free(outbuf); - free(hash); - free(chain); + jehanne_free(data); + jehanne_free(outbuf); + jehanne_free(hash); + jehanne_free(chain); return 0; } diff --git a/sys/src/lib/memlayer/draw.c b/sys/src/lib/memlayer/draw.c index d38e29c..8b22975 100644 --- a/sys/src/lib/memlayer/draw.c +++ b/sys/src/lib/memlayer/draw.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/lalloc.c b/sys/src/lib/memlayer/lalloc.c index 09b1c6f..b776b11 100644 --- a/sys/src/lib/memlayer/lalloc.c +++ b/sys/src/lib/memlayer/lalloc.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/layerop.c b/sys/src/lib/memlayer/layerop.c index 3771abc..97023d2 100644 --- a/sys/src/lib/memlayer/layerop.c +++ b/sys/src/lib/memlayer/layerop.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/ldelete.c b/sys/src/lib/memlayer/ldelete.c index ff3b47a..a89abd1 100644 --- a/sys/src/lib/memlayer/ldelete.c +++ b/sys/src/lib/memlayer/ldelete.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/lhide.c b/sys/src/lib/memlayer/lhide.c index 38c6c09..362c759 100644 --- a/sys/src/lib/memlayer/lhide.c +++ b/sys/src/lib/memlayer/lhide.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/line.c b/sys/src/lib/memlayer/line.c index 3ea83f5..820796f 100644 --- a/sys/src/lib/memlayer/line.c +++ b/sys/src/lib/memlayer/line.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/load.c b/sys/src/lib/memlayer/load.c index 642f1d6..bdca53a 100644 --- a/sys/src/lib/memlayer/load.c +++ b/sys/src/lib/memlayer/load.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/lorigin.c b/sys/src/lib/memlayer/lorigin.c index 2c7543f..41836e0 100644 --- a/sys/src/lib/memlayer/lorigin.c +++ b/sys/src/lib/memlayer/lorigin.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/lsetrefresh.c b/sys/src/lib/memlayer/lsetrefresh.c index 1dda291..de2ff80 100644 --- a/sys/src/lib/memlayer/lsetrefresh.c +++ b/sys/src/lib/memlayer/lsetrefresh.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/ltofront.c b/sys/src/lib/memlayer/ltofront.c index 5397332..afaaa29 100644 --- a/sys/src/lib/memlayer/ltofront.c +++ b/sys/src/lib/memlayer/ltofront.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/ltorear.c b/sys/src/lib/memlayer/ltorear.c index 51e34aa..08ac322 100644 --- a/sys/src/lib/memlayer/ltorear.c +++ b/sys/src/lib/memlayer/ltorear.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/memlayer/unload.c b/sys/src/lib/memlayer/unload.c index beec7d1..83b11a4 100644 --- a/sys/src/lib/memlayer/unload.c +++ b/sys/src/lib/memlayer/unload.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/mp/bigtest.c b/sys/src/lib/mp/bigtest.c index 1bde66e..b1fe056 100644 --- a/sys/src/lib/mp/bigtest.c +++ b/sys/src/lib/mp/bigtest.c @@ -1,5 +1,5 @@ #include -#include +#include #include char *sfactors[] = @@ -22,11 +22,11 @@ printmp(mpint *b, char *tag) int n; char *p; - print("%s (%d) ", tag, b->top); + jehanne_print("%s (%d) ", tag, b->top); p = mptoa(b, 10, nil, 0); - write(1, p, strlen(p)); - free(p); - print("\n"); + write(1, p, jehanne_strlen(p)); + jehanne_free(p); + jehanne_print("\n"); } int @@ -34,7 +34,7 @@ timing(void) { int32_t now, span; - now = time(0); + now = jehanne_time(0); span = now-start; start = now; @@ -50,8 +50,8 @@ main(int argc, char **argv) mpint *p, *k, *d, *b, *e, *x, *r; int i; - start = time(0); - fmtinstall('B', mpfmt); + start = jehanne_time(0); + jehanne_fmtinstall('B', mpfmt); mpsetminbits(2*Dbits); x = mpnew(0); @@ -75,10 +75,10 @@ main(int argc, char **argv) mpadd(k, mpone, p); // if(!probably_prime(p, 18)){ -// print("not a prime\n"); -// exits(0); +// jehanne_print("not a prime\n"); +// jehanne_exits(0); // } -// print("probably prime\n"); +// jehanne_print("probably prime\n"); mpright(k, 10, k); printmp(k, "k ="); @@ -86,7 +86,7 @@ main(int argc, char **argv) expdebug = 1; mpexp(b, k, p, x); printmp(x, "x ="); - print("timing %d\n", timing()); + jehanne_print("timing %d\n", timing()); for(i = 0; i < nelem(sfactors); i++){ d = strtomp(sfactors[i], nil, 10, nil); @@ -97,6 +97,6 @@ expdebug = 1; // x = b^e mod p mpexp(b, e, p, x); printmp(x, "x ="); - print("timing %d\n", timing()); + jehanne_print("timing %d\n", timing()); } } diff --git a/sys/src/lib/mp/port/betomp.c b/sys/src/lib/mp/port/betomp.c index dc516f3..093ff17 100644 --- a/sys/src/lib/mp/port/betomp.c +++ b/sys/src/lib/mp/port/betomp.c @@ -11,7 +11,7 @@ betomp(uint8_t *p, uint32_t n, mpint *b) if(b == nil){ b = mpnew(0); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); } mpbits(b, n*8); diff --git a/sys/src/lib/mp/port/cnfield.c b/sys/src/lib/mp/port/cnfield.c index 2f95f1d..1b98c63 100644 --- a/sys/src/lib/mp/port/cnfield.c +++ b/sys/src/lib/mp/port/cnfield.c @@ -38,7 +38,7 @@ cnreduce(Mfield *m, mpint *a, mpint *r) /* q = hi(r) */ qn = r->top - k; - memmove(q, r->p+k, qn*Dbytes); + jehanne_memmove(q, r->p+k, qn*Dbytes); /* r = lo(r) */ r->top = k; @@ -47,13 +47,13 @@ cnreduce(Mfield *m, mpint *a, mpint *r) do { /* t = q*c */ tn = qn+1; - memset(t, 0, tn*Dbytes); + jehanne_memset(t, 0, tn*Dbytes); mpvecdigmuladd(q, qn, f->c, t); /* q = hi(t) */ qn = tn - k; if(qn <= 0) qn = 0; - else memmove(q, t+k, qn*Dbytes); + else jehanne_memmove(q, t+k, qn*Dbytes); /* r += lo(t) */ if(tn > k) @@ -95,7 +95,7 @@ cnfield(mpint *N) mpsub(C, M, C); if(C->top != 1) goto out; - f = mallocz(sizeof(CNfield) + M->top*sizeof(mpdigit), 1); + f = jehanne_mallocz(sizeof(CNfield) + M->top*sizeof(mpdigit), 1); if(f == nil) goto out; f->s = s; diff --git a/sys/src/lib/mp/port/crt.c b/sys/src/lib/mp/port/crt.c index a98fef5..10b88be 100644 --- a/sys/src/lib/mp/port/crt.c +++ b/sys/src/lib/mp/port/crt.c @@ -22,9 +22,9 @@ crtpre(int n, mpint **m) int i, j; mpint *u; - crt = malloc(sizeof(CRTpre)+sizeof(mpint)*3*n); + crt = jehanne_malloc(sizeof(CRTpre)+sizeof(mpint)*3*n); if(crt == nil) - sysfatal("crtpre: %r"); + jehanne_sysfatal("crtpre: %r"); crt->m = crt->a; crt->c = crt->a+n; crt->p = crt->c+n; @@ -67,7 +67,7 @@ crtprefree(CRTpre *crt) mpfree(crt->p[i]); mpfree(crt->m[i]); } - free(crt); + jehanne_free(crt); } // convert to residues, returns a newly created structure @@ -77,9 +77,9 @@ crtin(CRTpre *crt, mpint *x) int i; CRTres *res; - res = malloc(sizeof(CRTres)+sizeof(mpint)*crt->n); + res = jehanne_malloc(sizeof(CRTres)+sizeof(mpint)*crt->n); if(res == nil) - sysfatal("crtin: %r"); + jehanne_sysfatal("crtin: %r"); res->n = crt->n; for(i = 0; i < res->n; i++){ res->r[i] = mpnew(0); @@ -117,5 +117,5 @@ crtresfree(CRTres *res) for(i = 0; i < res->n; i++) mpfree(res->r[i]); - free(res); + jehanne_free(res); } diff --git a/sys/src/lib/mp/port/crttest.c b/sys/src/lib/mp/port/crttest.c index 13b6ed9..c498074 100644 --- a/sys/src/lib/mp/port/crttest.c +++ b/sys/src/lib/mp/port/crttest.c @@ -8,7 +8,7 @@ testcrt(mpint **p) CRTres *res; mpint *m, *x, *y; - fmtinstall('B', mpfmt); + jehanne_fmtinstall('B', mpfmt); // get a modulus and a test number m = mpnew(1024+160); @@ -25,7 +25,7 @@ testcrt(mpint **p) // convert back y = mpnew(1024+160); crtout(crt, res, y); - print("x %B\ny %B\n", x, y); + jehanne_print("x %B\ny %B\n", x, y); mpfree(m); mpfree(x); mpfree(y); @@ -38,7 +38,7 @@ main(void) mpint *p[2]; int32_t start; - start = time(0); + start = jehanne_time(0); for(i = 0; i < 10; i++){ p[0] = mpnew(1024); p[1] = mpnew(1024); @@ -47,6 +47,6 @@ main(void) mpfree(p[0]); mpfree(p[1]); } - print("%ld secs with more\n", time(0)-start); - exits(0); + jehanne_print("%ld secs with more\n", jehanne_time(0)-start); + jehanne_exits(0); } diff --git a/sys/src/lib/mp/port/gmfield.c b/sys/src/lib/mp/port/gmfield.c index 52ead4e..340bc25 100644 --- a/sys/src/lib/mp/port/gmfield.c +++ b/sys/src/lib/mp/port/gmfield.c @@ -38,7 +38,7 @@ gmreduce(Mfield *m, mpint *a, mpint *r) d = g->top; mpbits(r, (d+1)*Dbits*2); - memmove(t+d, r->p+d, d*Dbytes); + jehanne_memmove(t+d, r->p+d, d*Dbytes); r->sign = 1; r->top = d; @@ -94,8 +94,8 @@ gmfield(mpint *N) g = nil; T = mpnew(0); M = mpcopy(N); - C = malloc(sizeof(int)*(d+1)); - X = malloc(sizeof(int)*(d*d)); + C = jehanne_malloc(sizeof(int)*(d+1)); + X = jehanne_malloc(sizeof(int)*(d*d)); if(C == nil || X == nil) goto out; @@ -115,7 +115,7 @@ gmfield(mpint *N) for(j=1; j 0; n--){ diff --git a/sys/src/lib/mp/port/mpadd.c b/sys/src/lib/mp/port/mpadd.c index 9a1ccde..66dbca2 100644 --- a/sys/src/lib/mp/port/mpadd.c +++ b/sys/src/lib/mp/port/mpadd.c @@ -2,7 +2,7 @@ #include #include "dat.h" -// sum = abs(b1) + abs(b2), i.e., add the magnitudes +// sum = jehanne_abs(b1) + jehanne_abs(b2), i.e., add the magnitudes void mpmagadd(mpint *b1, mpint *b2, mpint *sum) { diff --git a/sys/src/lib/mp/port/mpaux.c b/sys/src/lib/mp/port/mpaux.c index 93860ed..058b369 100644 --- a/sys/src/lib/mp/port/mpaux.c +++ b/sys/src/lib/mp/port/mpaux.c @@ -36,7 +36,7 @@ void mpsetminbits(int n) { if(n < 0) - sysfatal("mpsetminbits: n < 0"); + jehanne_sysfatal("mpsetminbits: n < 0"); if(n == 0) n = 1; mpmindigits = DIGITS(n); @@ -49,15 +49,15 @@ mpnew(int n) mpint *b; if(n < 0) - sysfatal("mpsetminbits: n < 0"); + jehanne_sysfatal("mpsetminbits: n < 0"); n = DIGITS(n); if(n < mpmindigits) n = mpmindigits; - b = mallocz(sizeof(mpint) + n*Dbytes, 1); + b = jehanne_mallocz(sizeof(mpint) + n*Dbytes, 1); if(b == nil) - sysfatal("mpnew: %r"); - setmalloctag(b, getcallerpc()); + jehanne_sysfatal("mpnew: %r"); + jehanne_setmalloctag(b, jehanne_getcallerpc()); b->p = (mpdigit*)&b[1]; b->size = n; b->sign = 1; @@ -78,19 +78,19 @@ mpbits(mpint *b, int m) return; } else { if(b->p == (mpdigit*)&b[1]){ - b->p = (mpdigit*)mallocz(n*Dbytes, 0); + b->p = (mpdigit*)jehanne_mallocz(n*Dbytes, 0); if(b->p == nil) - sysfatal("mpbits: %r"); - memmove(b->p, &b[1], Dbytes*b->top); - memset(&b[1], 0, Dbytes*b->size); + jehanne_sysfatal("mpbits: %r"); + jehanne_memmove(b->p, &b[1], Dbytes*b->top); + jehanne_memset(&b[1], 0, Dbytes*b->size); } else { - b->p = (mpdigit*)realloc(b->p, n*Dbytes); + b->p = (mpdigit*)jehanne_realloc(b->p, n*Dbytes); if(b->p == nil) - sysfatal("mpbits: %r"); + jehanne_sysfatal("mpbits: %r"); } b->size = n; } - memset(&b->p[b->top], 0, Dbytes*(n - b->top)); + jehanne_memset(&b->p[b->top], 0, Dbytes*(n - b->top)); b->top = n; b->flags &= ~MPnorm; } @@ -101,11 +101,11 @@ mpfree(mpint *b) if(b == nil) return; if(b->flags & MPstatic) - sysfatal("freeing mp constant"); - memset(b->p, 0, b->size*Dbytes); + jehanne_sysfatal("freeing mp constant"); + jehanne_memset(b->p, 0, b->size*Dbytes); if(b->p != (mpdigit*)&b[1]) - free(b->p); - free(b); + jehanne_free(b->p); + jehanne_free(b); } mpint* @@ -134,11 +134,11 @@ mpcopy(mpint *old) mpint *new; new = mpnew(Dbits*old->size); - setmalloctag(new, getcallerpc()); + jehanne_setmalloctag(new, jehanne_getcallerpc()); new->sign = old->sign; new->top = old->top; new->flags = old->flags & ~(MPstatic|MPfield); - memmove(new->p, old->p, Dbytes*old->top); + jehanne_memmove(new->p, old->p, Dbytes*old->top); return new; } @@ -153,7 +153,7 @@ mpassign(mpint *old, mpint *new) new->top = old->top; new->flags &= ~MPnorm; new->flags |= old->flags & ~(MPstatic|MPfield); - memmove(new->p, old->p, Dbytes*old->top); + jehanne_memmove(new->p, old->p, Dbytes*old->top); } // number of significant bits in mantissa diff --git a/sys/src/lib/mp/port/mpcmp.c b/sys/src/lib/mp/port/mpcmp.c index 7ab5a16..2b24a7a 100644 --- a/sys/src/lib/mp/port/mpcmp.c +++ b/sys/src/lib/mp/port/mpcmp.c @@ -2,7 +2,7 @@ #include #include "dat.h" -// return neg, 0, pos as abs(b1)-abs(b2) is neg, 0, pos +// return neg, 0, pos as jehanne_abs(b1)-jehanne_abs(b2) is neg, 0, pos int mpmagcmp(mpint *b1, mpint *b2) { diff --git a/sys/src/lib/mp/port/mpdiv.c b/sys/src/lib/mp/port/mpdiv.c index 927c014..32cc612 100644 --- a/sys/src/lib/mp/port/mpdiv.c +++ b/sys/src/lib/mp/port/mpdiv.c @@ -87,7 +87,7 @@ mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder) // D3a: rule out trial divisors 2 greater than real divisor if(vn > 1) for(;;){ - memset(t->p, 0, 3*Dbytes); // mpvecdigmuladd adds to what's there + jehanne_memset(t->p, 0, 3*Dbytes); // mpvecdigmuladd adds to what's there mpvecdigmuladd(vp-1, 2, qd, t->p); if(mpveccmp(t->p, 3, up-2, 3) > 0) qd--; diff --git a/sys/src/lib/mp/port/mpeuclid.c b/sys/src/lib/mp/port/mpeuclid.c index 586b9cc..20a6816 100644 --- a/sys/src/lib/mp/port/mpeuclid.c +++ b/sys/src/lib/mp/port/mpeuclid.c @@ -17,7 +17,7 @@ mpeuclid(mpint *a, mpint *b, mpint *d, mpint *x, mpint *y) assert(((a->flags|b->flags|d->flags|x->flags|y->flags) & MPtimesafe) == 0); if(a->sign<0 || b->sign<0) - sysfatal("mpeuclid: negative arg"); + jehanne_sysfatal("mpeuclid: negative arg"); if(mpcmp(a, b) < 0){ tmp = a; diff --git a/sys/src/lib/mp/port/mpexp.c b/sys/src/lib/mp/port/mpexp.c index f5d7ac9..ec0181d 100644 --- a/sys/src/lib/mp/port/mpexp.c +++ b/sys/src/lib/mp/port/mpexp.c @@ -32,7 +32,7 @@ mpexp(mpint *b, mpint *e, mpint *m, mpint *res) return; } if(i<0) - sysfatal("mpexp: negative exponent"); + jehanne_sysfatal("mpexp: negative exponent"); t[0] = mpcopy(b); t[1] = res; diff --git a/sys/src/lib/mp/port/mpextendedgcd.c b/sys/src/lib/mp/port/mpextendedgcd.c index 72e49bc..f710d2e 100644 --- a/sys/src/lib/mp/port/mpextendedgcd.c +++ b/sys/src/lib/mp/port/mpextendedgcd.c @@ -56,7 +56,7 @@ mpextendedgcd(mpint *a, mpint *b, mpint *v, mpint *x, mpint *y) D = mpcopy(mpone); for(;;) { -// print("%B %B %B %B %B %B\n", u, v, A, B, C, D); +// jehanne_print("%B %B %B %B %B %B\n", u, v, A, B, C, D); while(iseven(u)){ mpright(u, 1, u); if(!iseven(A) || !iseven(B)) { @@ -67,7 +67,7 @@ mpextendedgcd(mpint *a, mpint *b, mpint *v, mpint *x, mpint *y) mpright(B, 1, B); } -// print("%B %B %B %B %B %B\n", u, v, A, B, C, D); +// jehanne_print("%B %B %B %B %B %B\n", u, v, A, B, C, D); while(iseven(v)){ mpright(v, 1, v); if(!iseven(C) || !iseven(D)) { @@ -78,7 +78,7 @@ mpextendedgcd(mpint *a, mpint *b, mpint *v, mpint *x, mpint *y) mpright(D, 1, D); } -// print("%B %B %B %B %B %B\n", u, v, A, B, C, D); +// jehanne_print("%B %B %B %B %B %B\n", u, v, A, B, C, D); if(mpcmp(u, v) >= 0){ mpsub(u, v, u); mpsub(A, C, A); diff --git a/sys/src/lib/mp/port/mpfactorial.c b/sys/src/lib/mp/port/mpfactorial.c index 0d6f55c..9ff3160 100644 --- a/sys/src/lib/mp/port/mpfactorial.c +++ b/sys/src/lib/mp/port/mpfactorial.c @@ -27,7 +27,7 @@ mpfactorial(uint32_t n) if((cnt & 1) == 0){ s = stk[max]; mpbits(r, Dbits*(s->top+1+1)); - memset(r->p, 0, Dbytes*(s->top+1+1)); + jehanne_memset(r->p, 0, Dbytes*(s->top+1+1)); mpvecmul(s->p, s->top, &p, 1, r->p); r->sign = 1; r->top = s->top+1+1; /* XXX: norm */ @@ -59,7 +59,7 @@ mpfactorial(uint32_t n) }else{ s = stk[max--]; mpbits(r, Dbits*(s->top+1+1)); - memset(r->p, 0, Dbytes*(s->top+1+1)); + jehanne_memset(r->p, 0, Dbytes*(s->top+1+1)); mpvecmul(s->p, s->top, &p, 1, r->p); r->sign = 1; r->top = s->top+1+1; /* XXX: norm */ diff --git a/sys/src/lib/mp/port/mpfield.c b/sys/src/lib/mp/port/mpfield.c index f78e188..835e9cd 100644 --- a/sys/src/lib/mp/port/mpfield.c +++ b/sys/src/lib/mp/port/mpfield.c @@ -15,7 +15,7 @@ mpfield(mpint *N) goto Exchange; return N; Exchange: - setmalloctag(f, getcallerpc()); + jehanne_setmalloctag(f, jehanne_getcallerpc()); mpfree(N); return f; } diff --git a/sys/src/lib/mp/port/mpfmt.c b/sys/src/lib/mp/port/mpfmt.c index 064acc3..2323530 100644 --- a/sys/src/lib/mp/port/mpfmt.c +++ b/sys/src/lib/mp/port/mpfmt.c @@ -13,7 +13,7 @@ toencx(mpint *b, char *buf, int len, int (*enc)(char*, int, const uint8_t*, int) if(n < 0) return -1; rv = (*enc)(buf, len, p, n); - free(p); + jehanne_free(p); return rv; } @@ -99,7 +99,7 @@ to10(mpint *b, char *buf, int len) return -1; len -= out-buf; if(out != buf) - memmove(buf, out, len); + jehanne_memmove(buf, out, len); return 0; } @@ -144,7 +144,7 @@ Digout: i -= 3; len -= out-buf; if(out != buf) - memmove(buf, out, len); + jehanne_memmove(buf, out, len); return 0; } @@ -157,7 +157,7 @@ mpfmt(Fmt *fmt) b = va_arg(fmt->args, mpint*); if(b == nil) - return fmtstrcpy(fmt, "*"); + return jehanne_fmtstrcpy(fmt, "*"); base = fmt->prec; if(base == 0) @@ -165,7 +165,7 @@ mpfmt(Fmt *fmt) fmt->flags &= ~FmtPrec; p = mptoa(b, base, nil, 0); if(p == nil) - return fmtstrcpy(fmt, "*"); + return jehanne_fmtstrcpy(fmt, "*"); else{ if((fmt->flags & FmtSharp) != 0){ switch(base){ @@ -182,13 +182,13 @@ mpfmt(Fmt *fmt) x = ""; } if(*p == '-') - fmtprint(fmt, "-%s%s", x, p + 1); + jehanne_fmtprint(fmt, "-%s%s", x, p + 1); else - fmtprint(fmt, "%s%s", x, p); + jehanne_fmtprint(fmt, "%s%s", x, p); } else - fmtstrcpy(fmt, p); - free(p); + jehanne_fmtstrcpy(fmt, p); + jehanne_free(p); return 0; } } @@ -207,7 +207,7 @@ mptoa(mpint *b, int base, char *buf, int len) for(rv=1; (base >> rv) > 1; rv++) ; len = 10 + (b->top*Dbits / rv); - buf = malloc(len); + buf = jehanne_malloc(len); if(buf == nil) return nil; alloced = 1; @@ -223,10 +223,10 @@ mptoa(mpint *b, int base, char *buf, int len) } switch(base){ case 64: - rv = toencx(b, out, len, enc64); + rv = toencx(b, out, len, jehanne_enc64); break; case 32: - rv = toencx(b, out, len, enc32); + rv = toencx(b, out, len, jehanne_enc32); break; case 16: rv = topow2(b, out, len, 4); @@ -249,7 +249,7 @@ mptoa(mpint *b, int base, char *buf, int len) } if(rv < 0){ if(alloced) - free(buf); + jehanne_free(buf); return nil; } return buf; diff --git a/sys/src/lib/mp/port/mpmodop.c b/sys/src/lib/mp/port/mpmodop.c index 331f1cc..fa21932 100644 --- a/sys/src/lib/mp/port/mpmodop.c +++ b/sys/src/lib/mp/port/mpmodop.c @@ -11,7 +11,7 @@ modarg(mpint *a, mpint *m) mpbits(a, Dbits*(m->top+1)); a->top = m->top; } else if(a->top < m->top){ - memset(&a->p[a->top], 0, (m->top - a->top)*Dbytes); + jehanne_memset(&a->p[a->top], 0, (m->top - a->top)*Dbytes); } return a; } diff --git a/sys/src/lib/mp/port/mpmul.c b/sys/src/lib/mp/port/mpmul.c index 777adf3..bbace1c 100644 --- a/sys/src/lib/mp/port/mpmul.c +++ b/sys/src/lib/mp/port/mpmul.c @@ -40,9 +40,9 @@ mpkaratsuba(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *p) v1 = b + v0len; // room for the partial products - t = mallocz(Dbytes*5*(2*n+1), 1); + t = jehanne_mallocz(Dbytes*5*(2*n+1), 1); if(t == nil) - sysfatal("mpkaratsuba: %r"); + jehanne_sysfatal("mpkaratsuba: %r"); u0v0 = t; u1v1 = t + (2*n+1); diffprod = t + 2*(2*n+1); @@ -68,7 +68,7 @@ mpkaratsuba(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *p) mpvecmul(u0v0, u0len, u1v1, v0len, diffprod); // t[0:1] = u1*v1 - memset(t, 0, 2*(2*n+1)*Dbytes); + jehanne_memset(t, 0, 2*(2*n+1)*Dbytes); if(v1len > 0) mpvecmul(u1, u1len, v1, v1len, u1v1); @@ -90,9 +90,9 @@ mpkaratsuba(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *p) mpvecsub(res+n, reslen-n, diffprod, u0len+v0len, res+n); else mpvecadd(res+n, reslen-n, diffprod, u0len+v0len, res+n); - memmove(p, res, (alen+blen)*Dbytes); + jehanne_memmove(p, res, (alen+blen)*Dbytes); - free(t); + jehanne_free(t); } #define KARATSUBAMIN 32 diff --git a/sys/src/lib/mp/port/mpnrand.c b/sys/src/lib/mp/port/mpnrand.c index 8460cc0..5eeef9e 100644 --- a/sys/src/lib/mp/port/mpnrand.c +++ b/sys/src/lib/mp/port/mpnrand.c @@ -17,7 +17,7 @@ mpnrand(mpint *n, void (*gen)(uint8_t*, int), mpint *b) if(b == nil){ b = mpnew(bits); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); } /* m = m - (m % n) */ diff --git a/sys/src/lib/mp/port/mprand.c b/sys/src/lib/mp/port/mprand.c index 2bdd309..605e731 100644 --- a/sys/src/lib/mp/port/mprand.c +++ b/sys/src/lib/mp/port/mprand.c @@ -12,16 +12,16 @@ mprand(int bits, void (*gen)(uint8_t*, int), mpint *b) n = DIGITS(bits); if(b == nil){ b = mpnew(bits); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); }else mpbits(b, bits); - p = malloc(n*Dbytes); + p = jehanne_malloc(n*Dbytes); if(p == nil) - sysfatal("mprand: %r"); + jehanne_sysfatal("mprand: %r"); (*gen)(p, n*Dbytes); betomp(p, n*Dbytes, b); - free(p); + jehanne_free(p); // make sure we don't give too many bits m = bits%Dbits; diff --git a/sys/src/lib/mp/port/mpsub.c b/sys/src/lib/mp/port/mpsub.c index 292648f..e21fdbb 100644 --- a/sys/src/lib/mp/port/mpsub.c +++ b/sys/src/lib/mp/port/mpsub.c @@ -2,7 +2,7 @@ #include #include "dat.h" -// diff = abs(b1) - abs(b2), i.e., subtract the magnitudes +// diff = jehanne_abs(b1) - jehanne_abs(b2), i.e., subtract the magnitudes void mpmagsub(mpint *b1, mpint *b2, mpint *diff) { diff --git a/sys/src/lib/mp/port/mptobe.c b/sys/src/lib/mp/port/mptobe.c index eac7ef4..610ff3e 100644 --- a/sys/src/lib/mp/port/mptobe.c +++ b/sys/src/lib/mp/port/mptobe.c @@ -16,15 +16,15 @@ mptobe(mpint *b, uint8_t *p, uint32_t n, uint8_t **pp) m++; if(p == nil){ n = m; - p = malloc(n); + p = jehanne_malloc(n); if(p == nil) - sysfatal("mptobe: %r"); - setmalloctag(p, getcallerpc()); + jehanne_sysfatal("mptobe: %r"); + jehanne_setmalloctag(p, jehanne_getcallerpc()); } else { if(n < m) return -1; if(n > m) - memset(p+m, 0, n-m); + jehanne_memset(p+m, 0, n-m); } if(pp != nil) *pp = p; diff --git a/sys/src/lib/mp/port/mptober.c b/sys/src/lib/mp/port/mptober.c index 73932a0..ac73e1d 100644 --- a/sys/src/lib/mp/port/mptober.c +++ b/sys/src/lib/mp/port/mptober.c @@ -8,7 +8,7 @@ mptober(mpint *b, uint8_t *p, int n) int i, j, m; mpdigit x; - memset(p, 0, n); + jehanne_memset(p, 0, n); p += n; m = b->top*Dbytes; diff --git a/sys/src/lib/mp/port/mptoi.c b/sys/src/lib/mp/port/mptoi.c index ee5d753..f7a5cc7 100644 --- a/sys/src/lib/mp/port/mptoi.c +++ b/sys/src/lib/mp/port/mptoi.c @@ -12,7 +12,7 @@ itomp(int i, mpint *b) { if(b == nil){ b = mpnew(0); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); } b->sign = (i >> (sizeof(i)*8 - 1)) | 1; i *= b->sign; diff --git a/sys/src/lib/mp/port/mptole.c b/sys/src/lib/mp/port/mptole.c index 9f32b20..075c6aa 100644 --- a/sys/src/lib/mp/port/mptole.c +++ b/sys/src/lib/mp/port/mptole.c @@ -16,10 +16,10 @@ mptole(mpint *b, uint8_t *p, uint32_t n, uint8_t **pp) m++; if(p == nil){ n = m; - p = malloc(n); + p = jehanne_malloc(n); if(p == nil) - sysfatal("mptole: %r"); - setmalloctag(p, getcallerpc()); + jehanne_sysfatal("mptole: %r"); + jehanne_setmalloctag(p, jehanne_getcallerpc()); } else if(n < m) return -1; if(pp != nil) diff --git a/sys/src/lib/mp/port/mptolel.c b/sys/src/lib/mp/port/mptolel.c index 3622ef7..7185fcb 100644 --- a/sys/src/lib/mp/port/mptolel.c +++ b/sys/src/lib/mp/port/mptolel.c @@ -8,7 +8,7 @@ mptolel(mpint *b, uint8_t *p, int n) int i, j, m; mpdigit x; - memset(p, 0, n); + jehanne_memset(p, 0, n); m = b->top*Dbytes; if(m < n) diff --git a/sys/src/lib/mp/port/mptoui.c b/sys/src/lib/mp/port/mptoui.c index c7b4108..911cb19 100644 --- a/sys/src/lib/mp/port/mptoui.c +++ b/sys/src/lib/mp/port/mptoui.c @@ -12,7 +12,7 @@ uitomp(uint32_t i, mpint *b) { if(b == nil){ b = mpnew(0); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); } *b->p = i; b->top = 1; diff --git a/sys/src/lib/mp/port/mptouv.c b/sys/src/lib/mp/port/mptouv.c index 09a4076..567352b 100644 --- a/sys/src/lib/mp/port/mptouv.c +++ b/sys/src/lib/mp/port/mptouv.c @@ -15,7 +15,7 @@ uvtomp(uint64_t v, mpint *b) if(b == nil){ b = mpnew(VLDIGITS*sizeof(mpdigit)); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); }else mpbits(b, VLDIGITS*sizeof(mpdigit)); b->sign = 1; diff --git a/sys/src/lib/mp/port/mptov.c b/sys/src/lib/mp/port/mptov.c index 8ff06b6..21bbd66 100644 --- a/sys/src/lib/mp/port/mptov.c +++ b/sys/src/lib/mp/port/mptov.c @@ -16,7 +16,7 @@ vtomp(int64_t v, mpint *b) if(b == nil){ b = mpnew(VLDIGITS*sizeof(mpdigit)); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); }else mpbits(b, VLDIGITS*sizeof(mpdigit)); b->sign = (v >> (sizeof(v)*8 - 1)) | 1; diff --git a/sys/src/lib/mp/port/strtomp.c b/sys/src/lib/mp/port/strtomp.c index 7ebaffe..c88d5ea 100644 --- a/sys/src/lib/mp/port/strtomp.c +++ b/sys/src/lib/mp/port/strtomp.c @@ -25,10 +25,10 @@ init(void) { char *p; - memset(tab.t64, INVAL, sizeof(tab.t64)); - memset(tab.t32, INVAL, sizeof(tab.t32)); - memset(tab.t16, INVAL, sizeof(tab.t16)); - memset(tab.t10, INVAL, sizeof(tab.t10)); + jehanne_memset(tab.t64, INVAL, sizeof(tab.t64)); + jehanne_memset(tab.t32, INVAL, sizeof(tab.t32)); + jehanne_memset(tab.t16, INVAL, sizeof(tab.t16)); + jehanne_memset(tab.t10, INVAL, sizeof(tab.t10)); for(p = set64; *p; p++) tab.t64[(uint8_t)(*p)] = p-set64; @@ -159,13 +159,13 @@ fromdecx(char *a, mpint *b, uint8_t tab[256], int (*dec)(uint8_t*, int, const ch ; n = a-buf; if(n > 0){ - p = malloc(n); + p = jehanne_malloc(n); if(p == nil) - sysfatal("malloc: %r"); + jehanne_sysfatal("malloc: %r"); m = (*dec)(p, n, buf, n); if(m > 0) betomp(p, m, b); - free(p); + jehanne_free(p); } return a; } @@ -178,7 +178,7 @@ strtomp(char *a, char **pp, int base, mpint *b) if(b == nil){ b = mpnew(0); - setmalloctag(b, getcallerpc()); + jehanne_setmalloctag(b, jehanne_getcallerpc()); } if(tab.inited == 0) @@ -230,10 +230,10 @@ strtomp(char *a, char **pp, int base, mpint *b) e = frompow2(a, b, 4); break; case 32: - e = fromdecx(a, b, tab.t32, dec32); + e = fromdecx(a, b, tab.t32, jehanne_dec32); break; case 64: - e = fromdecx(a, b, tab.t64, dec64); + e = fromdecx(a, b, tab.t64, jehanne_dec64); break; default: abort(); diff --git a/sys/src/lib/mp/test.c b/sys/src/lib/mp/test.c index 71f09e4..864fee6 100644 --- a/sys/src/lib/mp/test.c +++ b/sys/src/lib/mp/test.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "dat.h" @@ -9,7 +9,7 @@ void prng(uint8_t *p, int n) { while(n-- > 0) - *p++ = rand(); + *p++ = jehanne_rand(); } void @@ -19,28 +19,28 @@ testconv(char *str) mpint *b; char *p; - print("testconv \"%s\":\n", str); + jehanne_print("testconv \"%s\":\n", str); b = strtomp(str, nil, 16, nil); for(i=0; itop+1)*Dbits); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++){ - memset(b2->p, 0, b2->top*Dbytes); + jehanne_memset(b2->p, 0, b2->top*Dbytes); mpvecdigmuladd(b->p, b->top, d, b2->p); } if(loops > 1) - print("%lld ns for a %d*%d vecdigmul\n", (nsec()-now)/loops, b->top*Dbits, Dbits); + jehanne_print("%lld ns for a %d*%d vecdigmul\n", (jehanne_nsec()-now)/loops, b->top*Dbits, Dbits); mpnorm(b2); - print("0 + %B * %ux = %B\n", b, d, b2); + jehanne_print("0 + %B * %ux = %B\n", b, d, b2); mpfree(b); mpfree(b2); @@ -125,15 +125,15 @@ testvecdigmulsub(char *str, mpdigit d) b2 = mpnew(0); mpbits(b2, (b->top+1)*Dbits); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++){ - memset(b2->p, 0, b2->top*Dbytes); + jehanne_memset(b2->p, 0, b2->top*Dbytes); mpvecdigmulsub(b->p, b->top, d, b2->p); } if(loops > 1) - print("%lld ns for a %d*%d vecdigmul\n", (nsec()-now)/loops, b->top*Dbits, Dbits); + jehanne_print("%lld ns for a %d*%d vecdigmul\n", (jehanne_nsec()-now)/loops, b->top*Dbits, Dbits); mpnorm(b2); - print("0 - %B * %ux = %B\n", b, d, b2); + jehanne_print("0 - %B * %ux = %B\n", b, d, b2); mpfree(b); mpfree(b2); @@ -150,13 +150,13 @@ testmul(char *str) b1 = mpcopy(b); b2 = mpnew(0); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpmul(b, b1, b2); if(loops > 1) - print("%lld µs for a %d*%d mult\n", (nsec()-now)/(loops*1000), + jehanne_print("%lld µs for a %d*%d mult\n", (jehanne_nsec()-now)/(loops*1000), b->top*Dbits, b1->top*Dbits); - print("%B * %B = %B\n", b, b1, b2); + jehanne_print("%B * %B = %B\n", b, b1, b2); mpfree(b); mpfree(b1); @@ -172,14 +172,14 @@ testmul2(mpint *b, mpint *b1) b2 = mpnew(0); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpmul(b, b1, b2); if(loops > 1) - print("%lld µs for a %d*%d mult\n", (nsec()-now)/(loops*1000), b->top*Dbits, b1->top*Dbits); - print("%B * ", b); - print("%B = ", b1); - print("%B\n", b2); + jehanne_print("%lld µs for a %d*%d mult\n", (jehanne_nsec()-now)/(loops*1000), b->top*Dbits, b1->top*Dbits); + jehanne_print("%B * ", b); + jehanne_print("%B = ", b1); + jehanne_print("%B\n", b2); mpfree(b2); } @@ -193,12 +193,12 @@ testdigdiv(char *str, mpdigit d) int64_t now; b = strtomp(str, nil, 16, nil); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpdigdiv(b->p, d, &q); if(loops > 1) - print("%lld ns for a %d / %d div\n", (nsec()-now)/loops, 2*Dbits, Dbits); - print("%B / %ux = %ux\n", b, d, q); + jehanne_print("%lld ns for a %d / %d div\n", (jehanne_nsec()-now)/loops, 2*Dbits, Dbits); + jehanne_print("%B / %ux = %ux\n", b, d, q); mpfree(b); } @@ -211,13 +211,13 @@ testdiv(mpint *x, mpint *y) b2 = mpnew(0); b3 = mpnew(0); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpdiv(x, y, b2, b3); if(loops > 1) - print("%lld µs for a %d/%d div\n", (nsec()-now)/(1000*loops), + jehanne_print("%lld µs for a %d/%d div\n", (jehanne_nsec()-now)/(1000*loops), x->top*Dbits, y->top*Dbits); - print("%B / %B = %B %B\n", x, y, b2, b3); + jehanne_print("%B / %B = %B %B\n", x, y, b2, b3); mpfree(b2); mpfree(b3); } @@ -230,13 +230,13 @@ testmod(mpint *x, mpint *y) int i; r = mpnew(0); - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpmod(x, y, r); if(loops > 1) - print("%lld µs for a %d/%d mod\n", (nsec()-now)/(1000*loops), + jehanne_print("%lld µs for a %d/%d mod\n", (jehanne_nsec()-now)/(1000*loops), x->top*Dbits, y->top*Dbits); - print("%B mod %B = %B\n", x, y, r); + jehanne_print("%B mod %B = %B\n", x, y, r); mpfree(r); } @@ -250,19 +250,19 @@ testinvert(mpint *x, mpint *y) r = mpnew(0); d1 = mpnew(0); d2 = mpnew(0); - now = nsec(); + now = jehanne_nsec(); mpextendedgcd(x, y, r, d1, d2); mpdiv(x, r, x, d1); mpdiv(y, r, y, d1); for(i = 0; i < loops; i++) mpinvert(x, y, r); if(loops > 1) - print("%lld µs for a %d in %d invert\n", (nsec()-now)/(1000*loops), + jehanne_print("%lld µs for a %d in %d invert\n", (jehanne_nsec()-now)/(1000*loops), x->top*Dbits, y->top*Dbits); - print("%B**-1 mod %B = %B\n", x, y, r); + jehanne_print("%B**-1 mod %B = %B\n", x, y, r); mpmul(r, x, d1); mpmod(d1, y, d2); - print("%B*%B mod %B = %B\n", x, r, y, d2); + jehanne_print("%B*%B mod %B = %B\n", x, r, y, d2); mpfree(r); mpfree(d1); mpfree(d2); @@ -277,7 +277,7 @@ testsub1(char *a, char *b) b2 = strtomp(b, nil, 16, nil); b3 = mpnew(0); mpsub(b1, b2, b3); - print("%B - %B = %B\n", b1, b2, b3); + jehanne_print("%B - %B = %B\n", b1, b2, b3); } void @@ -289,7 +289,7 @@ testmul1(char *a, char *b) b2 = strtomp(b, nil, 16, nil); b3 = mpnew(0); mpmul(b1, b2, b3); - print("%B * %B = %B\n", b1, b2, b3); + jehanne_print("%B * %B = %B\n", b1, b2, b3); } void @@ -306,16 +306,16 @@ testexp(char *base, char *exp, char *mod) m = strtomp(mod, nil, 16, nil); else m = nil; - now = nsec(); + now = jehanne_nsec(); for(i = 0; i < loops; i++) mpexp(b, e, m, res); if(loops > 1) - print("%ulldµs for a %d to the %d bit exp\n", (nsec()-now)/(loops*1000), + jehanne_print("%ulldµs for a %d to the %d bit exp\n", (jehanne_nsec()-now)/(loops*1000), b->top*Dbits, e->top*Dbits); if(m != nil) - print("%B ^ %B mod %B == %B\n", b, e, m, res); + jehanne_print("%B ^ %B mod %B == %B\n", b, e, m, res); else - print("%B ^ %B == %B\n", b, e, res); + jehanne_print("%B ^ %B == %B\n", b, e, res); mpfree(b); mpfree(e); mpfree(res); @@ -342,24 +342,24 @@ testgcd(void) a = strtomp("4EECAB3E04C4E6BC1F49D438731450396BF272B4D7B08F91C38E88ADCD281699889AFF872E2204C80CCAA8E460797103DE539D5DF8335A9B20C0B44886384F134C517287202FCA914D8A5096446B40CD861C641EF9C2730CB057D7B133F4C2B16BBD3D75FDDBD9151AAF0F9144AAA473AC93CF945DBFE0859FB685D5CBD0A8B3", nil, 16, nil); b = strtomp("C41CFBE4D4846F67A3DF7DE9921A49D3B42DC33728427AB159CEC8CBBDB12B5F0C244F1A734AEB9840804EA3C25036AD1B61AFF3ABBC247CD4B384224567A863A6F020E7EE9795554BCD08ABAD7321AF27E1E92E3DB1C6E7E94FAAE590AE9C48F96D93D178E809401ABE8A534A1EC44359733475A36A70C7B425125062B1142D", nil, 16, nil); mpextendedgcd(a, b, d, x, y); - print("gcd %B*%B+%B*%B = %B?\n", a, x, b, y, d); + jehanne_print("gcd %B*%B+%B*%B = %B?\n", a, x, b, y, d); mpfree(a); mpfree(b); for(i = 0; i < loops; i++){ a = mprand(2048, prng, nil); b = mprand(2048, prng, nil); - then = nsec(); + then = jehanne_nsec(); mpextendedgcd(a, b, d, x, y); - now = nsec(); + now = jehanne_nsec(); etime += now-then; mpmul(a, x, t1); mpmul(b, y, t2); mpadd(t1, t2, t2); if(mpcmp(d, t2) != 0) - print("%d gcd %B*%B+%B*%B != %B\n", i, a, x, b, y, d); + jehanne_print("%d gcd %B*%B+%B*%B != %B\n", i, a, x, b, y, d); // else -// print("%d euclid %B*%B+%B*%B == %B\n", i, a, x, b, y, d); +// jehanne_print("%d euclid %B*%B+%B*%B == %B\n", i, a, x, b, y, d); mpfree(a); mpfree(b); } @@ -371,7 +371,7 @@ testgcd(void) mpfree(t2); if(loops > 1) - print("binary %llud\n", etime); + jehanne_print("binary %llud\n", etime); } extern int _unnormalizedwarning = 1; @@ -383,13 +383,13 @@ main(int argc, char **argv) ARGBEGIN{ case 'n': - loops = atoi(ARGF()); + loops = jehanne_atoi(ARGF()); break; }ARGEND; - fmtinstall('B', mpfmt); - fmtinstall('Q', mpfmt); - srand(0); + jehanne_fmtinstall('B', mpfmt); + jehanne_fmtinstall('Q', mpfmt); + jehanne_srand(0); mpsetminbits(2*Dbits); testshift("1111111111111111"); testaddsub("fffffffffffffffff"); @@ -441,6 +441,6 @@ main(int argc, char **argv) testexp("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); #ifdef asdf #endif adsf - print("done\n"); - exits(0); + jehanne_print("done\n"); + jehanne_exits(0); } diff --git a/sys/src/lib/ndb/csgetval.c b/sys/src/lib/ndb/csgetval.c index a0409db..97363e5 100644 --- a/sys/src/lib/ndb/csgetval.c +++ b/sys/src/lib/ndb/csgetval.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "ndbhf.h" diff --git a/sys/src/lib/ndb/csipinfo.c b/sys/src/lib/ndb/csipinfo.c index bc0969b..aa2d66e 100644 --- a/sys/src/lib/ndb/csipinfo.c +++ b/sys/src/lib/ndb/csipinfo.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "ndbhf.h" diff --git a/sys/src/lib/ndb/dnsquery.c b/sys/src/lib/ndb/dnsquery.c index e0bbb67..c3240d4 100644 --- a/sys/src/lib/ndb/dnsquery.c +++ b/sys/src/lib/ndb/dnsquery.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "ndbhf.h" diff --git a/sys/src/lib/ndb/ndbaux.c b/sys/src/lib/ndb/ndbaux.c index 823ea1b..63d9eee 100644 --- a/sys/src/lib/ndb/ndbaux.c +++ b/sys/src/lib/ndb/ndbaux.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbcache.c b/sys/src/lib/ndb/ndbcache.c index 0377c1f..06f476c 100644 --- a/sys/src/lib/ndb/ndbcache.c +++ b/sys/src/lib/ndb/ndbcache.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ndb/ndbcat.c b/sys/src/lib/ndb/ndbcat.c index f7e8083..bed2558 100644 --- a/sys/src/lib/ndb/ndbcat.c +++ b/sys/src/lib/ndb/ndbcat.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbconcatenate.c b/sys/src/lib/ndb/ndbconcatenate.c index 9a6310e..c41efa5 100644 --- a/sys/src/lib/ndb/ndbconcatenate.c +++ b/sys/src/lib/ndb/ndbconcatenate.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ndb/ndbdiscard.c b/sys/src/lib/ndb/ndbdiscard.c index e9ed245..6e57b93 100644 --- a/sys/src/lib/ndb/ndbdiscard.c +++ b/sys/src/lib/ndb/ndbdiscard.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ndb/ndbfree.c b/sys/src/lib/ndb/ndbfree.c index 8c0c7af..d6b1985 100644 --- a/sys/src/lib/ndb/ndbfree.c +++ b/sys/src/lib/ndb/ndbfree.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbgetipaddr.c b/sys/src/lib/ndb/ndbgetipaddr.c index 3cb5a83..0173b03 100644 --- a/sys/src/lib/ndb/ndbgetipaddr.c +++ b/sys/src/lib/ndb/ndbgetipaddr.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbgetval.c b/sys/src/lib/ndb/ndbgetval.c index d82c6c7..c8198d7 100644 --- a/sys/src/lib/ndb/ndbgetval.c +++ b/sys/src/lib/ndb/ndbgetval.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "ndb.h" diff --git a/sys/src/lib/ndb/ndbhash.c b/sys/src/lib/ndb/ndbhash.c index 1ce21f3..12a6ab8 100644 --- a/sys/src/lib/ndb/ndbhash.c +++ b/sys/src/lib/ndb/ndbhash.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include "ndb.h" #include "ndbhf.h" diff --git a/sys/src/lib/ndb/ndbipinfo.c b/sys/src/lib/ndb/ndbipinfo.c index b7b8dac..93da097 100644 --- a/sys/src/lib/ndb/ndbipinfo.c +++ b/sys/src/lib/ndb/ndbipinfo.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndblookval.c b/sys/src/lib/ndb/ndblookval.c index 1589c26..90c35a1 100644 --- a/sys/src/lib/ndb/ndblookval.c +++ b/sys/src/lib/ndb/ndblookval.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbopen.c b/sys/src/lib/ndb/ndbopen.c index 88ea54d..c10b22b 100644 --- a/sys/src/lib/ndb/ndbopen.c +++ b/sys/src/lib/ndb/ndbopen.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbparse.c b/sys/src/lib/ndb/ndbparse.c index 083821e..5ce23e5 100644 --- a/sys/src/lib/ndb/ndbparse.c +++ b/sys/src/lib/ndb/ndbparse.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/src/lib/ndb/ndbreorder.c b/sys/src/lib/ndb/ndbreorder.c index 9d8bfad..b8f11f5 100644 --- a/sys/src/lib/ndb/ndbreorder.c +++ b/sys/src/lib/ndb/ndbreorder.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/ndb/ndbsubstitute.c b/sys/src/lib/ndb/ndbsubstitute.c index 6c5cd9b..849c56d 100644 --- a/sys/src/lib/ndb/ndbsubstitute.c +++ b/sys/src/lib/ndb/ndbsubstitute.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include diff --git a/sys/src/lib/plumb/event.c b/sys/src/lib/plumb/event.c index 688072c..586b87e 100644 --- a/sys/src/lib/plumb/event.c +++ b/sys/src/lib/plumb/event.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include "plumb.h" @@ -33,11 +33,11 @@ partial(int id, Event *e, uint8_t *b, int n) EQueue *eq, *p; int nmore; - lock(&eqlock); + jehanne_lock(&eqlock); for(eq = equeue; eq != nil; eq = eq->next) if(eq->id == id) break; - unlock(&eqlock); + jehanne_unlock(&eqlock); if(eq == nil) return 0; /* partial message exists for this id */ @@ -48,7 +48,7 @@ partial(int id, Event *e, uint8_t *b, int n) eq->nbuf += n; e->v = plumbunpackpartial((char*)eq->buf, eq->nbuf, &nmore); if(nmore == 0){ /* no more to read in this message */ - lock(&eqlock); + jehanne_lock(&eqlock); if(eq == equeue) equeue = eq->next; else{ @@ -58,7 +58,7 @@ partial(int id, Event *e, uint8_t *b, int n) drawerror(display, "eplumb: bad event queue"); p->next = eq->next; } - unlock(&eqlock); + jehanne_unlock(&eqlock); free(eq->buf); free(eq); } @@ -82,10 +82,10 @@ addpartial(int id, char *b, int n) return; } memmove(eq->buf, b, n); - lock(&eqlock); + jehanne_lock(&eqlock); eq->next = equeue; equeue = eq; - unlock(&eqlock); + jehanne_unlock(&eqlock); } static diff --git a/sys/src/lib/plumb/mesg.c b/sys/src/lib/plumb/mesg.c index 8bc1ccd..d3c4284 100644 --- a/sys/src/lib/plumb/mesg.c +++ b/sys/src/lib/plumb/mesg.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "plumb.h" int diff --git a/sys/src/lib/plumb/plumbsendtext.c b/sys/src/lib/plumb/plumbsendtext.c index 9c6ee79..d4e1945 100644 --- a/sys/src/lib/plumb/plumbsendtext.c +++ b/sys/src/lib/plumb/plumbsendtext.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "plumb.h" int diff --git a/sys/src/lib/regexp/regaux.c b/sys/src/lib/regexp/regaux.c index 60b1fc6..6b78a3e 100644 --- a/sys/src/lib/regexp/regaux.c +++ b/sys/src/lib/regexp/regaux.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" #include "regcomp.h" diff --git a/sys/src/lib/regexp/regcomp.c b/sys/src/lib/regexp/regcomp.c index 69249f4..46f1dc1 100644 --- a/sys/src/lib/regexp/regcomp.c +++ b/sys/src/lib/regexp/regcomp.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" #include "regcomp.h" diff --git a/sys/src/lib/regexp/regerror.c b/sys/src/lib/regexp/regerror.c index 8af53ea..08dbffe 100644 --- a/sys/src/lib/regexp/regerror.c +++ b/sys/src/lib/regexp/regerror.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" void diff --git a/sys/src/lib/regexp/regexec.c b/sys/src/lib/regexp/regexec.c index 1e2e443..8287dac 100644 --- a/sys/src/lib/regexp/regexec.c +++ b/sys/src/lib/regexp/regexec.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" #include "regcomp.h" diff --git a/sys/src/lib/regexp/regsub.c b/sys/src/lib/regexp/regsub.c index 083a6b9..7b39d2d 100644 --- a/sys/src/lib/regexp/regsub.c +++ b/sys/src/lib/regexp/regsub.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" /* substitute into one string using the matches from the last regexec() */ diff --git a/sys/src/lib/regexp/rregexec.c b/sys/src/lib/regexp/rregexec.c index c7a9b66..cb1d85f 100644 --- a/sys/src/lib/regexp/rregexec.c +++ b/sys/src/lib/regexp/rregexec.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" #include "regcomp.h" diff --git a/sys/src/lib/regexp/rregsub.c b/sys/src/lib/regexp/rregsub.c index 299a7a6..aa46b60 100644 --- a/sys/src/lib/regexp/rregsub.c +++ b/sys/src/lib/regexp/rregsub.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include "regexp.h" /* substitute into one string using the matches from the last regexec() */ diff --git a/sys/src/lib/sec/port/aes.c b/sys/src/lib/sec/port/aes.c index 68b4bdb..c8e03dd 100644 --- a/sys/src/lib/sec/port/aes.c +++ b/sys/src/lib/sec/port/aes.c @@ -70,14 +70,14 @@ void aes_decrypt(const uint32_t rk[], int Nr, const uint8_t ct[16], uint8_t pt[1 void setupAESstate(AESstate *s, uint8_t key[], int keybytes, uint8_t *ivec) { - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); if(keybytes > AESmaxkey) keybytes = AESmaxkey; - memmove(s->key, key, keybytes); + jehanne_memmove(s->key, key, keybytes); s->keybytes = keybytes; s->rounds = aes_setup(s->ekey, s->dkey, s->key, keybytes * 8); if(ivec != nil) - memmove(s->ivec, ivec, AESbsize); + jehanne_memmove(s->ivec, ivec, AESbsize); if(keybytes==16 || keybytes==24 || keybytes==32) s->setup = 0xcafebabe; /* else aes_setup was invalid */ @@ -100,7 +100,7 @@ setupAESXCBCstate(AESstate *s) /* was setupmac96 */ s->mackey + AESbsize*i); p = s->mackey; - memset(q, 0, AESbsize); + jehanne_memset(q, 0, AESbsize); /* * put the in the right endian. once figured, probably better @@ -114,7 +114,7 @@ setupAESXCBCstate(AESstate *s) /* was setupmac96 */ q[i] |= p[sizeof(uint32_t)-j-1] << 8*j; p += sizeof(uint32_t); } - memmove(s->mackey, q, 16); + jehanne_memmove(s->mackey, q, 16); } /* @@ -129,10 +129,10 @@ aesXCBCmac(uint8_t *p, int len, AESstate *s) assert(s->keybytes == 16); /* more complicated for bigger */ assert(s->rounds <= sizeof(s->mackey)/sizeof(uint32_t)); - memset(s->ivec, 0, AESbsize); /* E[0] is 0+ */ + jehanne_memset(s->ivec, 0, AESbsize); /* E[0] is 0+ */ for(; len > AESbsize; len -= AESbsize){ - memmove(q, p, AESbsize); + jehanne_memmove(q, p, AESbsize); p2 = q; ip = s->ivec; for(eip = ip + AESbsize; ip < eip; ) @@ -142,7 +142,7 @@ aesXCBCmac(uint8_t *p, int len, AESstate *s) } /* the last one */ - memmove(q, p, len); + jehanne_memmove(q, p, len); if(len == AESbsize) mackey = s->mackey + AESbsize; /* k2 */ else{ @@ -150,7 +150,7 @@ aesXCBCmac(uint8_t *p, int len, AESstate *s) p2 = q+len; /* padding */ *p2++ = 1 << 7; len = AESbsize - len - 1; - memset(p2, 0, len); + jehanne_memset(p2, 0, len); } ip = s->ivec; @@ -178,15 +178,15 @@ aesCBCencrypt(uint8_t *p, int len, AESstate *s) for(eip = ip+AESbsize; ip < eip; ) *p2++ ^= *ip++; aes_encrypt(s->ekey, s->rounds, p, q); - memmove(s->ivec, q, AESbsize); - memmove(p, q, AESbsize); + jehanne_memmove(s->ivec, q, AESbsize); + jehanne_memmove(p, q, AESbsize); p += AESbsize; } if(len > 0){ ip = s->ivec; aes_encrypt(s->ekey, s->rounds, ip, q); - memmove(s->ivec, q, AESbsize); + jehanne_memmove(s->ivec, q, AESbsize); for(eip = ip+len; ip < eip; ) *p++ ^= *ip++; } @@ -199,9 +199,9 @@ aesCBCdecrypt(uint8_t *p, int len, AESstate *s) uint8_t tmp[AESbsize], q[AESbsize]; for(; len >= AESbsize; len -= AESbsize){ - memmove(tmp, p, AESbsize); + jehanne_memmove(tmp, p, AESbsize); aes_decrypt(s->dkey, s->rounds, p, q); - memmove(p, q, AESbsize); + jehanne_memmove(p, q, AESbsize); tp = tmp; ip = s->ivec; for(eip = ip+AESbsize; ip < eip; ){ @@ -213,7 +213,7 @@ aesCBCdecrypt(uint8_t *p, int len, AESstate *s) if(len > 0){ ip = s->ivec; aes_encrypt(s->ekey, s->rounds, ip, q); - memmove(s->ivec, q, AESbsize); + jehanne_memmove(s->ivec, q, AESbsize); for(eip = ip+len; ip < eip; ) *p++ ^= *ip++; } diff --git a/sys/src/lib/sec/port/aes_gcm.c b/sys/src/lib/sec/port/aes_gcm.c index 25220f8..789b83f 100644 --- a/sys/src/lib/sec/port/aes_gcm.c +++ b/sys/src/lib/sec/port/aes_gcm.c @@ -86,8 +86,8 @@ ghashn(AESGCMstate *s, uint8_t *dat, uint32_t len, uint32_t Y[4]) dat += 16, len -= 16; } if(len > 0){ - memmove(tmp, dat, len); - memset(tmp+len, 0, 16-len); + jehanne_memmove(tmp, dat, len); + jehanne_memset(tmp+len, 0, 16-len); load128(tmp, X); ghash1(s, X, Y); } @@ -113,7 +113,7 @@ aesxctrn(AESstate *s, uint8_t *dat, uint32_t len) uint8_t ctr[AESbsize]; uint32_t i; - memmove(ctr, s->ivec, AESbsize); + jehanne_memmove(ctr, s->ivec, AESbsize); while(len > 0){ for(i=AESbsize-1; i>=AESbsize-4; i--) if(++ctr[i] != 0) @@ -130,8 +130,8 @@ void aesgcm_setiv(AESGCMstate *s, uint8_t *iv, int ivlen) { if(ivlen == 96/8){ - memmove(s->ivec, iv, ivlen); - memset(s->ivec+ivlen, 0, AESbsize-ivlen); + jehanne_memmove(s->ivec, iv, ivlen); + jehanne_memset(s->ivec+ivlen, 0, AESbsize-ivlen); s->ivec[AESbsize-1] = 1; } else { uint32_t L[4], Y[4] = {0}; @@ -150,7 +150,7 @@ setupAESGCMstate(AESGCMstate *s, uint8_t *key, int keylen, uint8_t *iv, int ivle { setupAESstate(s, key, keylen, nil); - memset(s->mackey, 0, AESbsize); + jehanne_memset(s->mackey, 0, AESbsize); aes_encrypt(s->ekey, s->rounds, s->mackey, s->mackey); load128(s->mackey, s->H); prepareM(s->H, s->M); diff --git a/sys/src/lib/sec/port/aesgcmtest.c b/sys/src/lib/sec/port/aesgcmtest.c index 2025ec6..84bb624 100644 --- a/sys/src/lib/sec/port/aesgcmtest.c +++ b/sys/src/lib/sec/port/aesgcmtest.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -233,7 +233,7 @@ parsehex(char *s, uint8_t *h, char *l) mpint *m; int n; - n = strlen(s); + n = jehanne_strlen(s); if(n == 0) return 0; assert((n & 1) == 0); @@ -244,7 +244,7 @@ parsehex(char *s, uint8_t *h, char *l) abort(); mptober(m, h, n); if(l != nil) - print("%s = %.*H\n", l, n, h); + jehanne_print("%s = %.*H\n", l, n, h); return n; } @@ -262,11 +262,11 @@ runtest(Test *t) setupAESGCMstate(&s, key, nkey, iv, niv); aesgcm_encrypt(plain, nplain, aad, naad, tag, &s); - print("C = %.*H\n", nplain, plain); - print("T = %.*H\n", 16, tag); + jehanne_print("C = %.*H\n", nplain, plain); + jehanne_print("T = %.*H\n", 16, tag); parsehex(t->T, tmp, nil); - assert(memcmp(tmp, tag, 16) == 0); + assert(jehanne_memcmp(tmp, tag, 16) == 0); } void @@ -278,9 +278,9 @@ perftest(void) int64_t now; int i, delta; - now = nsec(); + now = jehanne_nsec(); for(i=0; i<100; i++){ - memset(buf, 0, sizeof(buf)); + jehanne_memset(buf, 0, sizeof(buf)); if(1){ setupAESGCMstate(&s, zeros, 16, zeros, 12); aesgcm_encrypt(buf, sizeof(buf), nil, 0, tag, &s); @@ -289,8 +289,8 @@ perftest(void) aesCBCencrypt(buf, sizeof(buf), &s); } } - delta = (nsec() - now) / 1000000000LL; - fprint(2, "%ds = %d/s\n", delta, i*sizeof(buf) / delta); + delta = (jehanne_nsec() - now) / 1000000000LL; + jehanne_fprint(2, "%ds = %d/s\n", delta, i*sizeof(buf) / delta); } void @@ -298,17 +298,17 @@ main(int argc, char **argv) { int i; - fmtinstall('H', encodefmt); + jehanne_fmtinstall('H', encodefmt); ARGBEGIN { case 'p': perftest(); - exits(nil); + jehanne_exits(nil); } ARGEND; for(i=0; i -#include +#include #include enum{ @@ -185,35 +185,35 @@ testECB(Testvector *t) int i; uint8_t aux[Bsz]; - memcpy(aux, t->plain, Bsz); + jehanne_memcpy(aux, t->plain, Bsz); - memset(&s, 0, sizeof(BFstate)); + jehanne_memset(&s, 0, sizeof(BFstate)); setupBFstate(&s, t->key, Bsz, nil); bfECBencrypt(aux, Bsz, &s); - if(memcmp(aux, t->cipher, Bsz) != 0){ - fprint(2, "ECB encrypt failed, ciphertext is:\n"); + if(jehanne_memcmp(aux, t->cipher, Bsz) != 0){ + jehanne_fprint(2, "ECB encrypt failed, ciphertext is:\n"); for(i = 0; i < Bsz; i++) - fprint(2, "%02X", aux[i]); - fprint(2, "\nand should be:\n"); + jehanne_fprint(2, "%02X", aux[i]); + jehanne_fprint(2, "\nand should be:\n"); for(i = 0; i < Bsz; i++) - fprint(2, "%02X", t->cipher[i]); - fprint(2, "\n"); + jehanne_fprint(2, "%02X", t->cipher[i]); + jehanne_fprint(2, "\n"); return -1; } - memset(&s, 0, sizeof(BFstate)); + jehanne_memset(&s, 0, sizeof(BFstate)); setupBFstate(&s, t->key, Bsz, nil); bfECBdecrypt(aux, Bsz, &s); - if(memcmp(aux, t->plain, Bsz) != 0){ - fprint(2, "ECB decrypt failed, plaintext is:\n"); + if(jehanne_memcmp(aux, t->plain, Bsz) != 0){ + jehanne_fprint(2, "ECB decrypt failed, plaintext is:\n"); for(i = 0; i < Bsz; i++) - fprint(2, "%02X", aux[i]); - fprint(2, "\nand should be:\n"); + jehanne_fprint(2, "%02X", aux[i]); + jehanne_fprint(2, "\nand should be:\n"); for(i = 0; i < Bsz; i++) - fprint(2, "%02X", t->plain[i]); - fprint(2, "\n"); + jehanne_fprint(2, "%02X", t->plain[i]); + jehanne_fprint(2, "\n"); return -1; } return 0; @@ -226,35 +226,35 @@ testCBC(void) uint8_t aux[32]; int i; - memset(aux, 0 , sizeof(aux)); - memcpy(aux, CBCdata, sizeof(CBCdata)); - memset(&s, 0, sizeof(BFstate)); + jehanne_memset(aux, 0 , sizeof(aux)); + jehanne_memcpy(aux, CBCdata, sizeof(CBCdata)); + jehanne_memset(&s, 0, sizeof(BFstate)); setupBFstate(&s, CBCkey, sizeof(CBCkey), CBCiv); bfCBCencrypt(aux, 32, &s); - if(memcmp(aux, CBCcipher, sizeof(CBCcipher)) != 0){ - fprint(2, "CBC encrypt failed, ciphertext is:\n"); + if(jehanne_memcmp(aux, CBCcipher, sizeof(CBCcipher)) != 0){ + jehanne_fprint(2, "CBC encrypt failed, ciphertext is:\n"); for(i = 0; i < sizeof(aux); i++) - fprint(2, "%02X", aux[i]); - fprint(2, "\nand should be:\n"); + jehanne_fprint(2, "%02X", aux[i]); + jehanne_fprint(2, "\nand should be:\n"); for(i = 0; i < sizeof(CBCcipher); i++) - fprint(2, "%02X", CBCcipher[i]); - fprint(2, "\n"); + jehanne_fprint(2, "%02X", CBCcipher[i]); + jehanne_fprint(2, "\n"); return -1; } - memset(&s, 0, sizeof(BFstate)); + jehanne_memset(&s, 0, sizeof(BFstate)); setupBFstate(&s, CBCkey, sizeof(CBCkey), CBCiv); bfCBCdecrypt(aux, 32, &s); - if(memcmp(aux, CBCdata, sizeof(CBCdata)) != 0){ - fprint(2, "CBC decrypt failed, plaintext is:\n"); + if(jehanne_memcmp(aux, CBCdata, sizeof(CBCdata)) != 0){ + jehanne_fprint(2, "CBC decrypt failed, plaintext is:\n"); for(i = 0; i < sizeof(aux); i++) - fprint(2, "%02X", aux[i]); - fprint(2, "\nand should be:\n"); + jehanne_fprint(2, "%02X", aux[i]); + jehanne_fprint(2, "\nand should be:\n"); for(i = 0; i < sizeof(CBCdata); i++) - fprint(2, "%02X", CBCdata[i]); - fprint(2, "\n"); + jehanne_fprint(2, "%02X", CBCdata[i]); + jehanne_fprint(2, "\n"); return -1; } @@ -267,13 +267,13 @@ main(int argc, char **argv) int i; if(argc != 1) - sysfatal("usage: %s", argv[0]); + jehanne_sysfatal("usage: %s", argv[0]); for(i=0; i < nelem(vector); i++) if(testECB(&vector[i]) < 0) - sysfatal("TestECB %d failed", i); + jehanne_sysfatal("TestECB %d failed", i); if(testCBC() < 0) - sysfatal("TestCBC failed"); - exits(nil); + jehanne_sysfatal("TestCBC failed"); + jehanne_exits(nil); } diff --git a/sys/src/lib/sec/port/blowfish.c b/sys/src/lib/sec/port/blowfish.c index a9f4a2f..6868653 100644 --- a/sys/src/lib/sec/port/blowfish.c +++ b/sys/src/lib/sec/port/blowfish.c @@ -49,21 +49,21 @@ setupBFstate(BFstate *s, uint8_t key[], int keybytes, uint8_t *ivec) int i, j; uint32_t n, buf[2]; - memset(s, 0, sizeof(*s)); - memset(buf, 0, sizeof buf); + jehanne_memset(s, 0, sizeof(*s)); + jehanne_memset(buf, 0, sizeof buf); if (keybytes > sizeof(s->key)) keybytes = sizeof(s->key); - memmove(s->key, key, keybytes); + jehanne_memmove(s->key, key, keybytes); if (ivec != nil) - memmove(s->ivec, ivec, sizeof(s->ivec)); + jehanne_memmove(s->ivec, ivec, sizeof(s->ivec)); else - memset(s->ivec, 0, sizeof(s->ivec)); + jehanne_memset(s->ivec, 0, sizeof(s->ivec)); - memmove(s->pbox, pbox, sizeof(pbox)); - memmove(s->sbox, sbox, sizeof(sbox)); + jehanne_memmove(s->pbox, pbox, sizeof(pbox)); + jehanne_memmove(s->sbox, sbox, sizeof(sbox)); if (keybytes > 4*(BFrounds + 2)) keybytes = 4*(BFrounds + 2); diff --git a/sys/src/lib/sec/port/ccpoly.c b/sys/src/lib/sec/port/ccpoly.c index 7366b93..2c39295 100644 --- a/sys/src/lib/sec/port/ccpoly.c +++ b/sys/src/lib/sec/port/ccpoly.c @@ -6,8 +6,8 @@ ccpolyotk(Chachastate *cs, DigestState *ds) { uint8_t otk[ChachaBsize]; - memset(ds, 0, sizeof(*ds)); - memset(otk, 0, 32); + jehanne_memset(ds, 0, sizeof(*ds)); + jehanne_memset(otk, 0, 32); chacha_setblock(cs, 0); chacha_encrypt(otk, ChachaBsize, cs); poly1305(nil, 0, otk, 32, nil, ds); diff --git a/sys/src/lib/sec/port/chacha.c b/sys/src/lib/sec/port/chacha.c index 1fd3bdf..b41d0fd 100644 --- a/sys/src/lib/sec/port/chacha.c +++ b/sys/src/lib/sec/port/chacha.c @@ -56,9 +56,9 @@ void setupChachastate(Chachastate *s, uint8_t *key, uint32_t keylen, uint8_t *iv, uint32_t ivlen, int rounds) { if(keylen != 256/8 && keylen != 128/8) - sysfatal("invalid chacha key length"); + jehanne_sysfatal("invalid chacha key length"); if(ivlen != 96/8 && ivlen != 64/8) - sysfatal("invalid chacha iv length"); + jehanne_sysfatal("invalid chacha iv length"); if(rounds == 0) rounds = 20; s->rounds = rounds; @@ -173,9 +173,9 @@ chacha_encrypt2(uint8_t *src, uint8_t *dst, uint32_t bytes, Chachastate *s) dst += ChachaBsize; } if(bytes > 0){ - memmove(tmp, src, bytes); + jehanne_memmove(tmp, src, bytes); encryptblock(s, tmp, tmp); - memmove(dst, tmp, bytes); + jehanne_memmove(dst, tmp, bytes); } } diff --git a/sys/src/lib/sec/port/chachatest.c b/sys/src/lib/sec/port/chachatest.c index 99c1701..92f35a0 100644 --- a/sys/src/lib/sec/port/chachatest.c +++ b/sys/src/lib/sec/port/chachatest.c @@ -1,5 +1,5 @@ #include -#include +#include #include static void @@ -8,15 +8,15 @@ printblock(uint8_t *b, usize n) int i; for(i=0; i+8<=n; i+=8){ - print("%#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux\n", + jehanne_print("%#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux %#.2ux\n", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]); b += 8; } if(i < n){ - print("%#.2ux", *b++); + jehanne_print("%#.2ux", *b++); while(++i < n) - print(" %#.2ux", *b++); - print("\n"); + jehanne_print(" %#.2ux", *b++); + jehanne_print("\n"); } } @@ -86,91 +86,91 @@ main(int argc, char **argv) ARGBEGIN{ }ARGEND - print("rfc7539:\n"); - print("key:\n"); + jehanne_print("rfc7539:\n"); + jehanne_print("key:\n"); printblock(rfckey, sizeof(rfckey)); - n = strlen(rfctext); + n = jehanne_strlen(rfctext); setupChachastate(&s, rfckey, sizeof(rfckey), rfcnonce, sizeof(rfcnonce), 0); chacha_setblock(&s, rfccount); - print("rfc in:\n"); + jehanne_print("rfc in:\n"); printblock((uint8_t*)rfctext, n); chacha_encrypt2((uint8_t*)rfctext, rfcout, n, &s); - print("rfc out:\n"); + jehanne_print("rfc out:\n"); printblock(rfcout, n); - if(memcmp(rfcout, rfcref, sizeof(rfcref)) != 0){ - print("failure of vision\n"); - exits("wrong"); + if(jehanne_memcmp(rfcout, rfcref, sizeof(rfcref)) != 0){ + jehanne_print("failure of vision\n"); + jehanne_exits("wrong"); } - print("\n"); + jehanne_print("\n"); - print("ccpoly key:\n"); + jehanne_print("ccpoly key:\n"); printblock(ccpkey, sizeof(ccpkey)); - print("ccpoly iv:\n"); + jehanne_print("ccpoly iv:\n"); printblock(ccpiv, sizeof(ccpiv)); setupChachastate(&s, ccpkey, sizeof(ccpkey), ccpiv, sizeof(ccpiv), 20); - memmove(rfcout, rfctext, sizeof(rfctext)-1); + jehanne_memmove(rfcout, rfctext, sizeof(rfctext)-1); ccpoly_encrypt(rfcout, sizeof(rfctext)-1, ccpaad, sizeof(ccpaad), tag, &s); - print("ccpoly cipher:\n"); + jehanne_print("ccpoly cipher:\n"); printblock(rfcout, sizeof(rfctext)-1); - print("ccpoly tag:\n"); + jehanne_print("ccpoly tag:\n"); printblock(tag, sizeof(tag)); - if(memcmp(tag, ccptag, sizeof(tag)) != 0){ - print("bad ccpoly tag\n"); - exits("wrong"); + if(jehanne_memcmp(tag, ccptag, sizeof(tag)) != 0){ + jehanne_print("bad ccpoly tag\n"); + jehanne_exits("wrong"); } if(ccpoly_decrypt(rfcout, sizeof(rfctext)-1, ccpaad, sizeof(ccpaad), tag, &s) != 0){ - print("ccpoly decryption failed\n"); - exits("wrong"); + jehanne_print("ccpoly decryption failed\n"); + jehanne_exits("wrong"); } - if(memcmp(rfcout, rfctext, sizeof(rfctext)-1) != 0){ - print("ccpoly bad decryption\n"); - exits("wrong"); + if(jehanne_memcmp(rfcout, rfctext, sizeof(rfctext)-1) != 0){ + jehanne_print("ccpoly bad decryption\n"); + jehanne_exits("wrong"); } - print("\n"); + jehanne_print("\n"); - print("ccpoly64 key:\n"); + jehanne_print("ccpoly64 key:\n"); printblock(ccp64key, sizeof(ccp64key)); - print("ccpoly64 iv:\n"); + jehanne_print("ccpoly64 iv:\n"); printblock(ccp64iv, sizeof(ccp64iv)); setupChachastate(&s, ccp64key, sizeof(ccp64key), ccp64iv, sizeof(ccp64iv), 20); - memmove(rfcout, ccp64inp, sizeof(ccp64inp)); + jehanne_memmove(rfcout, ccp64inp, sizeof(ccp64inp)); ccpoly_encrypt(rfcout, sizeof(ccp64inp), ccp64aad, sizeof(ccp64aad), tag, &s); - print("ccpoly64 cipher:\n"); + jehanne_print("ccpoly64 cipher:\n"); printblock(rfcout, sizeof(ccp64inp)); - print("ccpoly64 tag:\n"); + jehanne_print("ccpoly64 tag:\n"); printblock(tag, sizeof(tag)); - if(memcmp(rfcout, ccp64out, sizeof(ccp64out)) != 0){ - print("ccpoly64 bad ciphertext\n"); - exits("wrong"); + if(jehanne_memcmp(rfcout, ccp64out, sizeof(ccp64out)) != 0){ + jehanne_print("ccpoly64 bad ciphertext\n"); + jehanne_exits("wrong"); } - if(memcmp(tag, ccp64tag, sizeof(ccp64tag)) != 0){ - print("ccpoly64 bad encryption tag\n"); - exits("wrong"); + if(jehanne_memcmp(tag, ccp64tag, sizeof(ccp64tag)) != 0){ + jehanne_print("ccpoly64 bad encryption tag\n"); + jehanne_exits("wrong"); } if(ccpoly_decrypt(rfcout, sizeof(ccp64inp), ccp64aad, sizeof(ccp64aad), tag, &s) != 0){ - print("ccpoly64 decryption failed\n"); - exits("wrong"); + jehanne_print("ccpoly64 decryption failed\n"); + jehanne_exits("wrong"); } - if(memcmp(rfcout, ccp64inp, sizeof(ccp64inp)) != 0){ - print("ccpoly64 bad decryption\n"); - exits("wrong"); + if(jehanne_memcmp(rfcout, ccp64inp, sizeof(ccp64inp)) != 0){ + jehanne_print("ccpoly64 bad decryption\n"); + jehanne_exits("wrong"); } - print("passed\n"); - exits(nil); + jehanne_print("passed\n"); + jehanne_exits(nil); } diff --git a/sys/src/lib/sec/port/crypt.c b/sys/src/lib/sec/port/crypt.c index 1aada9f..a0e30df 100644 --- a/sys/src/lib/sec/port/crypt.c +++ b/sys/src/lib/sec/port/crypt.c @@ -17,7 +17,7 @@ * for DES keys. */ #include -#include +#include #include #include diff --git a/sys/src/lib/sec/port/curve25519.c b/sys/src/lib/sec/port/curve25519.c index dd45fe9..beff208 100644 --- a/sys/src/lib/sec/port/curve25519.c +++ b/sys/src/lib/sec/port/curve25519.c @@ -230,7 +230,7 @@ fmul(felem *output, felem *in, felem *in2) { fproduct(t, in, in2); freduce_degree(t); freduce_coefficients(t); - memcpy(output, t, sizeof(felem) * 10); + jehanne_memcpy(output, t, sizeof(felem) * 10); } static void fsquare_inner(felem *output, felem *in) { @@ -298,7 +298,7 @@ fsquare(felem *output, felem *in) { fsquare_inner(t, in); freduce_degree(t); freduce_coefficients(t); - memcpy(output, t, sizeof(felem) * 10); + jehanne_memcpy(output, t, sizeof(felem) * 10); } /* Take a little-endian, 32-byte number and expand it into polynomial form */ @@ -394,11 +394,11 @@ static void fmonty(felem *x2, felem *z2, /* output 2Q */ felem origx[10], origxprime[10], zzz[19], xx[19], zz[19], xxprime[19], zzprime[19], zzzprime[19], xxxprime[19]; - memcpy(origx, x, 10 * sizeof(felem)); + jehanne_memcpy(origx, x, 10 * sizeof(felem)); fsum(x, z); fdifference(z, origx); // does x - z - memcpy(origxprime, xprime, sizeof(felem) * 10); + jehanne_memcpy(origxprime, xprime, sizeof(felem) * 10); fsum(xprime, zprime); fdifference(zprime, origxprime); fproduct(xxprime, xprime, z); @@ -407,7 +407,7 @@ static void fmonty(felem *x2, felem *z2, /* output 2Q */ freduce_coefficients(xxprime); freduce_degree(zzprime); freduce_coefficients(zzprime); - memcpy(origxprime, xxprime, sizeof(felem) * 10); + jehanne_memcpy(origxprime, xxprime, sizeof(felem) * 10); fsum(xxprime, zzprime); fdifference(zzprime, origxprime); fsquare(xxxprime, xxprime); @@ -415,8 +415,8 @@ static void fmonty(felem *x2, felem *z2, /* output 2Q */ fproduct(zzprime, zzzprime, qmqp); freduce_degree(zzprime); freduce_coefficients(zzprime); - memcpy(x3, xxxprime, sizeof(felem) * 10); - memcpy(z3, zzprime, sizeof(felem) * 10); + jehanne_memcpy(x3, xxxprime, sizeof(felem) * 10); + jehanne_memcpy(z3, zzprime, sizeof(felem) * 10); fsquare(xx, x); fsquare(zz, z); @@ -424,7 +424,7 @@ static void fmonty(felem *x2, felem *z2, /* output 2Q */ freduce_degree(x2); freduce_coefficients(x2); fdifference(zz, xx); // does zz = xx - zz - memset(zzz + 10, 0, sizeof(felem) * 9); + jehanne_memset(zzz + 10, 0, sizeof(felem) * 9); fscalar_product(zzz, zz, 121665); freduce_degree(zzz); freduce_coefficients(zzz); @@ -449,7 +449,7 @@ cmult(felem *resultx, felem *resultz, uint8_t *n, felem *q) { unsigned i, j; - memcpy(nqpqx, q, sizeof(felem) * 10); + jehanne_memcpy(nqpqx, q, sizeof(felem) * 10); for (i = 0; i < 32; ++i) { uint8_t byte = n[31 - i]; @@ -485,8 +485,8 @@ cmult(felem *resultx, felem *resultz, uint8_t *n, felem *q) { } } - memcpy(resultx, nqx, sizeof(felem) * 10); - memcpy(resultz, nqz, sizeof(felem) * 10); + jehanne_memcpy(resultx, nqx, sizeof(felem) * 10); + jehanne_memcpy(resultz, nqz, sizeof(felem) * 10); } // ----------------------------------------------------------------------------- diff --git a/sys/src/lib/sec/port/curve25519_dh.c b/sys/src/lib/sec/port/curve25519_dh.c index a450a4f..691d73c 100644 --- a/sys/src/lib/sec/port/curve25519_dh.c +++ b/sys/src/lib/sec/port/curve25519_dh.c @@ -29,6 +29,6 @@ curve25519_dh_finish(uint8_t x[32], uint8_t y[32], uint8_t z[32]) /* calculate dhx key */ curve25519(z, x, y); - memset(x, 0, 32); - memset(y, 0, 32); + jehanne_memset(x, 0, 32); + jehanne_memset(y, 0, 32); } diff --git a/sys/src/lib/sec/port/decodepem.c b/sys/src/lib/sec/port/decodepem.c index febc006..0e84d7c 100644 --- a/sys/src/lib/sec/port/decodepem.c +++ b/sys/src/lib/sec/port/decodepem.c @@ -16,44 +16,44 @@ decodePEM(char *s, char *type, int *len, char **new_s) * find the correct section of the file, stripping garbage at the beginning and end. * the data is delimited by -----BEGIN -----\n and -----END -----\n */ - n = strlen(type); - e = strchr(s, '\0'); + n = jehanne_strlen(type); + e = jehanne_strchr(s, '\0'); for(t = s; t != nil && t < e; ){ tt = t; - t = strchr(tt, '\n'); + t = jehanne_strchr(tt, '\n'); if(t != nil) t++; - if(strncmp(tt, "-----BEGIN ", STRLEN("-----BEGIN ")) == 0 - && strncmp(&tt[STRLEN("-----BEGIN ")], type, n) == 0 - && strncmp(&tt[STRLEN("-----BEGIN ")+n], "-----\n", STRLEN("-----\n")) == 0) + if(jehanne_strncmp(tt, "-----BEGIN ", STRLEN("-----BEGIN ")) == 0 + && jehanne_strncmp(&tt[STRLEN("-----BEGIN ")], type, n) == 0 + && jehanne_strncmp(&tt[STRLEN("-----BEGIN ")+n], "-----\n", STRLEN("-----\n")) == 0) break; } for(tt = t; tt != nil && tt < e; tt++){ - if(strncmp(tt, "-----END ", STRLEN("-----END ")) == 0 - && strncmp(&tt[STRLEN("-----END ")], type, n) == 0 - && strncmp(&tt[STRLEN("-----END ")+n], "-----\n", STRLEN("-----\n")) == 0) + if(jehanne_strncmp(tt, "-----END ", STRLEN("-----END ")) == 0 + && jehanne_strncmp(&tt[STRLEN("-----END ")], type, n) == 0 + && jehanne_strncmp(&tt[STRLEN("-----END ")+n], "-----\n", STRLEN("-----\n")) == 0) break; - tt = strchr(tt, '\n'); + tt = jehanne_strchr(tt, '\n'); if(tt == nil) break; } if(tt == nil || tt == e){ - werrstr("incorrect .pem file format: bad header or trailer"); + jehanne_werrstr("incorrect .pem file format: bad header or trailer"); return nil; } if(new_s) *new_s = tt+1; n = ((tt - t) * 6 + 7) / 8; - d = malloc(n); + d = jehanne_malloc(n); if(d == nil){ - werrstr("out of memory"); + jehanne_werrstr("out of memory"); return nil; } - n = dec64(d, n, t, tt - t); + n = jehanne_dec64(d, n, t, tt - t); if(n < 0){ - free(d); - werrstr("incorrect .pem file format: bad base64 encoded data"); + jehanne_free(d); + jehanne_werrstr("incorrect .pem file format: bad base64 encoded data"); return nil; } *len = n; @@ -68,12 +68,12 @@ decodepemchain(char *s, char *type) char *e; int n; - e = strchr(s, '\0'); + e = jehanne_strchr(s, '\0'); while (s < e) { d = decodePEM(s, type, &n, &s); if(d == nil) break; - chp = malloc(sizeof(PEMChain)); + chp = jehanne_malloc(sizeof(PEMChain)); chp->next = nil; chp->pem = d; chp->pemlen = n; diff --git a/sys/src/lib/sec/port/des3CBC.c b/sys/src/lib/sec/port/des3CBC.c index 2cd8902..cda8195 100644 --- a/sys/src/lib/sec/port/des3CBC.c +++ b/sys/src/lib/sec/port/des3CBC.c @@ -20,7 +20,7 @@ des3CBCencrypt(uint8_t *p, int len, DES3state *s) for(eip = ip+8; ip < eip; ) *p2++ ^= *ip++; triple_block_cipher(s->expanded, p, DES3EDE); - memmove(s->ivec, p, 8); + jehanne_memmove(s->ivec, p, 8); p += 8; } @@ -39,7 +39,7 @@ des3CBCdecrypt(uint8_t *p, int len, DES3state *s) uint8_t tmp[8]; for(; len >= 8; len -= 8){ - memmove(tmp, p, 8); + jehanne_memmove(tmp, p, 8); triple_block_cipher(s->expanded, p, DES3DED); tp = tmp; ip = s->ivec; diff --git a/sys/src/lib/sec/port/desCBC.c b/sys/src/lib/sec/port/desCBC.c index 08e1a2d..e151e32 100644 --- a/sys/src/lib/sec/port/desCBC.c +++ b/sys/src/lib/sec/port/desCBC.c @@ -20,7 +20,7 @@ desCBCencrypt(uint8_t *p, int len, DESstate *s) for(eip = ip+8; ip < eip; ) *p2++ ^= *ip++; block_cipher(s->expanded, p, 0); - memmove(s->ivec, p, 8); + jehanne_memmove(s->ivec, p, 8); p += 8; } @@ -39,7 +39,7 @@ desCBCdecrypt(uint8_t *p, int len, DESstate *s) uint8_t tmp[8]; for(; len >= 8; len -= 8){ - memmove(tmp, p, 8); + jehanne_memmove(tmp, p, 8); block_cipher(s->expanded, p, 1); tp = tmp; ip = s->ivec; diff --git a/sys/src/lib/sec/port/desmodes.c b/sys/src/lib/sec/port/desmodes.c index 944babc..9512af8 100644 --- a/sys/src/lib/sec/port/desmodes.c +++ b/sys/src/lib/sec/port/desmodes.c @@ -9,23 +9,23 @@ void setupDESstate(DESstate *s, uint8_t key[8], uint8_t *ivec) { - memset(s, 0, sizeof(*s)); - memmove(s->key, key, sizeof(s->key)); + jehanne_memset(s, 0, sizeof(*s)); + jehanne_memmove(s->key, key, sizeof(s->key)); des_key_setup(key, s->expanded); if(ivec) - memmove(s->ivec, ivec, 8); + jehanne_memmove(s->ivec, ivec, 8); s->setup = 0xdeadbeef; } void setupDES3state(DES3state *s, uint8_t key[3][8], uint8_t *ivec) { - memset(s, 0, sizeof(*s)); - memmove(s->key, key, sizeof(s->key)); + jehanne_memset(s, 0, sizeof(*s)); + jehanne_memmove(s->key, key, sizeof(s->key)); des_key_setup(key[0], s->expanded[0]); des_key_setup(key[1], s->expanded[1]); des_key_setup(key[2], s->expanded[2]); if(ivec) - memmove(s->ivec, ivec, 8); + jehanne_memmove(s->ivec, ivec, 8); s->setup = 0xdeadbeef; } diff --git a/sys/src/lib/sec/port/dh.c b/sys/src/lib/sec/port/dh.c index c43595e..12b1f5a 100644 --- a/sys/src/lib/sec/port/dh.c +++ b/sys/src/lib/sec/port/dh.c @@ -8,7 +8,7 @@ dh_new(DHstate *dh, mpint *p, mpint *q, mpint *g) mpint *pm1; int n; - memset(dh, 0, sizeof(*dh)); + jehanne_memset(dh, 0, sizeof(*dh)); if(mpcmp(g, mpone) <= 0) return nil; @@ -69,6 +69,6 @@ Out: mpfree(dh->g); mpfree(dh->x); mpfree(dh->y); - memset(dh, 0, sizeof(*dh)); + jehanne_memset(dh, 0, sizeof(*dh)); return k; } diff --git a/sys/src/lib/sec/port/dsaalloc.c b/sys/src/lib/sec/port/dsaalloc.c index d82ab3d..efad64c 100644 --- a/sys/src/lib/sec/port/dsaalloc.c +++ b/sys/src/lib/sec/port/dsaalloc.c @@ -7,9 +7,9 @@ dsapuballoc(void) { DSApub *dsa; - dsa = mallocz(sizeof(*dsa), 1); + dsa = jehanne_mallocz(sizeof(*dsa), 1); if(dsa == nil) - sysfatal("dsapuballoc"); + jehanne_sysfatal("dsapuballoc"); return dsa; } @@ -22,7 +22,7 @@ dsapubfree(DSApub *dsa) mpfree(dsa->q); mpfree(dsa->alpha); mpfree(dsa->key); - free(dsa); + jehanne_free(dsa); } @@ -31,9 +31,9 @@ dsaprivalloc(void) { DSApriv *dsa; - dsa = mallocz(sizeof(*dsa), 1); + dsa = jehanne_mallocz(sizeof(*dsa), 1); if(dsa == nil) - sysfatal("dsaprivalloc"); + jehanne_sysfatal("dsaprivalloc"); return dsa; } @@ -47,7 +47,7 @@ dsaprivfree(DSApriv *dsa) mpfree(dsa->pub.alpha); mpfree(dsa->pub.key); mpfree(dsa->secret); - free(dsa); + jehanne_free(dsa); } DSAsig* @@ -55,9 +55,9 @@ dsasigalloc(void) { DSAsig *dsa; - dsa = mallocz(sizeof(*dsa), 1); + dsa = jehanne_mallocz(sizeof(*dsa), 1); if(dsa == nil) - sysfatal("dsasigalloc"); + jehanne_sysfatal("dsasigalloc"); return dsa; } @@ -68,5 +68,5 @@ dsasigfree(DSAsig *dsa) return; mpfree(dsa->r); mpfree(dsa->s); - free(dsa); + jehanne_free(dsa); } diff --git a/sys/src/lib/sec/port/dsagen.c b/sys/src/lib/sec/port/dsagen.c index 46c369e..049e4e6 100644 --- a/sys/src/lib/sec/port/dsagen.c +++ b/sys/src/lib/sec/port/dsagen.c @@ -38,7 +38,7 @@ dsagen(DSApub *opub) mpsub(pub->p, mpone, exp); mpdiv(exp, pub->q, exp, r); if(mpcmp(r, mpzero) != 0) - sysfatal("dsagen foul up"); + jehanne_sysfatal("dsagen foul up"); while(1){ mprand(bits, genrandom, g); mpmod(g, pub->p, g); diff --git a/sys/src/lib/sec/port/dsaprimes.c b/sys/src/lib/sec/port/dsaprimes.c index 1bb136a..08cc901 100644 --- a/sys/src/lib/sec/port/dsaprimes.c +++ b/sys/src/lib/sec/port/dsaprimes.c @@ -48,7 +48,7 @@ DSAprimes(mpint *q, mpint *p, uint8_t seed[SHA1dlen]) forever: do{ Hrand(s); - memcpy(sj, s, 20); + jehanne_memcpy(sj, s, 20); sha1(s, 20, Hs, 0); Hincr(sj); sha1(sj, 20, Hs1, 0); @@ -59,13 +59,13 @@ forever: letomp(Hs, 20, q); }while(!probably_prime(q, 18)); if(seed != nil) // allow skeptics to confirm computation - memmove(seed, s, SHA1dlen); + jehanne_memmove(seed, s, SHA1dlen); i = 0; j = 2; Hincr(sj); mpleft(q, 1, q2); while(i<4096){ - memcpy(sjk, sj, 20); + jehanne_memcpy(sjk, sj, 20); for(k=0; k <= n; k++){ sha1(sjk, 20, Hs, 0); letomp(Hs, 20, Vk); diff --git a/sys/src/lib/sec/port/dsasign.c b/sys/src/lib/sec/port/dsasign.c index 137134b..1734685 100644 --- a/sys/src/lib/sec/port/dsasign.c +++ b/sys/src/lib/sec/port/dsasign.c @@ -25,7 +25,7 @@ dsasign(DSApriv *priv, mpint *m) continue; mpextendedgcd(k, q, r, kinv, s); if(mpcmp(r, mpone) != 0) - sysfatal("dsasign: pub->q not prime"); + jehanne_sysfatal("dsasign: pub->q not prime"); break; } diff --git a/sys/src/lib/sec/port/ecc.c b/sys/src/lib/sec/port/ecc.c index cd4249e..ccb417b 100644 --- a/sys/src/lib/sec/port/ecc.c +++ b/sys/src/lib/sec/port/ecc.c @@ -189,14 +189,14 @@ halfpt(ECdomain *dom, char *s, char **rptr, mpint *out) mpint *ret; n = ((mpsignif(dom->p)+7)/8)*2; - if(strlen(s) < n) + if(jehanne_strlen(s) < n) return 0; - buf = malloc(n+1); + buf = jehanne_malloc(n+1); buf[n] = 0; - memcpy(buf, s, n); + jehanne_memcpy(buf, s, n); ret = strtomp(buf, &r, 16, out); *rptr = s + (r - buf); - free(buf); + jehanne_free(buf); return ret; } @@ -324,7 +324,7 @@ strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *ret) allocd = 0; if(ret == nil){ allocd = 1; - ret = mallocz(sizeof(*ret), 1); + ret = jehanne_mallocz(sizeof(*ret), 1); if(ret == nil) return nil; ret->x = mpnew(0); @@ -376,7 +376,7 @@ err: if(allocd){ mpfree(ret->x); mpfree(ret->y); - free(ret); + jehanne_free(ret); } return nil; } @@ -385,7 +385,7 @@ ECpriv* ecgen(ECdomain *dom, ECpriv *p) { if(p == nil){ - p = mallocz(sizeof(*p), 1); + p = jehanne_mallocz(sizeof(*p), 1); if(p == nil) return nil; p->x = mpnew(0); @@ -516,12 +516,12 @@ base58dec(char *src, uint8_t *dst, int len) r = mpnew(0); b = uitomp(58, nil); for(; *src; src++){ - t = strchr(code, *src); + t = jehanne_strchr(code, *src); if(t == nil){ mpfree(n); mpfree(r); mpfree(b); - werrstr("invalid base58 char"); + jehanne_werrstr("invalid base58 char"); return -1; } uitomp(t - code, r); @@ -538,7 +538,7 @@ base58dec(char *src, uint8_t *dst, int len) void ecdominit(ECdomain *dom, void (*init)(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h)) { - memset(dom, 0, sizeof(*dom)); + jehanne_memset(dom, 0, sizeof(*dom)); dom->p = mpnew(0); dom->a = mpnew(0); dom->b = mpnew(0); @@ -562,7 +562,7 @@ ecdomfree(ECdomain *dom) mpfree(dom->G.y); mpfree(dom->n); mpfree(dom->h); - memset(dom, 0, sizeof(*dom)); + jehanne_memset(dom, 0, sizeof(*dom)); } int @@ -589,7 +589,7 @@ ecdecodepub(ECdomain *dom, uint8_t *data, int len) n = (mpsignif(dom->p)+7)/8; if(len != 1 + 2*n || data[0] != 0x04) return nil; - pub = mallocz(sizeof(*pub), 1); + pub = jehanne_mallocz(sizeof(*pub), 1); if(pub == nil) return nil; pub->x = betomp(data+1, n, nil); @@ -608,5 +608,5 @@ ecpubfree(ECpub *p) return; mpfree(p->x); mpfree(p->y); - free(p); + jehanne_free(p); } diff --git a/sys/src/lib/sec/port/egalloc.c b/sys/src/lib/sec/port/egalloc.c index 3f0753d..288479c 100644 --- a/sys/src/lib/sec/port/egalloc.c +++ b/sys/src/lib/sec/port/egalloc.c @@ -7,9 +7,9 @@ egpuballoc(void) { EGpub *eg; - eg = mallocz(sizeof(*eg), 1); + eg = jehanne_mallocz(sizeof(*eg), 1); if(eg == nil) - sysfatal("egpuballoc"); + jehanne_sysfatal("egpuballoc"); return eg; } @@ -21,7 +21,7 @@ egpubfree(EGpub *eg) mpfree(eg->p); mpfree(eg->alpha); mpfree(eg->key); - free(eg); + jehanne_free(eg); } @@ -30,9 +30,9 @@ egprivalloc(void) { EGpriv *eg; - eg = mallocz(sizeof(*eg), 1); + eg = jehanne_mallocz(sizeof(*eg), 1); if(eg == nil) - sysfatal("egprivalloc"); + jehanne_sysfatal("egprivalloc"); return eg; } @@ -45,7 +45,7 @@ egprivfree(EGpriv *eg) mpfree(eg->pub.alpha); mpfree(eg->pub.key); mpfree(eg->secret); - free(eg); + jehanne_free(eg); } EGsig* @@ -53,9 +53,9 @@ egsigalloc(void) { EGsig *eg; - eg = mallocz(sizeof(*eg), 1); + eg = jehanne_mallocz(sizeof(*eg), 1); if(eg == nil) - sysfatal("egsigalloc"); + jehanne_sysfatal("egsigalloc"); return eg; } @@ -66,5 +66,5 @@ egsigfree(EGsig *eg) return; mpfree(eg->r); mpfree(eg->s); - free(eg); + jehanne_free(eg); } diff --git a/sys/src/lib/sec/port/egtest.c b/sys/src/lib/sec/port/egtest.c index 7c17c26..9e29009 100644 --- a/sys/src/lib/sec/port/egtest.c +++ b/sys/src/lib/sec/port/egtest.c @@ -9,7 +9,7 @@ main(void) mpint *m, *gamma, *delta, *in, *out; int plen, shift; - fmtinstall('B', mpfmt); + jehanne_fmtinstall('B', mpfmt); sk = egprivalloc(); sk->pub.p = uitomp(2357, nil); @@ -30,5 +30,5 @@ main(void) egdecrypt(sk, in, out); if(mpcmp(m, out) != 0) - print("decrypt failed to recover message\n"); + jehanne_print("decrypt failed to recover message\n"); } diff --git a/sys/src/lib/sec/port/fastrand.c b/sys/src/lib/sec/port/fastrand.c index 6ff2461..edf6c1a 100644 --- a/sys/src/lib/sec/port/fastrand.c +++ b/sys/src/lib/sec/port/fastrand.c @@ -3,7 +3,7 @@ /* * use the X917 random number generator to create random - * numbers (faster than truerand() but not as random). + * numbers (faster than jehanne_truerand() but not as random). */ uint32_t fastrand(void) diff --git a/sys/src/lib/sec/port/genrandom.c b/sys/src/lib/sec/port/genrandom.c index 5b9e84a..c21b530 100644 --- a/sys/src/lib/sec/port/genrandom.c +++ b/sys/src/lib/sec/port/genrandom.c @@ -16,7 +16,7 @@ X917(uint8_t *rand, int nrand) uint64_t I, x; /* 1. Compute intermediate value I = Ek(time). */ - I = nsec(); + I = jehanne_nsec(); triple_block_cipher(x917state.des3.expanded, (uint8_t*)&I, 0); /* two-key EDE */ /* 2. x[i] = Ek(I^seed); seed = Ek(x[i]^I); */ @@ -25,7 +25,7 @@ X917(uint8_t *rand, int nrand) x = I ^ x917state.seed; triple_block_cipher(x917state.des3.expanded, (uint8_t*)&x, 0); n8 = (nrand>8) ? 8 : nrand; - memcpy(rand, (uint8_t*)&x, n8); + jehanne_memcpy(rand, (uint8_t*)&x, n8); rand += 8; nrand -= 8; x ^= I; @@ -44,7 +44,7 @@ X917init(void) ulp = (uint32_t*)key3; for(n = 0; n < sizeof(key3)/sizeof(uint32_t); n++) - ulp[n] = truerand(); + ulp[n] = jehanne_truerand(); setupDES3state(&x917state.des3, key3, nil); X917(mix, sizeof mix); x917state.seeded = 1; @@ -53,9 +53,9 @@ X917init(void) void genrandom(uint8_t *p, int n) { - qlock(&x917state.lock); + jehanne_qlock(&x917state.lock); if(x917state.seeded == 0) X917init(); X917(p, n); - qunlock(&x917state.lock); + jehanne_qunlock(&x917state.lock); } diff --git a/sys/src/lib/sec/port/hkdf.c b/sys/src/lib/sec/port/hkdf.c index 07d7615..9b0dc38 100644 --- a/sys/src/lib/sec/port/hkdf.c +++ b/sys/src/lib/sec/port/hkdf.c @@ -14,7 +14,7 @@ hkdf_x(salt, nsalt, info, ninfo, key, nkey, d, dlen, x, xlen) assert(xlen <= sizeof(tmp)); - memset(tmp, 0, xlen); + jehanne_memset(tmp, 0, xlen); if(nsalt == 0){ salt = tmp; nsalt = xlen; @@ -27,10 +27,10 @@ hkdf_x(salt, nsalt, info, ninfo, key, nkey, d, dlen, x, xlen) ds = (*x)(info, ninfo, prk, xlen, nil, ds); (*x)(&cnt, 1, prk, xlen, tmp, ds); if(dlen <= xlen){ - memmove(d, tmp, dlen); + jehanne_memmove(d, tmp, dlen); break; } - memmove(d, tmp, xlen); + jehanne_memmove(d, tmp, xlen); dlen -= xlen; d += xlen; ds = (*x)(tmp, xlen, prk, xlen, nil, nil); diff --git a/sys/src/lib/sec/port/hmac.c b/sys/src/lib/sec/port/hmac.c index 238b346..9679b77 100644 --- a/sys/src/lib/sec/port/hmac.c +++ b/sys/src/lib/sec/port/hmac.c @@ -21,7 +21,7 @@ hmac_x(uint8_t *p, uint32_t len, uint8_t *key, uint32_t klen, uint8_t *digest, D /* first time through */ if(s == nil || s->seeded == 0){ - memset(pad, 0x36, Hmacblksz); + jehanne_memset(pad, 0x36, Hmacblksz); pad[Hmacblksz] = 0; for(i = 0; i < klen; i++) pad[i] ^= key[i]; @@ -35,7 +35,7 @@ hmac_x(uint8_t *p, uint32_t len, uint8_t *key, uint32_t klen, uint8_t *digest, D return s; /* last time through */ - memset(pad, 0x5c, Hmacblksz); + jehanne_memset(pad, 0x5c, Hmacblksz); pad[Hmacblksz] = 0; for(i = 0; i < klen; i++) pad[i] ^= key[i]; diff --git a/sys/src/lib/sec/port/hmactest.c b/sys/src/lib/sec/port/hmactest.c index 735bdb7..95e91cc 100644 --- a/sys/src/lib/sec/port/hmactest.c +++ b/sys/src/lib/sec/port/hmactest.c @@ -11,9 +11,9 @@ main(void) int i; uint8_t hash[MD5dlen]; - hmac_md5(data, strlen((char*)data), key, 4, hash, nil); + hmac_md5(data, jehanne_strlen((char*)data), key, 4, hash, nil); for(i=0; imalloced = 1; } @@ -174,7 +174,7 @@ md4(uint8_t *p, uint32_t len, uint8_t *digest, MD4state *s) i = 64 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -195,7 +195,7 @@ md4(uint8_t *p, uint32_t len, uint8_t *digest, MD4state *s) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -209,7 +209,7 @@ md4(uint8_t *p, uint32_t len, uint8_t *digest, MD4state *s) p = s->buf; len = s->blen; } else { - memmove(buf, p, len); + jehanne_memmove(buf, p, len); p = buf; } s->len += len; @@ -218,7 +218,7 @@ md4(uint8_t *p, uint32_t len, uint8_t *digest, MD4state *s) i = 56 - len; else i = 120 - len; - memset(e, 0, i); + jehanne_memset(e, 0, i); *e = 0x80; len += i; @@ -233,7 +233,7 @@ md4(uint8_t *p, uint32_t len, uint8_t *digest, MD4state *s) /* return result and free state */ encode(digest, s->state, MD4dlen); if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/md4test.c b/sys/src/lib/sec/port/md4test.c index c37f6d0..dd16b63 100644 --- a/sys/src/lib/sec/port/md4test.c +++ b/sys/src/lib/sec/port/md4test.c @@ -23,9 +23,9 @@ main(void) for(pp = tests; *pp; pp++){ p = (uint8_t*)*pp; - md4(p, strlen(*pp), digest, 0); + md4(p, jehanne_strlen(*pp), digest, 0); for(i = 0; i < MD5dlen; i++) - print("%2.2ux", digest[i]); - print("\n"); + jehanne_print("%2.2ux", digest[i]); + jehanne_print("\n"); } } diff --git a/sys/src/lib/sec/port/md5.c b/sys/src/lib/sec/port/md5.c index a8c10e1..b761a27 100644 --- a/sys/src/lib/sec/port/md5.c +++ b/sys/src/lib/sec/port/md5.c @@ -40,10 +40,10 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) uint8_t *e; if(s == nil){ - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); s->malloced = 1; } @@ -61,7 +61,7 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) i = 64 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -84,7 +84,7 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -98,7 +98,7 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) p = s->buf; len = s->blen; } else { - memmove(buf, p, len); + jehanne_memmove(buf, p, len); p = buf; } s->len += len; @@ -107,7 +107,7 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) i = 56 - len; else i = 120 - len; - memset(e, 0, i); + jehanne_memset(e, 0, i); *e = 0x80; len += i; @@ -123,7 +123,7 @@ md5(uint8_t *p, uint32_t len, uint8_t *digest, MD5state *s) /* return result and free state */ encode(digest, s->state, MD5dlen); if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/md5pickle.c b/sys/src/lib/sec/port/md5pickle.c index a3adb51..8b1006e 100644 --- a/sys/src/lib/sec/port/md5pickle.c +++ b/sys/src/lib/sec/port/md5pickle.c @@ -8,14 +8,14 @@ md5pickle(MD5state *s) int m, n; m = 17+4*9+4*((s->blen+3)/3 + 1); - p = malloc(m); + p = jehanne_malloc(m); if(p == nil) return p; - n = sprint(p, "%16.16llux %8.8ux %8.8ux %8.8ux %8.8ux ", + n = jehanne_sprint(p, "%16.16llux %8.8ux %8.8ux %8.8ux %8.8ux ", s->len, s->state[0], s->state[1], s->state[2], s->state[3]); - enc64(p+n, m-n, s->buf, s->blen); + jehanne_enc64(p+n, m-n, s->buf, s->blen); return p; } @@ -24,15 +24,15 @@ md5unpickle(char *p) { MD5state *s; - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - s->len = strtoull(p, &p, 16); - s->state[0] = strtoul(p, &p, 16); - s->state[1] = strtoul(p, &p, 16); - s->state[2] = strtoul(p, &p, 16); - s->state[3] = strtoul(p, &p, 16); - s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p)); + s->len = jehanne_strtoull(p, &p, 16); + s->state[0] = jehanne_strtoul(p, &p, 16); + s->state[1] = jehanne_strtoul(p, &p, 16); + s->state[2] = jehanne_strtoul(p, &p, 16); + s->state[3] = jehanne_strtoul(p, &p, 16); + s->blen = jehanne_dec64(s->buf, sizeof(s->buf), p, jehanne_strlen(p)); s->malloced = 1; s->seeded = 1; return s; diff --git a/sys/src/lib/sec/port/nfastrand.c b/sys/src/lib/sec/port/nfastrand.c index feecda7..c926ebb 100644 --- a/sys/src/lib/sec/port/nfastrand.c +++ b/sys/src/lib/sec/port/nfastrand.c @@ -13,7 +13,7 @@ nfastrand(uint32_t n) * so we want a random number < m. */ if(n > Maxrand) - sysfatal("nfastrand: n too large"); + jehanne_sysfatal("nfastrand: n too large"); m = Maxrand - Maxrand % n; while((r = fastrand()) >= m) diff --git a/sys/src/lib/sec/port/pbkdf2.c b/sys/src/lib/sec/port/pbkdf2.c index b096783..57fdcf5 100644 --- a/sys/src/lib/sec/port/pbkdf2.c +++ b/sys/src/lib/sec/port/pbkdf2.c @@ -22,13 +22,13 @@ pbkdf2_x(p, plen, s, slen, rounds, d, dlen, x, xlen) tmp[0] = i >> 24; ds = (*x)(s, slen, p, plen, nil, nil); (*x)(tmp, 4, p, plen, block, ds); - memmove(tmp, block, xlen); + jehanne_memmove(tmp, block, xlen); for(j = 1; j < rounds; j++){ (*x)(tmp, xlen, p, plen, tmp, nil); for(k=0; k xlen ? xlen : dlen; - memmove(d, block, n); + jehanne_memmove(d, block, n); } } diff --git a/sys/src/lib/sec/port/poly1305.c b/sys/src/lib/sec/port/poly1305.c index cfcc98f..6eb25b6 100644 --- a/sys/src/lib/sec/port/poly1305.c +++ b/sys/src/lib/sec/port/poly1305.c @@ -19,10 +19,10 @@ poly1305(uint8_t *m, uint32_t len, uint8_t *key, uint32_t klen, uint8_t *digest, uint32_t hibit, mask, c; if(s == nil){ - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); s->malloced = 1; } @@ -56,7 +56,7 @@ poly1305(uint8_t *m, uint32_t len, uint8_t *key, uint32_t klen, uint8_t *digest, c = 16 - s->blen; if(c > len) c = len; - memmove(s->buf + s->blen, m, c); + jehanne_memmove(s->buf + s->blen, m, c); len -= c, m += c; s->blen += c; if(s->blen == 16){ @@ -118,7 +118,7 @@ Block: if(len){ s->blen = len; - memmove(s->buf, m, len); + jehanne_memmove(s->buf, m, len); } if(digest == nil){ @@ -185,11 +185,11 @@ Block: U32TO8(&digest[12], h3); if(s->malloced){ - memset(s, 0, sizeof(*s)); - free(s); + jehanne_memset(s, 0, sizeof(*s)); + jehanne_free(s); return nil; } - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); return nil; } diff --git a/sys/src/lib/sec/port/primetest.c b/sys/src/lib/sec/port/primetest.c index cc649c3..79739fc 100644 --- a/sys/src/lib/sec/port/primetest.c +++ b/sys/src/lib/sec/port/primetest.c @@ -10,23 +10,23 @@ main(void) mpint *q = mpnew(0); mpint *nine = mpnew(0); - fmtinstall('B', mpfmt); + jehanne_fmtinstall('B', mpfmt); strtomp("2492491", nil, 16, z); // 38347921 = x*y = (2**28-9)/7, // an example of 3**(n-1)=1 mod n strtomp("15662C00E811", nil, 16, p);// 23528569104401, a prime uitomp(9, nine); if(probably_prime(z, 5) == 1) - fprint(2, "tricked primality test\n"); + jehanne_fprint(2, "tricked primality test\n"); if(probably_prime(nine, 5) == 1) - fprint(2, "9 passed primality test!\n"); + jehanne_fprint(2, "9 passed primality test!\n"); if(probably_prime(p, 25) == 1) - fprint(2, "ok\n"); + jehanne_fprint(2, "ok\n"); DSAprimes(q, p, nil); - print("q=%B\np=%B\n", q, p); + jehanne_print("q=%B\np=%B\n", q, p); - exits(0); + jehanne_exits(0); } // example output, checked with Maple: diff --git a/sys/src/lib/sec/port/prng.c b/sys/src/lib/sec/port/prng.c index 6021eba..942b68f 100644 --- a/sys/src/lib/sec/port/prng.c +++ b/sys/src/lib/sec/port/prng.c @@ -10,5 +10,5 @@ prng(uint8_t *p, int n) uint8_t *e; for(e = p+n; p < e; p++) - *p = rand(); + *p = jehanne_rand(); } diff --git a/sys/src/lib/sec/port/probably_prime.c b/sys/src/lib/sec/port/probably_prime.c index b3f88dc..0b85b2b 100644 --- a/sys/src/lib/sec/port/probably_prime.c +++ b/sys/src/lib/sec/port/probably_prime.c @@ -15,7 +15,7 @@ probably_prime(mpint *n, int nrep) mpint *nm1, *q, *x, *y, *r; if(n->sign < 0) - sysfatal("negative prime candidate"); + jehanne_sysfatal("negative prime candidate"); if(nrep <= 0) nrep = 18; diff --git a/sys/src/lib/sec/port/readcert.c b/sys/src/lib/sec/port/readcert.c index 37ba91c..0324478 100644 --- a/sys/src/lib/sec/port/readcert.c +++ b/sys/src/lib/sec/port/readcert.c @@ -11,20 +11,20 @@ readfile(char *name) fd = open(name, OREAD); if(fd < 0) return nil; - if((d = dirfstat(fd)) == nil) { + if((d = jehanne_dirfstat(fd)) == nil) { close(fd); return nil; } - s = malloc(d->length + 1); - if(s == nil || readn(fd, s, d->length) != d->length){ - free(s); - free(d); + s = jehanne_malloc(d->length + 1); + if(s == nil || jehanne_readn(fd, s, d->length) != d->length){ + jehanne_free(s); + jehanne_free(d); close(fd); return nil; } close(fd); s[d->length] = '\0'; - free(d); + jehanne_free(d); return s; } @@ -36,13 +36,13 @@ readcert(char *filename, int *pcertlen) pem = readfile(filename); if(pem == nil){ - werrstr("can't read %s: %r", filename); + jehanne_werrstr("can't read %s: %r", filename); return nil; } binary = decodePEM(pem, "CERTIFICATE", pcertlen, nil); - free(pem); + jehanne_free(pem); if(binary == nil){ - werrstr("can't parse %s", filename); + jehanne_werrstr("can't parse %s", filename); return nil; } return binary; @@ -55,7 +55,7 @@ readcertchain(char *filename) chfile = readfile(filename); if (chfile == nil) { - werrstr("can't read %s: %r", filename); + jehanne_werrstr("can't read %s: %r", filename); return nil; } return decodepemchain(chfile, "CERTIFICATE"); diff --git a/sys/src/lib/sec/port/ripemd.c b/sys/src/lib/sec/port/ripemd.c index 4835202..d558a53 100644 --- a/sys/src/lib/sec/port/ripemd.c +++ b/sys/src/lib/sec/port/ripemd.c @@ -284,7 +284,7 @@ static void MDfinish(uint32_t *MDbuf, uint8_t *strptr, uint32_t lswlen, uint32_t unsigned int i; /* counter */ uint32_t X[16]; /* message words */ - memset(X, 0, 16*sizeof(uint32_t)); + jehanne_memset(X, 0, 16*sizeof(uint32_t)); /* put bytes from strptr into X */ for (i=0; i<(lswlen&63); i++) { @@ -298,7 +298,7 @@ static void MDfinish(uint32_t *MDbuf, uint8_t *strptr, uint32_t lswlen, uint32_t if ((lswlen & 63) > 55) { /* length goes to next block */ compress(MDbuf, X); - memset(X, 0, 16*sizeof(uint32_t)); + jehanne_memset(X, 0, 16*sizeof(uint32_t)); } /* append length in bits*/ @@ -316,10 +316,10 @@ ripemd160(uint8_t *p, uint32_t len, uint8_t *digest, DigestState *s) int i, j, k; if(s == nil){ - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); s->malloced = 1; } @@ -333,7 +333,7 @@ ripemd160(uint8_t *p, uint32_t len, uint8_t *digest, DigestState *s) i = 64 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -362,7 +362,7 @@ ripemd160(uint8_t *p, uint32_t len, uint8_t *digest, DigestState *s) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -377,7 +377,7 @@ ripemd160(uint8_t *p, uint32_t len, uint8_t *digest, DigestState *s) } if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/rsaalloc.c b/sys/src/lib/sec/port/rsaalloc.c index 0caa96d..7bb15aa 100644 --- a/sys/src/lib/sec/port/rsaalloc.c +++ b/sys/src/lib/sec/port/rsaalloc.c @@ -7,9 +7,9 @@ rsapuballoc(void) { RSApub *rsa; - rsa = mallocz(sizeof(*rsa), 1); + rsa = jehanne_mallocz(sizeof(*rsa), 1); if(rsa == nil) - sysfatal("rsapuballoc"); + jehanne_sysfatal("rsapuballoc"); return rsa; } @@ -20,7 +20,7 @@ rsapubfree(RSApub *rsa) return; mpfree(rsa->ek); mpfree(rsa->n); - free(rsa); + jehanne_free(rsa); } @@ -29,9 +29,9 @@ rsaprivalloc(void) { RSApriv *rsa; - rsa = mallocz(sizeof(*rsa), 1); + rsa = jehanne_mallocz(sizeof(*rsa), 1); if(rsa == nil) - sysfatal("rsaprivalloc"); + jehanne_sysfatal("rsaprivalloc"); return rsa; } @@ -48,5 +48,5 @@ rsaprivfree(RSApriv *rsa) mpfree(rsa->kp); mpfree(rsa->kq); mpfree(rsa->c2); - free(rsa); + jehanne_free(rsa); } diff --git a/sys/src/lib/sec/port/rsafill.c b/sys/src/lib/sec/port/rsafill.c index f514b07..6c2f7e2 100644 --- a/sys/src/lib/sec/port/rsafill.c +++ b/sys/src/lib/sec/port/rsafill.c @@ -10,13 +10,13 @@ rsafill(mpint *n, mpint *e, mpint *d, mpint *p, mpint *q) // make sure we're not being hoodwinked if(!probably_prime(p, 10) || !probably_prime(q, 10)){ - werrstr("rsafill: p or q not prime"); + jehanne_werrstr("rsafill: p or q not prime"); return nil; } x = mpnew(0); mpmul(p, q, x); if(mpcmp(n, x) != 0){ - werrstr("rsafill: n != p*q"); + jehanne_werrstr("rsafill: n != p*q"); mpfree(x); return nil; } @@ -27,7 +27,7 @@ rsafill(mpint *n, mpint *e, mpint *d, mpint *p, mpint *q) mpmul(e, d, c2); mpmod(c2, x, x); if(mpcmp(x, mpone) != 0){ - werrstr("rsafill: e*d != 1 mod (p-1)*(q-1)"); + jehanne_werrstr("rsafill: e*d != 1 mod (p-1)*(q-1)"); mpfree(x); mpfree(c2); return nil; diff --git a/sys/src/lib/sec/port/rsatest.c b/sys/src/lib/sec/port/rsatest.c index ab646cf..eecaf4a 100644 --- a/sys/src/lib/sec/port/rsatest.c +++ b/sys/src/lib/sec/port/rsatest.c @@ -14,11 +14,11 @@ main(void) RSApriv *rsa; mpint *clr, *enc, *clr2; - fmtinstall('B', mpfmt); + jehanne_fmtinstall('B', mpfmt); rsa = rsagen(1024, 16, 0); if(rsa == nil) - sysfatal("rsagen"); + jehanne_sysfatal("rsagen"); Binit(&b, 0, OREAD); clr = mpnew(0); clr2 = mpnew(0); @@ -27,30 +27,30 @@ main(void) strtomp("123456789abcdef123456789abcdef123456789abcdef123456789abcdef", nil, 16, clr); rsaencrypt(&rsa->pub, clr, enc); - start = nsec(); + start = jehanne_nsec(); for(n = 0; n < 10; n++) rsadecrypt(rsa, enc, clr); - print("%lld\n", nsec()-start); + jehanne_print("%lld\n", jehanne_nsec()-start); - start = nsec(); + start = jehanne_nsec(); for(n = 0; n < 10; n++) mpexp(enc, rsa->dk, rsa->pub.n, clr2); - print("%lld\n", nsec()-start); + jehanne_print("%lld\n", jehanne_nsec()-start); if(mpcmp(clr, clr2) != 0) - print("%B != %B\n", clr, clr2); + jehanne_print("%B != %B\n", clr, clr2); - print("> "); + jehanne_print("> "); while(p = Brdline(&b, '\n')){ n = Blinelen(&b); letomp((uint8_t*)p, n, clr); - print("clr %B\n", clr); + jehanne_print("clr %B\n", clr); rsaencrypt(&rsa->pub, clr, enc); - print("enc %B\n", enc); + jehanne_print("enc %B\n", enc); rsadecrypt(rsa, enc, clr); - print("clr %B\n", clr); + jehanne_print("clr %B\n", clr); n = mptole(clr, buf, sizeof(buf), nil); write(1, buf, n); - print("> "); + jehanne_print("> "); } } diff --git a/sys/src/lib/sec/port/salsa.c b/sys/src/lib/sec/port/salsa.c index a92d336..adc98e9 100644 --- a/sys/src/lib/sec/port/salsa.c +++ b/sys/src/lib/sec/port/salsa.c @@ -37,9 +37,9 @@ void setupSalsastate(Salsastate *s, uint8_t *key, uint32_t keylen, uint8_t *iv, uint32_t ivlen, int rounds) { if(keylen != 256/8 && keylen != 128/8) - sysfatal("invalid salsa key length"); + jehanne_sysfatal("invalid salsa key length"); if(ivlen != 64/8 && ivlen != 128/8 && ivlen != 192/8) - sysfatal("invalid salsa iv length"); + jehanne_sysfatal("invalid salsa iv length"); if(rounds == 0) rounds = 20; s->rounds = rounds; @@ -176,7 +176,7 @@ salsa_setiv(Salsastate *s, uint8_t *iv) hsalsablock(h, s); load(&s->input[1], h+16*0, 4); load(&s->input[11], h+16*1, 4); - memset(h, 0, 32); + jehanne_memset(h, 0, 32); s->input[8] = counter[0]; s->input[9] = counter[1]; @@ -296,9 +296,9 @@ salsa_encrypt2(uint8_t *src, uint8_t *dst, uint32_t bytes, Salsastate *s) dst += SalsaBsize; } if(bytes > 0){ - memmove(tmp, src, bytes); + jehanne_memmove(tmp, src, bytes); encryptblock(s, tmp, tmp); - memmove(dst, tmp, bytes); + jehanne_memmove(dst, tmp, bytes); } } @@ -315,5 +315,5 @@ hsalsa(uint8_t h[32], uint8_t *key, uint32_t keylen, uint8_t nonce[16], int roun setupSalsastate(s, key, keylen, nonce, 16, rounds); hsalsablock(h, s); - memset(s, 0, sizeof(s)); + jehanne_memset(s, 0, sizeof(s)); } diff --git a/sys/src/lib/sec/port/sha1.c b/sys/src/lib/sec/port/sha1.c index 9fbd550..252e3a5 100644 --- a/sys/src/lib/sec/port/sha1.c +++ b/sys/src/lib/sec/port/sha1.c @@ -19,10 +19,10 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) uint8_t *e; if(s == nil){ - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - memset(s, 0, sizeof(*s)); + jehanne_memset(s, 0, sizeof(*s)); s->malloced = 1; } @@ -41,7 +41,7 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) i = 64 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -64,7 +64,7 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -78,7 +78,7 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) p = s->buf; len = s->blen; } else { - memmove(buf, p, len); + jehanne_memmove(buf, p, len); p = buf; } s->len += len; @@ -87,7 +87,7 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) i = 56 - len; else i = 120 - len; - memset(e, 0, i); + jehanne_memset(e, 0, i); *e = 0x80; len += i; @@ -103,7 +103,7 @@ sha1(uint8_t *p, uint32_t len, uint8_t *digest, SHA1state *s) /* return result and free state */ encode(digest, s->state, SHA1dlen); if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/sha1pickle.c b/sys/src/lib/sec/port/sha1pickle.c index 6139567..71de9e3 100644 --- a/sys/src/lib/sec/port/sha1pickle.c +++ b/sys/src/lib/sec/port/sha1pickle.c @@ -8,13 +8,13 @@ sha1pickle(SHA1state *s) int m, n; m = 5*9+4*((s->blen+3)/3); - p = malloc(m); + p = jehanne_malloc(m); if(p == nil) return p; - n = sprint(p, "%8.8ux %8.8ux %8.8ux %8.8ux %8.8ux ", + n = jehanne_sprint(p, "%8.8ux %8.8ux %8.8ux %8.8ux %8.8ux ", s->state[0], s->state[1], s->state[2], s->state[3], s->state[4]); - enc64(p+n, m-n, s->buf, s->blen); + jehanne_enc64(p+n, m-n, s->buf, s->blen); return p; } @@ -23,15 +23,15 @@ sha1unpickle(char *p) { SHA1state *s; - s = malloc(sizeof(*s)); + s = jehanne_malloc(sizeof(*s)); if(s == nil) return nil; - s->state[0] = strtoul(p, &p, 16); - s->state[1] = strtoul(p, &p, 16); - s->state[2] = strtoul(p, &p, 16); - s->state[3] = strtoul(p, &p, 16); - s->state[4] = strtoul(p, &p, 16); - s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p)); + s->state[0] = jehanne_strtoul(p, &p, 16); + s->state[1] = jehanne_strtoul(p, &p, 16); + s->state[2] = jehanne_strtoul(p, &p, 16); + s->state[3] = jehanne_strtoul(p, &p, 16); + s->state[4] = jehanne_strtoul(p, &p, 16); + s->blen = jehanne_dec64(s->buf, sizeof(s->buf), p, jehanne_strlen(p)); s->malloced = 1; s->seeded = 1; return s; diff --git a/sys/src/lib/sec/port/sha2_128.c b/sys/src/lib/sec/port/sha2_128.c index b3f7e8c..ac64172 100644 --- a/sys/src/lib/sec/port/sha2_128.c +++ b/sys/src/lib/sec/port/sha2_128.c @@ -2,7 +2,7 @@ * sha2 128-bit */ #include -#include +#include #include static void encode64(uint8_t*, uint64_t*, uint32_t); @@ -22,7 +22,7 @@ SHA2_384state* sha2_384(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_384state *s) { if(s == nil) { - s = mallocz(sizeof(*s), 1); + s = jehanne_mallocz(sizeof(*s), 1); if(s == nil) return nil; s->malloced = 1; @@ -50,7 +50,7 @@ sha2_512(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s) { if(s == nil) { - s = mallocz(sizeof(*s), 1); + s = jehanne_mallocz(sizeof(*s), 1); if(s == nil) return nil; s->malloced = 1; @@ -87,7 +87,7 @@ sha2_128(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s, int dlen) i = 128 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -110,7 +110,7 @@ sha2_128(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s, int dlen) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -124,7 +124,7 @@ sha2_128(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s, int dlen) p = s->buf; len = s->blen; } else { - memmove(buf, p, len); + jehanne_memmove(buf, p, len); p = buf; } s->len += len; @@ -133,7 +133,7 @@ sha2_128(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s, int dlen) i = 112 - len; else i = 240 - len; - memset(e, 0, i); + jehanne_memset(e, 0, i); *e = 0x80; len += i; @@ -149,7 +149,7 @@ sha2_128(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_512state *s, int dlen) /* return result and free state */ encode64(digest, s->bstate, dlen); if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/sha2_64.c b/sys/src/lib/sec/port/sha2_64.c index f594bee..e71ba93 100644 --- a/sys/src/lib/sec/port/sha2_64.c +++ b/sys/src/lib/sec/port/sha2_64.c @@ -2,7 +2,7 @@ * sha2 64-bit */ #include -#include +#include #include static void encode32(uint8_t*, uint32_t*, uint32_t); @@ -23,7 +23,7 @@ SHA2_224state* sha2_224(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_224state *s) { if(s == nil) { - s = mallocz(sizeof(*s), 1); + s = jehanne_mallocz(sizeof(*s), 1); if(s == nil) return nil; s->malloced = 1; @@ -50,7 +50,7 @@ SHA2_256state* sha2_256(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s) { if(s == nil) { - s = mallocz(sizeof(*s), 1); + s = jehanne_mallocz(sizeof(*s), 1); if(s == nil) return nil; s->malloced = 1; @@ -87,7 +87,7 @@ sha2_64(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s, int dlen) i = 64 - s->blen; if(len < i) i = len; - memmove(s->buf + s->blen, p, i); + jehanne_memmove(s->buf + s->blen, p, i); len -= i; s->blen += i; p += i; @@ -110,7 +110,7 @@ sha2_64(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s, int dlen) /* save the left overs if not last call */ if(digest == 0){ if(len){ - memmove(s->buf, p, len); + jehanne_memmove(s->buf, p, len); s->blen += len; } return s; @@ -124,7 +124,7 @@ sha2_64(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s, int dlen) p = s->buf; len = s->blen; } else { - memmove(buf, p, len); + jehanne_memmove(buf, p, len); p = buf; } s->len += len; @@ -133,7 +133,7 @@ sha2_64(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s, int dlen) i = 56 - len; else i = 120 - len; - memset(e, 0, i); + jehanne_memset(e, 0, i); *e = 0x80; len += i; @@ -149,7 +149,7 @@ sha2_64(uint8_t *p, uint32_t len, uint8_t *digest, SHA2_256state *s, int dlen) /* return result and free state */ encode32(digest, s->state, dlen); if(s->malloced == 1) - free(s); + jehanne_free(s); return nil; } diff --git a/sys/src/lib/sec/port/sha2block128.c b/sys/src/lib/sec/port/sha2block128.c index 1b24e5e..9fe9977 100644 --- a/sys/src/lib/sec/port/sha2block128.c +++ b/sys/src/lib/sec/port/sha2block128.c @@ -7,7 +7,7 @@ * and reflect the functions defined in FIPS pub. 180-2. */ #include -#include +#include #define ROTR(x,n) (((x) >> (n)) | ((x) << (64-(n)))) #define sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x) >> 7)) diff --git a/sys/src/lib/sec/port/sha2block64.c b/sys/src/lib/sec/port/sha2block64.c index c9f890e..213be56 100644 --- a/sys/src/lib/sec/port/sha2block64.c +++ b/sys/src/lib/sec/port/sha2block64.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define ROTR(x,n) (((x) >> (n)) | ((x) << (32-(n)))) #define sigma0(x) (ROTR((x),7) ^ ROTR((x),18) ^ ((x) >> 3)) diff --git a/sys/src/lib/sec/port/sha2test.c b/sys/src/lib/sec/port/sha2test.c index c3b3b8d..8eab8d8 100644 --- a/sys/src/lib/sec/port/sha2test.c +++ b/sys/src/lib/sec/port/sha2test.c @@ -1,5 +1,5 @@ #include -#include +#include #include "libsec.h" char *tests[] = { @@ -25,39 +25,39 @@ main(void) uint8_t *p; uint8_t digest[SHA2_512dlen]; - print("SHA2_224 tests:\n"); + jehanne_print("SHA2_224 tests:\n"); for(pp = tests; *pp; pp++){ p = (uint8_t*)*pp; - sha2_224(p, strlen(*pp), digest, 0); + sha2_224(p, jehanne_strlen(*pp), digest, 0); for(i = 0; i < SHA2_224dlen; i++) - print("%2.2ux", digest[i]); - print("\n"); + jehanne_print("%2.2ux", digest[i]); + jehanne_print("\n"); } - print("\nSHA256 tests:\n"); + jehanne_print("\nSHA256 tests:\n"); for(pp = tests; *pp; pp++){ p = (uint8_t*)*pp; - sha2_256(p, strlen(*pp), digest, 0); + sha2_256(p, jehanne_strlen(*pp), digest, 0); for(i = 0; i < SHA2_256dlen; i++) - print("%2.2ux", digest[i]); - print("\n"); + jehanne_print("%2.2ux", digest[i]); + jehanne_print("\n"); } - print("\nSHA384 tests:\n"); + jehanne_print("\nSHA384 tests:\n"); for(pp = tests; *pp; pp++){ p = (uint8_t*)*pp; - sha2_384(p, strlen(*pp), digest, 0); + sha2_384(p, jehanne_strlen(*pp), digest, 0); for(i = 0; i < SHA2_384dlen; i++) - print("%2.2ux", digest[i]); - print("\n"); + jehanne_print("%2.2ux", digest[i]); + jehanne_print("\n"); } - print("\nSHA512 tests:\n"); + jehanne_print("\nSHA512 tests:\n"); for(pp = tests; *pp; pp++){ p = (uint8_t*)*pp; - sha2_512(p, strlen(*pp), digest, 0); + sha2_512(p, jehanne_strlen(*pp), digest, 0); for(i = 0; i < SHA2_512dlen; i++) - print("%2.2ux", digest[i]); - print("\n"); + jehanne_print("%2.2ux", digest[i]); + jehanne_print("\n"); } } diff --git a/sys/src/lib/sec/port/thumb.c b/sys/src/lib/sec/port/thumb.c index 523fa41..587f2b9 100644 --- a/sys/src/lib/sec/port/thumb.c +++ b/sys/src/lib/sec/port/thumb.c @@ -20,10 +20,10 @@ freeThumbprints(Thumbprint *table) for(hd = table; hd < table+ThumbTab; hd++){ for(p = hd->next; p && p != hd; p = q){ q = p->next; - free(p); + jehanne_free(p); } } - free(table); + jehanne_free(table); } int @@ -35,7 +35,7 @@ okThumbprint(uint8_t *sum, Thumbprint *table) return 0; hd = tablehead(sum, table); for(p = hd->next; p; p = p->next){ - if(memcmp(sum, p->sha1, SHA1dlen) == 0) + if(jehanne_memcmp(sum, p->sha1, SHA1dlen) == 0) return 1; if(p == hd) break; @@ -51,23 +51,23 @@ loadThumbprints(char *file, Thumbprint *table, Thumbprint *crltab) uint8_t sum[SHA1dlen]; Biobuf *bin; - if(access(file, AEXIST) < 0) + if(jehanne_access(file, AEXIST) < 0) return 0; /* not an error */ if((bin = Bopen(file, OREAD)) == nil) return -1; - for(; (line = Brdstr(bin, '\n', 1)) != nil; free(line)){ - if(tokenize(line, field, nelem(field)) < 2) + for(; (line = Brdstr(bin, '\n', 1)) != nil; jehanne_free(line)){ + if(jehanne_tokenize(line, field, nelem(field)) < 2) continue; - if(strcmp(field[0], "#include") == 0){ + if(jehanne_strcmp(field[0], "#include") == 0){ if(loadThumbprints(field[1], table, crltab) < 0) goto err; continue; } - if(strcmp(field[0], "x509") != 0 || strncmp(field[1], "sha1=", 5) != 0) + if(jehanne_strcmp(field[0], "x509") != 0 || jehanne_strncmp(field[1], "sha1=", 5) != 0) continue; field[1] += 5; - if(dec16(sum, SHA1dlen, field[1], strlen(field[1])) != SHA1dlen){ - werrstr("malformed x509 entry in %s: %s", file, field[1]); + if(jehanne_dec16(sum, SHA1dlen, field[1], jehanne_strlen(field[1])) != SHA1dlen){ + jehanne_werrstr("malformed x509 entry in %s: %s", file, field[1]); goto err; } if(crltab && okThumbprint(sum, crltab)) @@ -76,17 +76,17 @@ loadThumbprints(char *file, Thumbprint *table, Thumbprint *crltab) if(hd->next == nil) entry = hd; else { - if((entry = malloc(sizeof(*entry))) == nil) + if((entry = jehanne_malloc(sizeof(*entry))) == nil) goto err; entry->next = hd->next; } hd->next = entry; - memcpy(entry->sha1, sum, SHA1dlen); + jehanne_memcpy(entry->sha1, sum, SHA1dlen); } Bterm(bin); return 0; err: - free(line); + jehanne_free(line); Bterm(bin); return -1; } @@ -98,15 +98,15 @@ initThumbprints(char *ok, char *crl) table = crltab = nil; if(crl){ - if((crltab = malloc(ThumbTab * sizeof(*crltab))) == nil) + if((crltab = jehanne_malloc(ThumbTab * sizeof(*crltab))) == nil) goto err; - memset(crltab, 0, ThumbTab * sizeof(*crltab)); + jehanne_memset(crltab, 0, ThumbTab * sizeof(*crltab)); if(loadThumbprints(crl, crltab, nil) < 0) goto err; } - if((table = malloc(ThumbTab * sizeof(*table))) == nil) + if((table = jehanne_malloc(ThumbTab * sizeof(*table))) == nil) goto err; - memset(table, 0, ThumbTab * sizeof(*table)); + jehanne_memset(table, 0, ThumbTab * sizeof(*table)); if(loadThumbprints(ok, table, crltab) < 0){ freeThumbprints(table); table = nil; diff --git a/sys/src/lib/sec/port/tlshand.c b/sys/src/lib/sec/port/tlshand.c index 5f782eb..6d74131 100644 --- a/sys/src/lib/sec/port/tlshand.c +++ b/sys/src/lib/sec/port/tlshand.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -482,21 +482,21 @@ tlsServer(int fd, TLSconn *conn) return -1; } buf[n] = 0; - snprint(conn->dir, sizeof(conn->dir), "#a/tls/%s", buf); - snprint(dname, sizeof(dname), "#a/tls/%s/hand", buf); + jehanne_snprint(conn->dir, sizeof(conn->dir), "#a/tls/%s", buf); + jehanne_snprint(dname, sizeof(dname), "#a/tls/%s/hand", buf); hand = open(dname, ORDWR); if(hand < 0){ close(ctl); return -1; } data = -1; - fprint(ctl, "fd %d 0x%x", fd, ProtocolVersion); + jehanne_fprint(ctl, "fd %d 0x%x", fd, ProtocolVersion); tls = tlsServer2(ctl, hand, conn->cert, conn->certlen, conn->pskID, conn->psk, conn->psklen, conn->trace, conn->chain); if(tls != nil){ - snprint(dname, sizeof(dname), "#a/tls/%s/data", buf); + jehanne_snprint(dname, sizeof(dname), "#a/tls/%s/data", buf); data = open(dname, ORDWR); } close(hand); @@ -505,14 +505,14 @@ tlsServer(int fd, TLSconn *conn) tlsConnectionFree(tls); return -1; } - free(conn->cert); + jehanne_free(conn->cert); conn->cert = nil; // client certificates are not yet implemented conn->certlen = 0; conn->sessionIDlen = 0; conn->sessionID = nil; if(conn->sessionKey != nil && conn->sessionType != nil - && strcmp(conn->sessionType, "ttls") == 0) + && jehanne_strcmp(conn->sessionType, "ttls") == 0) tls->sec->prf( conn->sessionKey, conn->sessionKeylen, tls->sec->sec, MasterSecretSize, @@ -534,7 +534,7 @@ tlsClientExtensions(TLSconn *conn, int *plen) // RFC6066 - Server Name Identification if(conn->serverName != nil){ - n = strlen(conn->serverName); + n = jehanne_strlen(conn->serverName); m = p - b; b = erealloc(b, m + 2+2+2+1+2+n); @@ -545,7 +545,7 @@ tlsClientExtensions(TLSconn *conn, int *plen) put16(p, 1+2+n), p += 2; /* Server Name list length */ *p++ = 0; /* Server Name Type: host_name */ put16(p, n), p += 2; /* Server Name length */ - memmove(p, conn->serverName, n); + jehanne_memmove(p, conn->serverName, n); p += n; } @@ -615,38 +615,38 @@ tlsClient(int fd, TLSconn *conn) return -1; } buf[n] = 0; - snprint(conn->dir, sizeof(conn->dir), "#a/tls/%s", buf); - snprint(dname, sizeof(dname), "#a/tls/%s/hand", buf); + jehanne_snprint(conn->dir, sizeof(conn->dir), "#a/tls/%s", buf); + jehanne_snprint(dname, sizeof(dname), "#a/tls/%s/hand", buf); hand = open(dname, ORDWR); if(hand < 0){ close(ctl); return -1; } - snprint(dname, sizeof(dname), "#a/tls/%s/data", buf); + jehanne_snprint(dname, sizeof(dname), "#a/tls/%s/data", buf); data = open(dname, ORDWR); if(data < 0){ close(hand); close(ctl); return -1; } - fprint(ctl, "fd %d 0x%x", fd, ProtocolVersion); + jehanne_fprint(ctl, "fd %d 0x%x", fd, ProtocolVersion); ext = tlsClientExtensions(conn, &n); tls = tlsClient2(ctl, hand, conn->cert, conn->certlen, conn->pskID, conn->psk, conn->psklen, ext, n, conn->trace); - free(ext); + jehanne_free(ext); close(hand); close(ctl); if(tls == nil){ close(data); return -1; } - free(conn->cert); + jehanne_free(conn->cert); if(tls->cert != nil){ conn->certlen = tls->cert->len; conn->cert = emalloc(conn->certlen); - memcpy(conn->cert, tls->cert->data, conn->certlen); + jehanne_memcpy(conn->cert, tls->cert->data, conn->certlen); } else { conn->certlen = 0; conn->cert = nil; @@ -655,7 +655,7 @@ tlsClient(int fd, TLSconn *conn) conn->sessionID = nil; if(conn->sessionKey != nil && conn->sessionType != nil - && strcmp(conn->sessionType, "ttls") == 0) + && jehanne_strcmp(conn->sessionType, "ttls") == 0) tls->sec->prf( conn->sessionKey, conn->sessionKeylen, tls->sec->sec, MasterSecretSize, @@ -700,7 +700,7 @@ tlsServer2(int ctl, int hand, c->trace = trace; c->version = ProtocolVersion; - memset(&m, 0, sizeof(m)); + jehanne_memset(&m, 0, sizeof(m)); if(!msgRecv(c, &m)){ if(trace) trace("initial msgRecv failed\n"); @@ -757,7 +757,7 @@ tlsServer2(int ctl, int hand, m.tag = HServerHello; m.u.serverHello.version = c->version; - memmove(m.u.serverHello.random, c->sec->srandom, RandomSize); + jehanne_memmove(m.u.serverHello.random, c->sec->srandom, RandomSize); m.u.serverHello.cipher = cipher; m.u.serverHello.compressor = compressor; m.u.serverHello.sid = makebytes(nil, 0); @@ -818,8 +818,8 @@ tlsServer2(int ctl, int hand, } if(pskid != nil){ if(m.u.clientKeyExchange.pskid == nil - || m.u.clientKeyExchange.pskid->len != strlen(pskid) - || memcmp(pskid, m.u.clientKeyExchange.pskid->data, m.u.clientKeyExchange.pskid->len) != 0){ + || m.u.clientKeyExchange.pskid->len != jehanne_strlen(pskid) + || jehanne_memcmp(pskid, m.u.clientKeyExchange.pskid->data, m.u.clientKeyExchange.pskid->len) != 0){ tlsError(c, EUnknownPSKidentity, "unknown or missing pskid"); goto Err; } @@ -866,7 +866,7 @@ tlsServer2(int ctl, int hand, msgClear(&m); /* change cipher spec */ - if(fprint(c->ctl, "changecipher") < 0){ + if(jehanne_fprint(c->ctl, "changecipher") < 0){ tlsError(c, EInternalError, "can't enable cipher: %r"); goto Err; } @@ -882,7 +882,7 @@ tlsServer2(int ctl, int hand, if(trace) trace("tls finished\n"); - if(fprint(c->ctl, "opened") < 0) + if(jehanne_fprint(c->ctl, "opened") < 0) goto Err; return c; @@ -951,12 +951,12 @@ Found: if(pub == nil) return nil; - memset(Q, 0, sizeof(*Q)); + jehanne_memset(Q, 0, sizeof(*Q)); Q->x = mpnew(0); Q->y = mpnew(0); Q->d = mpnew(0); - memset(&K, 0, sizeof(K)); + jehanne_memset(&K, 0, sizeof(K)); K.x = mpnew(0); K.y = mpnew(0); @@ -990,7 +990,7 @@ tlsClient2(int ctl, int hand, return nil; epm = nil; - memset(&m, 0, sizeof(m)); + jehanne_memset(&m, 0, sizeof(m)); c = emalloc(sizeof(TlsConnection)); c->ctl = ctl; @@ -1021,7 +1021,7 @@ tlsClient2(int ctl, int hand, /* client hello */ m.tag = HClientHello; m.u.clientHello.version = c->version; - memmove(m.u.clientHello.random, c->sec->crandom, RandomSize); + jehanne_memmove(m.u.clientHello.random, c->sec->crandom, RandomSize); m.u.clientHello.sid = makebytes(nil, 0); m.u.clientHello.ciphers = makeciphers(psklen > 0); m.u.clientHello.compressors = makebytes(compressors,sizeof(compressors)); @@ -1041,7 +1041,7 @@ tlsClient2(int ctl, int hand, goto Err; } tlsSecVers(c->sec, c->version); - memmove(c->sec->srandom, m.u.serverHello.random, RandomSize); + jehanne_memmove(c->sec->srandom, m.u.serverHello.random, RandomSize); cipher = m.u.serverHello.cipher; if((psklen > 0) != isPSK(cipher) || !setAlgs(c, cipher)) { @@ -1155,7 +1155,7 @@ tlsClient2(int ctl, int hand, if(psklen > 0){ if(pskid == nil) pskid = ""; - m.u.clientKeyExchange.pskid = makebytes((uint8_t*)pskid, strlen(pskid)); + m.u.clientKeyExchange.pskid = makebytes((uint8_t*)pskid, jehanne_strlen(pskid)); } m.u.clientKeyExchange.key = epm; epm = nil; @@ -1194,7 +1194,7 @@ tlsClient2(int ctl, int hand, } /* change cipher spec */ - if(fprint(c->ctl, "changecipher") < 0){ + if(jehanne_fprint(c->ctl, "changecipher") < 0){ tlsError(c, EInternalError, "can't enable cipher: %r"); goto Err; } @@ -1231,7 +1231,7 @@ tlsClient2(int ctl, int hand, } msgClear(&m); - if(fprint(c->ctl, "opened") < 0){ + if(jehanne_fprint(c->ctl, "opened") < 0){ if(trace) trace("unable to do final open: %r\n"); goto Err; @@ -1239,7 +1239,7 @@ tlsClient2(int ctl, int hand, return c; Err: - free(epm); + jehanne_free(epm); msgClear(&m); tlsConnectionFree(c); return nil; @@ -1282,13 +1282,13 @@ msgSend(TlsConnection *c, Msg *m, int act) p += 2; // random - memmove(p, m->u.clientHello.random, RandomSize); + jehanne_memmove(p, m->u.clientHello.random, RandomSize); p += RandomSize; // sid n = m->u.clientHello.sid->len; p[0] = n; - memmove(p+1, m->u.clientHello.sid->data, n); + jehanne_memmove(p+1, m->u.clientHello.sid->data, n); p += n+1; n = m->u.clientHello.ciphers->len; @@ -1301,7 +1301,7 @@ msgSend(TlsConnection *c, Msg *m, int act) n = m->u.clientHello.compressors->len; p[0] = n; - memmove(p+1, m->u.clientHello.compressors->data, n); + jehanne_memmove(p+1, m->u.clientHello.compressors->data, n); p += n+1; if(m->u.clientHello.extensions == nil) @@ -1310,7 +1310,7 @@ msgSend(TlsConnection *c, Msg *m, int act) if(n == 0) break; put16(p, n); - memmove(p+2, m->u.clientHello.extensions->data, n); + jehanne_memmove(p+2, m->u.clientHello.extensions->data, n); p += n+2; break; case HServerHello: @@ -1318,13 +1318,13 @@ msgSend(TlsConnection *c, Msg *m, int act) p += 2; // random - memmove(p, m->u.serverHello.random, RandomSize); + jehanne_memmove(p, m->u.serverHello.random, RandomSize); p += RandomSize; // sid n = m->u.serverHello.sid->len; p[0] = n; - memmove(p+1, m->u.serverHello.sid->data, n); + jehanne_memmove(p+1, m->u.serverHello.sid->data, n); p += n+1; put16(p, m->u.serverHello.cipher); @@ -1338,7 +1338,7 @@ msgSend(TlsConnection *c, Msg *m, int act) if(n == 0) break; put16(p, n); - memmove(p+2, m->u.serverHello.extensions->data, n); + jehanne_memmove(p+2, m->u.serverHello.extensions->data, n); p += n+2; break; case HServerHelloDone: @@ -1356,7 +1356,7 @@ msgSend(TlsConnection *c, Msg *m, int act) for(i = 0; i < m->u.certificate.ncert; i++){ put24(p, m->u.certificate.certs[i]->len); p += 3; - memmove(p, m->u.certificate.certs[i]->data, m->u.certificate.certs[i]->len); + jehanne_memmove(p, m->u.certificate.certs[i]->data, m->u.certificate.certs[i]->len); p += m->u.certificate.certs[i]->len; } break; @@ -1367,7 +1367,7 @@ msgSend(TlsConnection *c, Msg *m, int act) } put16(p, m->u.certificateVerify.signature->len); p += 2; - memmove(p, m->u.certificateVerify.signature->data, m->u.certificateVerify.signature->len); + jehanne_memmove(p, m->u.certificateVerify.signature->data, m->u.certificateVerify.signature->len); p += m->u.certificateVerify.signature->len; break; case HServerKeyExchange: @@ -1375,13 +1375,13 @@ msgSend(TlsConnection *c, Msg *m, int act) n = m->u.serverKeyExchange.pskid->len; put16(p, n); p += 2; - memmove(p, m->u.serverKeyExchange.pskid->data, n); + jehanne_memmove(p, m->u.serverKeyExchange.pskid->data, n); p += n; } if(m->u.serverKeyExchange.dh_parameters == nil) break; n = m->u.serverKeyExchange.dh_parameters->len; - memmove(p, m->u.serverKeyExchange.dh_parameters->data, n); + jehanne_memmove(p, m->u.serverKeyExchange.dh_parameters->data, n); p += n; if(m->u.serverKeyExchange.dh_signature == nil) break; @@ -1391,7 +1391,7 @@ msgSend(TlsConnection *c, Msg *m, int act) } n = m->u.serverKeyExchange.dh_signature->len; put16(p, n), p += 2; - memmove(p, m->u.serverKeyExchange.dh_signature->data, n); + jehanne_memmove(p, m->u.serverKeyExchange.dh_signature->data, n); p += n; break; case HClientKeyExchange: @@ -1399,7 +1399,7 @@ msgSend(TlsConnection *c, Msg *m, int act) n = m->u.clientKeyExchange.pskid->len; put16(p, n); p += 2; - memmove(p, m->u.clientKeyExchange.pskid->data, n); + jehanne_memmove(p, m->u.clientKeyExchange.pskid->data, n); p += n; } if(m->u.clientKeyExchange.key == nil) @@ -1411,11 +1411,11 @@ msgSend(TlsConnection *c, Msg *m, int act) else put16(p, n), p += 2; } - memmove(p, m->u.clientKeyExchange.key->data, n); + jehanne_memmove(p, m->u.clientKeyExchange.key->data, n); p += n; break; case HFinished: - memmove(p, m->u.finished.verify, m->u.finished.n); + jehanne_memmove(p, m->u.finished.verify, m->u.finished.n); p += m->u.finished.n; break; } @@ -1433,7 +1433,7 @@ msgSend(TlsConnection *c, Msg *m, int act) if(act == AFlush){ c->sendp = c->sendbuf; if(write(c->hand, c->sendbuf, p - c->sendbuf) < 0){ - fprint(2, "write error: %r\n"); + jehanne_fprint(2, "write error: %r\n"); goto Err; } } @@ -1453,7 +1453,7 @@ tlsReadN(TlsConnection *c, int n) nn = c->ep - c->rp; if(nn < n){ if(c->rp != c->recvbuf){ - memmove(c->recvbuf, c->rp, nn); + jehanne_memmove(c->recvbuf, c->rp, nn); c->rp = c->recvbuf; c->ep = &c->recvbuf[nn]; } @@ -1536,8 +1536,8 @@ msgRecv(TlsConnection *c, Msg *m) m->u.clientHello.sid = makebytes(nil, 0); if(nrandom > RandomSize) nrandom = RandomSize; - memset(m->u.clientHello.random, 0, RandomSize - nrandom); - memmove(&m->u.clientHello.random[RandomSize - nrandom], p, nrandom); + jehanne_memset(m->u.clientHello.random, 0, RandomSize - nrandom); + jehanne_memmove(&m->u.clientHello.random[RandomSize - nrandom], p, nrandom); m->u.clientHello.compressors = newbytes(1); m->u.clientHello.compressors->data[0] = CompressionNull; goto Ok; @@ -1564,7 +1564,7 @@ msgRecv(TlsConnection *c, Msg *m) if(n < RandomSize) goto Short; - memmove(m->u.clientHello.random, p, RandomSize); + jehanne_memmove(m->u.clientHello.random, p, RandomSize); p += RandomSize, n -= RandomSize; if(n < 1 || n < p[0]+1) goto Short; @@ -1606,7 +1606,7 @@ msgRecv(TlsConnection *c, Msg *m) if(n < RandomSize) goto Short; - memmove(m->u.serverHello.random, p, RandomSize); + jehanne_memmove(m->u.serverHello.random, p, RandomSize); p += RandomSize, n -= RandomSize; if(n < 1 || n < p[0]+1) @@ -1813,7 +1813,7 @@ msgRecv(TlsConnection *c, Msg *m) case SSL3FinishedLen: if(n < m->u.finished.n) goto Short; - memmove(m->u.finished.verify, p, m->u.finished.n); + jehanne_memmove(m->u.finished.verify, p, m->u.finished.n); n -= m->u.finished.n; break; case BeforeSetVersion: @@ -1831,7 +1831,7 @@ Ok: char *buf; buf = emalloc(8000); c->trace("recv %s", msgPrint(buf, 8000, m)); - free(buf); + jehanne_free(buf); } return 1; Short: @@ -1862,14 +1862,14 @@ msgClear(Msg *m) case HCertificate: for(i=0; iu.certificate.ncert; i++) freebytes(m->u.certificate.certs[i]); - free(m->u.certificate.certs); + jehanne_free(m->u.certificate.certs); break; case HCertificateRequest: freebytes(m->u.certificateRequest.types); freeints(m->u.certificateRequest.sigalgs); for(i=0; iu.certificateRequest.nca; i++) freebytes(m->u.certificateRequest.cas[i]); - free(m->u.certificateRequest.cas); + jehanne_free(m->u.certificateRequest.cas); break; case HCertificateVerify: freebytes(m->u.certificateVerify.signature); @@ -1891,7 +1891,7 @@ msgClear(Msg *m) case HFinished: break; } - memset(m, 0, sizeof(Msg)); + jehanne_memset(m, 0, sizeof(Msg)); } static char * @@ -1900,17 +1900,17 @@ bytesPrint(char *bs, char *be, char *s0, Bytes *b, char *s1) int i; if(s0) - bs = seprint(bs, be, "%s", s0); + bs = jehanne_seprint(bs, be, "%s", s0); if(b == nil) - bs = seprint(bs, be, "nil"); + bs = jehanne_seprint(bs, be, "nil"); else { - bs = seprint(bs, be, "<%d> [ ", b->len); + bs = jehanne_seprint(bs, be, "<%d> [ ", b->len); for(i=0; ilen; i++) - bs = seprint(bs, be, "%.2x ", b->data[i]); - bs = seprint(bs, be, "]"); + bs = jehanne_seprint(bs, be, "%.2x ", b->data[i]); + bs = jehanne_seprint(bs, be, "]"); } if(s1) - bs = seprint(bs, be, "%s", s1); + bs = jehanne_seprint(bs, be, "%s", s1); return bs; } @@ -1920,17 +1920,17 @@ intsPrint(char *bs, char *be, char *s0, Ints *b, char *s1) int i; if(s0) - bs = seprint(bs, be, "%s", s0); + bs = jehanne_seprint(bs, be, "%s", s0); if(b == nil) - bs = seprint(bs, be, "nil"); + bs = jehanne_seprint(bs, be, "nil"); else { - bs = seprint(bs, be, "[ "); + bs = jehanne_seprint(bs, be, "[ "); for(i=0; ilen; i++) - bs = seprint(bs, be, "%x ", b->data[i]); - bs = seprint(bs, be, "]"); + bs = jehanne_seprint(bs, be, "%x ", b->data[i]); + bs = jehanne_seprint(bs, be, "]"); } if(s1) - bs = seprint(bs, be, "%s", s1); + bs = jehanne_seprint(bs, be, "%s", s1); return bs; } @@ -1942,15 +1942,15 @@ msgPrint(char *buf, int n, Msg *m) switch(m->tag) { default: - bs = seprint(bs, be, "unknown %d\n", m->tag); + bs = jehanne_seprint(bs, be, "unknown %d\n", m->tag); break; case HClientHello: - bs = seprint(bs, be, "ClientHello\n"); - bs = seprint(bs, be, "\tversion: %.4x\n", m->u.clientHello.version); - bs = seprint(bs, be, "\trandom: "); + bs = jehanne_seprint(bs, be, "ClientHello\n"); + bs = jehanne_seprint(bs, be, "\tversion: %.4x\n", m->u.clientHello.version); + bs = jehanne_seprint(bs, be, "\trandom: "); for(i=0; iu.clientHello.random[i]); - bs = seprint(bs, be, "\n"); + bs = jehanne_seprint(bs, be, "%.2x", m->u.clientHello.random[i]); + bs = jehanne_seprint(bs, be, "\n"); bs = bytesPrint(bs, be, "\tsid: ", m->u.clientHello.sid, "\n"); bs = intsPrint(bs, be, "\tciphers: ", m->u.clientHello.ciphers, "\n"); bs = bytesPrint(bs, be, "\tcompressors: ", m->u.clientHello.compressors, "\n"); @@ -1958,71 +1958,71 @@ msgPrint(char *buf, int n, Msg *m) bs = bytesPrint(bs, be, "\textensions: ", m->u.clientHello.extensions, "\n"); break; case HServerHello: - bs = seprint(bs, be, "ServerHello\n"); - bs = seprint(bs, be, "\tversion: %.4x\n", m->u.serverHello.version); - bs = seprint(bs, be, "\trandom: "); + bs = jehanne_seprint(bs, be, "ServerHello\n"); + bs = jehanne_seprint(bs, be, "\tversion: %.4x\n", m->u.serverHello.version); + bs = jehanne_seprint(bs, be, "\trandom: "); for(i=0; iu.serverHello.random[i]); - bs = seprint(bs, be, "\n"); + bs = jehanne_seprint(bs, be, "%.2x", m->u.serverHello.random[i]); + bs = jehanne_seprint(bs, be, "\n"); bs = bytesPrint(bs, be, "\tsid: ", m->u.serverHello.sid, "\n"); - bs = seprint(bs, be, "\tcipher: %.4x\n", m->u.serverHello.cipher); - bs = seprint(bs, be, "\tcompressor: %.2x\n", m->u.serverHello.compressor); + bs = jehanne_seprint(bs, be, "\tcipher: %.4x\n", m->u.serverHello.cipher); + bs = jehanne_seprint(bs, be, "\tcompressor: %.2x\n", m->u.serverHello.compressor); if(m->u.serverHello.extensions != nil) bs = bytesPrint(bs, be, "\textensions: ", m->u.serverHello.extensions, "\n"); break; case HCertificate: - bs = seprint(bs, be, "Certificate\n"); + bs = jehanne_seprint(bs, be, "Certificate\n"); for(i=0; iu.certificate.ncert; i++) bs = bytesPrint(bs, be, "\t", m->u.certificate.certs[i], "\n"); break; case HCertificateRequest: - bs = seprint(bs, be, "CertificateRequest\n"); + bs = jehanne_seprint(bs, be, "CertificateRequest\n"); bs = bytesPrint(bs, be, "\ttypes: ", m->u.certificateRequest.types, "\n"); if(m->u.certificateRequest.sigalgs != nil) bs = intsPrint(bs, be, "\tsigalgs: ", m->u.certificateRequest.sigalgs, "\n"); - bs = seprint(bs, be, "\tcertificateauthorities\n"); + bs = jehanne_seprint(bs, be, "\tcertificateauthorities\n"); for(i=0; iu.certificateRequest.nca; i++) bs = bytesPrint(bs, be, "\t\t", m->u.certificateRequest.cas[i], "\n"); break; case HCertificateVerify: - bs = seprint(bs, be, "HCertificateVerify\n"); + bs = jehanne_seprint(bs, be, "HCertificateVerify\n"); if(m->u.certificateVerify.sigalg != 0) - bs = seprint(bs, be, "\tsigalg: %.4x\n", m->u.certificateVerify.sigalg); + bs = jehanne_seprint(bs, be, "\tsigalg: %.4x\n", m->u.certificateVerify.sigalg); bs = bytesPrint(bs, be, "\tsignature: ", m->u.certificateVerify.signature,"\n"); break; case HServerHelloDone: - bs = seprint(bs, be, "ServerHelloDone\n"); + bs = jehanne_seprint(bs, be, "ServerHelloDone\n"); break; case HServerKeyExchange: - bs = seprint(bs, be, "HServerKeyExchange\n"); + bs = jehanne_seprint(bs, be, "HServerKeyExchange\n"); if(m->u.serverKeyExchange.pskid != nil) bs = bytesPrint(bs, be, "\tpskid: ", m->u.serverKeyExchange.pskid, "\n"); if(m->u.serverKeyExchange.dh_parameters == nil) break; if(m->u.serverKeyExchange.curve != 0){ - bs = seprint(bs, be, "\tcurve: %.4x\n", m->u.serverKeyExchange.curve); + bs = jehanne_seprint(bs, be, "\tcurve: %.4x\n", m->u.serverKeyExchange.curve); } else { bs = bytesPrint(bs, be, "\tdh_p: ", m->u.serverKeyExchange.dh_p, "\n"); bs = bytesPrint(bs, be, "\tdh_g: ", m->u.serverKeyExchange.dh_g, "\n"); } bs = bytesPrint(bs, be, "\tdh_Ys: ", m->u.serverKeyExchange.dh_Ys, "\n"); if(m->u.serverKeyExchange.sigalg != 0) - bs = seprint(bs, be, "\tsigalg: %.4x\n", m->u.serverKeyExchange.sigalg); + bs = jehanne_seprint(bs, be, "\tsigalg: %.4x\n", m->u.serverKeyExchange.sigalg); bs = bytesPrint(bs, be, "\tdh_parameters: ", m->u.serverKeyExchange.dh_parameters, "\n"); bs = bytesPrint(bs, be, "\tdh_signature: ", m->u.serverKeyExchange.dh_signature, "\n"); break; case HClientKeyExchange: - bs = seprint(bs, be, "HClientKeyExchange\n"); + bs = jehanne_seprint(bs, be, "HClientKeyExchange\n"); if(m->u.clientKeyExchange.pskid != nil) bs = bytesPrint(bs, be, "\tpskid: ", m->u.clientKeyExchange.pskid, "\n"); if(m->u.clientKeyExchange.key != nil) bs = bytesPrint(bs, be, "\tkey: ", m->u.clientKeyExchange.key, "\n"); break; case HFinished: - bs = seprint(bs, be, "HFinished\n"); + bs = jehanne_seprint(bs, be, "HFinished\n"); for(i=0; iu.finished.n; i++) - bs = seprint(bs, be, "%.2x", m->u.finished.verify[i]); - bs = seprint(bs, be, "\n"); + bs = jehanne_seprint(bs, be, "%.2x", m->u.finished.verify[i]); + bs = jehanne_seprint(bs, be, "\n"); break; } USED(bs); @@ -2036,16 +2036,16 @@ tlsError(TlsConnection *c, int err, char *fmt, ...) va_list arg; va_start(arg, fmt); - vseprint(msg, msg+sizeof(msg), fmt, arg); + jehanne_vseprint(msg, msg+sizeof(msg), fmt, arg); va_end(arg); if(c->trace) c->trace("tlsError: %s\n", msg); if(c->erred) - fprint(2, "double error: %r, %s", msg); + jehanne_fprint(2, "double error: %r, %s", msg); else errstr(msg, sizeof(msg)); c->erred = 1; - fprint(c->ctl, "alert %d", err); + jehanne_fprint(c->ctl, "alert %d", err); } // commit to specific version number @@ -2063,7 +2063,7 @@ setVersion(TlsConnection *c, int version) c->version = version; c->finished.n = TLSFinishedLen; } - return fprint(c->ctl, "version 0x%x", version); + return jehanne_fprint(c->ctl, "version 0x%x", version); } // confirm that received Finished message matches the expected value @@ -2092,8 +2092,8 @@ tlsConnectionFree(TlsConnection *c) rsapubfree(c->sec->rsapub); freebytes(c->cert); - memset(c, 0, sizeof(*c)); - free(c); + jehanne_memset(c, 0, sizeof(*c)); + jehanne_free(c); } @@ -2203,7 +2203,7 @@ okCompression(Bytes *cv) for(i = 0; i < nelem(compressors); i++) { c = compressors[i]; - if(memchr(cv->data, c, cv->len) != nil) + if(jehanne_memchr(cv->data, c, cv->len) != nil) return c; } return -1; @@ -2219,28 +2219,28 @@ initCiphers(void) char s[MaxAlgF], *flds[MaxAlgs]; int i, j, n, ok; - lock(&ciphLock); + jehanne_lock(&ciphLock); if(nciphers){ - unlock(&ciphLock); + jehanne_unlock(&ciphLock); return nciphers; } j = open("#a/tls/encalgs", OREAD); if(j < 0){ - werrstr("can't open #a/tls/encalgs: %r"); + jehanne_werrstr("can't open #a/tls/encalgs: %r"); goto out; } n = read(j, s, MaxAlgF-1); close(j); if(n <= 0){ - werrstr("nothing in #a/tls/encalgs: %r"); + jehanne_werrstr("nothing in #a/tls/encalgs: %r"); goto out; } s[n] = 0; - n = getfields(s, flds, MaxAlgs, 1, " \t\r\n"); + n = jehanne_getfields(s, flds, MaxAlgs, 1, " \t\r\n"); for(i = 0; i < nelem(cipherAlgs); i++){ ok = 0; for(j = 0; j < n; j++){ - if(strcmp(cipherAlgs[i].enc, flds[j]) == 0){ + if(jehanne_strcmp(cipherAlgs[i].enc, flds[j]) == 0){ ok = 1; break; } @@ -2250,21 +2250,21 @@ initCiphers(void) j = open("#a/tls/hashalgs", OREAD); if(j < 0){ - werrstr("can't open #a/tls/hashalgs: %r"); + jehanne_werrstr("can't open #a/tls/hashalgs: %r"); goto out; } n = read(j, s, MaxAlgF-1); close(j); if(n <= 0){ - werrstr("nothing in #a/tls/hashalgs: %r"); + jehanne_werrstr("nothing in #a/tls/hashalgs: %r"); goto out; } s[n] = 0; - n = getfields(s, flds, MaxAlgs, 1, " \t\r\n"); + n = jehanne_getfields(s, flds, MaxAlgs, 1, " \t\r\n"); for(i = 0; i < nelem(cipherAlgs); i++){ ok = 0; for(j = 0; j < n; j++){ - if(strcmp(cipherAlgs[i].digest, flds[j]) == 0){ + if(jehanne_strcmp(cipherAlgs[i].digest, flds[j]) == 0){ ok = 1; break; } @@ -2274,7 +2274,7 @@ initCiphers(void) nciphers++; } out: - unlock(&ciphLock); + jehanne_unlock(&ciphLock); return nciphers; } @@ -2314,7 +2314,7 @@ factotum_rsa_open(RSApub *rsapub) return nil; } s = "proto=rsa service=tls role=client"; - if(auth_rpc(rpc, "start", s, strlen(s)) == ARok){ + if(auth_rpc(rpc, "start", s, jehanne_strlen(s)) == ARok){ // roll factotum keyring around to match public key n = mpnew(0); while(auth_rpc(rpc, "read", nil, 0) == ARok){ @@ -2340,8 +2340,8 @@ factotum_rsa_decrypt(AuthRpc *rpc, mpint *cipher) mpfree(cipher); if(p == nil) return nil; - rv = auth_rpc(rpc, "write", p, strlen(p)); - free(p); + rv = auth_rpc(rpc, "write", p, jehanne_strlen(p)); + jehanne_free(p); if(rv != ARok || auth_rpc(rpc, "read", nil, 0) != ARok) return nil; return strtomp(rpc->arg, nil, 16, nil); @@ -2381,7 +2381,7 @@ tlsPmd5(uint8_t *buf, int nbuf, uint8_t *key, int nkey, uint8_t *label, int nlab buf += n; nbuf -= n; hmac_md5(ai, MD5dlen, key, nkey, tmp, nil); - memmove(ai, tmp, MD5dlen); + jehanne_memmove(ai, tmp, MD5dlen); } } @@ -2410,7 +2410,7 @@ tlsPsha1(uint8_t *buf, int nbuf, uint8_t *key, int nkey, uint8_t *label, int nla buf += n; nbuf -= n; hmac_sha1(ai, SHA1dlen, key, nkey, tmp, nil); - memmove(ai, tmp, SHA1dlen); + jehanne_memmove(ai, tmp, SHA1dlen); } } @@ -2432,11 +2432,11 @@ p_sha256(uint8_t *buf, int nbuf, uint8_t *key, int nkey, uint8_t *label, int nla n = SHA2_256dlen; if(n > nbuf) n = nbuf; - memmove(buf, tmp, n); + jehanne_memmove(buf, tmp, n); buf += n; nbuf -= n; hmac_sha2_256(ai, SHA2_256dlen, key, nkey, tmp, nil); - memmove(ai, tmp, SHA2_256dlen); + jehanne_memmove(ai, tmp, SHA2_256dlen); } } @@ -2444,10 +2444,10 @@ p_sha256(uint8_t *buf, int nbuf, uint8_t *key, int nkey, uint8_t *label, int nla static void tls10PRF(uint8_t *buf, int nbuf, uint8_t *key, int nkey, char *label, uint8_t *seed0, int nseed0, uint8_t *seed1, int nseed1) { - int nlabel = strlen(label); + int nlabel = jehanne_strlen(label); int n = (nkey + 1) >> 1; - memset(buf, 0, nbuf); + jehanne_memset(buf, 0, nbuf); tlsPmd5(buf, nbuf, key, n, (uint8_t*)label, nlabel, seed0, nseed0, seed1, nseed1); tlsPsha1(buf, nbuf, key+nkey-n, n, (uint8_t*)label, nlabel, seed0, nseed0, seed1, nseed1); } @@ -2458,9 +2458,9 @@ tls12PRF(uint8_t *buf, int nbuf, uint8_t *key, int nkey, char *label, uint8_t *s uint8_t seed[2*RandomSize]; assert(nseed0+nseed1 <= sizeof(seed)); - memmove(seed, seed0, nseed0); - memmove(seed+nseed0, seed1, nseed1); - p_sha256(buf, nbuf, key, nkey, (uint8_t*)label, strlen(label), seed, nseed0+nseed1); + jehanne_memmove(seed, seed0, nseed0); + jehanne_memmove(seed+nseed0, seed1, nseed1); + p_sha256(buf, nbuf, key, nkey, (uint8_t*)label, jehanne_strlen(label), seed, nseed0+nseed1); } static void @@ -2486,7 +2486,7 @@ sslPRF(uint8_t *buf, int nbuf, uint8_t *key, int nkey, char *label, uint8_t *see n = MD5dlen; if(n > nbuf) n = nbuf; - memmove(buf, md5dig, n); + jehanne_memmove(buf, md5dig, n); buf += n; nbuf -= n; len++; @@ -2507,20 +2507,20 @@ sslSetFinished(TlsSec *sec, HandshakeHash hsh, uint8_t *finished, int isclient) md5((uint8_t*)label, 4, nil, &hsh.md5); md5(sec->sec, MasterSecretSize, nil, &hsh.md5); - memset(pad, 0x36, 48); + jehanne_memset(pad, 0x36, 48); md5(pad, 48, nil, &hsh.md5); md5(nil, 0, h0, &hsh.md5); - memset(pad, 0x5C, 48); + jehanne_memset(pad, 0x5C, 48); s = md5(sec->sec, MasterSecretSize, nil, nil); s = md5(pad, 48, nil, s); md5(h0, MD5dlen, finished, s); sha1((uint8_t*)label, 4, nil, &hsh.sha1); sha1(sec->sec, MasterSecretSize, nil, &hsh.sha1); - memset(pad, 0x36, 40); + jehanne_memset(pad, 0x36, 40); sha1(pad, 40, nil, &hsh.sha1); sha1(nil, 0, h1, &hsh.sha1); - memset(pad, 0x5C, 40); + jehanne_memset(pad, 0x5C, 40); s = sha1(sec->sec, MasterSecretSize, nil, nil); s = sha1(pad, 40, nil, s); sha1(h1, SHA1dlen, finished + MD5dlen, s); @@ -2557,17 +2557,17 @@ tls12SetFinished(TlsSec *sec, HandshakeHash hsh, uint8_t *finished, int isclient label = "client finished"; else label = "server finished"; - p_sha256(finished, TLSFinishedLen, sec->sec, MasterSecretSize, (uint8_t*)label, strlen(label), seed, SHA2_256dlen); + p_sha256(finished, TLSFinishedLen, sec->sec, MasterSecretSize, (uint8_t*)label, jehanne_strlen(label), seed, SHA2_256dlen); } static void tlsSecInits(TlsSec *sec, int cvers, uint8_t *crandom) { - memset(sec, 0, sizeof(*sec)); + jehanne_memset(sec, 0, sizeof(*sec)); sec->clientVers = cvers; - memmove(sec->crandom, crandom, RandomSize); + jehanne_memmove(sec->crandom, crandom, RandomSize); - put32(sec->srandom, time(nil)); + put32(sec->srandom, jehanne_time(nil)); genrandom(sec->srandom+4, RandomSize-4); } @@ -2577,7 +2577,7 @@ tlsSecRSAs(TlsSec *sec, Bytes *epm) Bytes *pm; if(epm == nil){ - werrstr("no encrypted premaster secret"); + jehanne_werrstr("no encrypted premaster secret"); return -1; } // if the client messed up, just continue as if everything is ok, @@ -2601,7 +2601,7 @@ tlsSecECDHEs1(TlsSec *sec, Namedcurve *nc) int n; ecdominit(dom, nc->init); - memset(Q, 0, sizeof(*Q)); + jehanne_memset(Q, 0, sizeof(*Q)); Q->x = mpnew(0); Q->y = mpnew(0); Q->d = mpnew(0); @@ -2626,16 +2626,16 @@ tlsSecECDHEs2(TlsSec *sec, Bytes *Yc) ECpub *Y; if(Yc == nil){ - werrstr("no public key"); + jehanne_werrstr("no public key"); return -1; } if((Y = ecdecodepub(dom, Yc->data, Yc->len)) == nil){ - werrstr("bad public key"); + jehanne_werrstr("bad public key"); return -1; } - memset(&K, 0, sizeof(K)); + jehanne_memset(&K, 0, sizeof(K)); K.x = mpnew(0); K.y = mpnew(0); @@ -2653,9 +2653,9 @@ tlsSecECDHEs2(TlsSec *sec, Bytes *Yc) static void tlsSecInitc(TlsSec *sec, int cvers) { - memset(sec, 0, sizeof(*sec)); + jehanne_memset(sec, 0, sizeof(*sec)); sec->clientVers = cvers; - put32(sec->crandom, time(nil)); + put32(sec->crandom, jehanne_time(nil)); genrandom(sec->crandom+4, RandomSize-4); } @@ -2667,7 +2667,7 @@ tlsSecRSAc(TlsSec *sec, uint8_t *cert, int ncert) pub = X509toRSApub(cert, ncert, nil, 0); if(pub == nil){ - werrstr("invalid x509/rsa certificate"); + jehanne_werrstr("invalid x509/rsa certificate"); return nil; } pm = newbytes(MasterSecretSize); @@ -2683,7 +2683,7 @@ static int tlsSecFinished(TlsSec *sec, HandshakeHash hsh, uint8_t *fin, int nfin, int isclient) { if(sec->nfin != nfin){ - werrstr("invalid finished exchange"); + jehanne_werrstr("invalid finished exchange"); return -1; } hsh.md5.malloced = 0; @@ -2731,12 +2731,12 @@ setSecrets(TlsConnection *c, int isclient) (*c->sec->prf)(kd, c->nsecret, c->sec->sec, MasterSecretSize, "key expansion", c->sec->srandom, RandomSize, c->sec->crandom, RandomSize); - enc64(secrets, 2*c->nsecret, kd, c->nsecret); - memset(kd, 0, c->nsecret); + jehanne_enc64(secrets, 2*c->nsecret, kd, c->nsecret); + jehanne_memset(kd, 0, c->nsecret); - rv = fprint(c->ctl, "secret %s %s %d %s", c->digest, c->enc, isclient, secrets); - memset(secrets, 0, 2*c->nsecret); - free(secrets); + rv = jehanne_fprint(c->ctl, "secret %s %s %d %s", c->digest, c->enc, isclient, secrets); + jehanne_memset(secrets, 0, 2*c->nsecret); + jehanne_free(secrets); return rv; } @@ -2756,18 +2756,18 @@ setMasterSecret(TlsSec *sec, Bytes *pm) pm = newbytes(4 + opm->len + sec->psklen); p = pm->data; put16(p, opm->len), p += 2; - memmove(p, opm->data, opm->len), p += opm->len; + jehanne_memmove(p, opm->data, opm->len), p += opm->len; put16(p, sec->psklen), p += 2; - memmove(p, sec->psk, sec->psklen); + jehanne_memmove(p, sec->psk, sec->psklen); - memset(opm->data, 0, opm->len); + jehanne_memset(opm->data, 0, opm->len); freebytes(opm); } (*sec->prf)(sec->sec, MasterSecretSize, pm->data, pm->len, "master secret", sec->crandom, RandomSize, sec->srandom, RandomSize); - memset(pm->data, 0, pm->len); + jehanne_memset(pm->data, 0, pm->len); freebytes(pm); } @@ -2779,9 +2779,9 @@ digestDHparams(TlsSec *sec, Bytes *par, uint8_t digest[MAXdlen], int sigalg) Bytes *blob; blob = newbytes(2*RandomSize + par->len); - memmove(blob->data+0*RandomSize, sec->crandom, RandomSize); - memmove(blob->data+1*RandomSize, sec->srandom, RandomSize); - memmove(blob->data+2*RandomSize, par->data, par->len); + jehanne_memmove(blob->data+0*RandomSize, sec->crandom, RandomSize); + jehanne_memmove(blob->data+1*RandomSize, sec->srandom, RandomSize); + jehanne_memmove(blob->data+2*RandomSize, par->data, par->len); if(hashalg == 0){ digestlen = MD5dlen+SHA1dlen; md5(blob->data, blob->len, digest, nil); @@ -2865,15 +2865,15 @@ rsacomp(Bytes* block, RSApub* key, int modlen) if(ylen < modlen) { a = newbytes(modlen); - memset(a->data, 0, modlen-ylen); - memmove(a->data+modlen-ylen, ybytes->data, ylen); + jehanne_memset(a->data, 0, modlen-ylen); + jehanne_memmove(a->data+modlen-ylen, ybytes->data, ylen); freebytes(ybytes); ybytes = a; } else if(ylen > modlen) { // assume it has leading zeros (mod should make it so) a = newbytes(modlen); - memmove(a->data, ybytes->data, modlen); + jehanne_memmove(a->data, ybytes->data, modlen); freebytes(ybytes); ybytes = a; } @@ -2905,9 +2905,9 @@ pkcs1_encrypt(Bytes* data, RSApub* key, int blocktype) eb = newbytes(modlen); eb->data[0] = 0; eb->data[1] = blocktype; - memmove(eb->data+2, pad->data, padlen); + jehanne_memmove(eb->data+2, pad->data, padlen); eb->data[padlen+2] = 0; - memmove(eb->data+padlen+3, data->data, dlen); + jehanne_memmove(eb->data+padlen+3, data->data, dlen); ans = rsacomp(eb, key, modlen); freebytes(eb); freebytes(pad); @@ -2939,7 +2939,7 @@ pkcs1_decrypt(TlsSec *sec, Bytes *cipher) break; if(++i < eb->len){ eb->len -= i; - memmove(eb->data, eb->data+i, eb->len); + jehanne_memmove(eb->data, eb->data+i, eb->len); return eb; } } @@ -2958,11 +2958,11 @@ pkcs1_sign(TlsSec *sec, uint8_t *digest, int digestlen, int sigalg) if(hashalg > 0 && hashalg < nelem(hashfun) && hashfun[hashalg].len == digestlen) digestlen = asn1encodedigest(hashfun[hashalg].fun, digest, buf, sizeof(buf)); else if(digestlen == MD5dlen+SHA1dlen) - memmove(buf, digest, digestlen); + jehanne_memmove(buf, digest, digestlen); else digestlen = -1; if(digestlen <= 0){ - werrstr("bad digest algorithm"); + jehanne_werrstr("bad digest algorithm"); return nil; } signedMP = factotum_rsa_decrypt(sec->rpc, pkcs1padbuf(buf, digestlen, sec->rsapub->n)); @@ -2982,11 +2982,11 @@ emalloc(int n) void *p; if(n==0) n=1; - p = malloc(n); + p = jehanne_malloc(n); if(p == nil) - sysfatal("out of memory"); - memset(p, 0, n); - setmalloctag(p, getcallerpc()); + jehanne_sysfatal("out of memory"); + jehanne_memset(p, 0, n); + jehanne_setmalloctag(p, jehanne_getcallerpc()); return p; } @@ -2997,9 +2997,9 @@ erealloc(void *ReallocP, int ReallocN) ReallocN = 1; if(ReallocP == nil) ReallocP = emalloc(ReallocN); - else if((ReallocP = realloc(ReallocP, ReallocN)) == nil) - sysfatal("out of memory"); - setrealloctag(ReallocP, getcallerpc()); + else if((ReallocP = jehanne_realloc(ReallocP, ReallocN)) == nil) + jehanne_sysfatal("out of memory"); + jehanne_setrealloctag(ReallocP, jehanne_getcallerpc()); return(ReallocP); } @@ -3068,14 +3068,14 @@ makebytes(uint8_t* buf, int len) Bytes* ans; ans = newbytes(len); - memmove(ans->data, buf, len); + jehanne_memmove(ans->data, buf, len); return ans; } static void freebytes(Bytes* b) { - free(b); + jehanne_free(b); } static mpint* @@ -3116,7 +3116,7 @@ newints(int len) static void freeints(Ints* b) { - free(b); + jehanne_free(b); } static int diff --git a/sys/src/lib/sec/port/tsmemcmp.c b/sys/src/lib/sec/port/tsmemcmp.c index 0220f84..a5f928f 100644 --- a/sys/src/lib/sec/port/tsmemcmp.c +++ b/sys/src/lib/sec/port/tsmemcmp.c @@ -2,7 +2,7 @@ #include /* - * timing safe memcmp() + * timing safe jehanne_memcmp() */ int tsmemcmp(void *a1, void *a2, uint32_t n) diff --git a/sys/src/lib/sec/port/x509.c b/sys/src/lib/sec/port/x509.c index fd1ed38..6b99acc 100644 --- a/sys/src/lib/sec/port/x509.c +++ b/sys/src/lib/sec/port/x509.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -160,11 +160,11 @@ emalloc(int n) void *p; if(n==0) n=1; - p = malloc(n); + p = jehanne_malloc(n); if(p == nil) - sysfatal("out of memory"); - memset(p, 0, n); - setmalloctag(p, getcallerpc()); + jehanne_sysfatal("out of memory"); + jehanne_memset(p, 0, n); + jehanne_setmalloctag(p, jehanne_getcallerpc()); return p; } @@ -174,9 +174,9 @@ estrdup(char *s) char *d; int n; - n = strlen(s)+1; + n = jehanne_strlen(s)+1; d = emalloc(n); - memmove(d, s, n); + jehanne_memmove(d, s, n); return d; } @@ -222,7 +222,7 @@ ber_decode(uint8_t** pp, uint8_t* pend, Elem* pelem) Tag tag; Value val; - memset(pelem, 0, sizeof(*pelem)); + jehanne_memset(pelem, 0, sizeof(*pelem)); err = tag_decode(pp, pend, &tag, &isconstr); if(err == ASN_OK) { err = length_decode(pp, pend, &length); @@ -511,7 +511,7 @@ value_decode(uint8_t** pp, uint8_t* pend, int length, int kind, int isconstr, Va break; n--; s += 4; - d += runetochar(d, &r); + d += jehanne_runetochar(d, &r); } *d = 0; break; @@ -526,7 +526,7 @@ value_decode(uint8_t** pp, uint8_t* pend, int length, int kind, int isconstr, Va break; n--; s += 2; - d += runetochar(d, &r); + d += jehanne_runetochar(d, &r); } *d = 0; break; @@ -547,10 +547,10 @@ value_decode(uint8_t** pp, uint8_t* pend, int length, int kind, int isconstr, Va } if(n != 0){ err = ASN_EINVAL; - free(pval->u.stringval); + jehanne_free(pval->u.stringval); } else pval->tag = VString; - free(va); + jehanne_free(va); } break; @@ -939,7 +939,7 @@ val_enc(uint8_t** pp, Elem e, int *pconstr, int lenonly) else { if(is_bigint(&e, &bb)) { if(!lenonly) - memmove(p, bb->data, bb->len); + jehanne_memmove(p, bb->data, bb->len); p += bb->len; } else @@ -961,7 +961,7 @@ val_enc(uint8_t** pp, Elem e, int *pconstr, int lenonly) else { if(!lenonly) { *p = v; - memmove(p+1, bits->data, bits->len); + jehanne_memmove(p+1, bits->data, bits->len); } p += 1 + bits->len; } @@ -990,7 +990,7 @@ val_enc(uint8_t** pp, Elem e, int *pconstr, int lenonly) } if(bb != nil) { if(!lenonly) - memmove(p, bb->data, bb->len); + jehanne_memmove(p, bb->data, bb->len); p += bb->len; } else @@ -1051,9 +1051,9 @@ val_enc(uint8_t** pp, Elem e, int *pconstr, int lenonly) if(e.val.tag == VString) { s = e.val.u.stringval; if(s != nil) { - v = strlen(s); + v = jehanne_strlen(s); if(!lenonly) - memmove(p, s, v); + jehanne_memmove(p, s, v); p += v; } } @@ -1311,14 +1311,14 @@ makebytes(uint8_t* buf, int len) Bytes* ans; ans = newbytes(len); - memmove(ans->data, buf, len); + jehanne_memmove(ans->data, buf, len); return ans; } static void freebytes(Bytes* b) { - free(b); + jehanne_free(b); } /* @@ -1344,8 +1344,8 @@ catbytes(Bytes* b1, Bytes* b2) n = b1->len + b2->len; ans = newbytes(n); ans->len = n; - memmove(ans->data, b1->data, b1->len); - memmove(ans->data+b1->len, b2->data, b2->len); + jehanne_memmove(ans->data, b1->data, b1->len); + jehanne_memmove(ans->data+b1->len, b2->data, b2->len); } return ans; } @@ -1369,14 +1369,14 @@ makeints(int* buf, int len) Ints* ans; ans = newints(len); - memmove(ans->data, buf, len*sizeof(int)); + jehanne_memmove(ans->data, buf, len*sizeof(int)); return ans; } static void freeints(Ints* b) { - free(b); + jehanne_free(b); } /* len is number of bytes */ @@ -1399,7 +1399,7 @@ makebits(uint8_t* buf, int len, int unusedbits) Bits* ans; ans = newbits(len); - memmove(ans->data, buf, len); + jehanne_memmove(ans->data, buf, len); ans->unusedbits = unusedbits; return ans; } @@ -1407,7 +1407,7 @@ makebits(uint8_t* buf, int len, int unusedbits) static void freebits(Bits* b) { - free(b); + jehanne_free(b); } static Elist* @@ -1416,7 +1416,7 @@ mkel(Elem e, Elist* tail) Elist* el; el = (Elist*)emalloc(sizeof(Elist)); - setmalloctag(el, getcallerpc()); + jehanne_setmalloctag(el, jehanne_getcallerpc()); el->hd = e; el->tl = tail; return el; @@ -1441,7 +1441,7 @@ freeelist(Elist* el) while(el != nil) { next = el->tl; - free(el); + jehanne_free(el); el = next; } } @@ -1475,7 +1475,7 @@ freevalfields(Value* v) break; case VString: if(v->u.stringval) - free(v->u.stringval); + jehanne_free(v->u.stringval); break; case VSeq: el = v->u.seqval; @@ -1711,13 +1711,13 @@ freecert(CertX509* c) { if(c == nil) return; - free(c->issuer); - free(c->validity_start); - free(c->validity_end); - free(c->subject); + jehanne_free(c->issuer); + jehanne_free(c->validity_start); + jehanne_free(c->validity_end); + jehanne_free(c->subject); freebytes(c->publickey); freebytes(c->signature); - free(c); + jehanne_free(c); } /* @@ -1760,7 +1760,7 @@ parse_name(Elem* e) if(!is_string(&eatl->tl->hd, &s) || i>=MAXPARTS) goto errret; parts[i++] = s; - plen += strlen(s) + 2; /* room for ", " after */ + plen += jehanne_strlen(s) + 2; /* room for ", " after */ esetl = esetl->tl; } el = el->tl; @@ -1770,9 +1770,9 @@ parse_name(Elem* e) *ans = '\0'; while(--i >= 0) { s = parts[i]; - strcat(ans, s); + jehanne_strcat(ans, s); if(i > 0) - strcat(ans, ", "); + jehanne_strcat(ans, ", "); } } @@ -2146,9 +2146,9 @@ pkcs1padbuf(uint8_t *buf, int len, mpint *modulus) for(i = 2; i < pm1; i++) p[i] = 0xFF; p[pm1] = 0; - memcpy(&p[pm1+1], buf, len); + jehanne_memcpy(&p[pm1+1], buf, len); mp = betomp(p, n, nil); - free(p); + jehanne_free(p); return mp; } @@ -2242,10 +2242,10 @@ pkcs1decryptsignature(uint8_t *sig, int siglen, RSApub *pk, uint8_t **pbuf) if(buflen < 1 || buf[0] != 0) goto bad; buf++, buflen--; - memmove(*pbuf, buf, buflen); + jehanne_memmove(*pbuf, buf, buflen); return buflen; bad: - free(*pbuf); + jehanne_free(*pbuf); *pbuf = nil; return -1; } @@ -2262,11 +2262,11 @@ X509rsaverifydigest(uint8_t *sig, int siglen, uint8_t *edigest, int edigestlen, buflen = pkcs1decryptsignature(sig, siglen, pk, &buf); if(buflen == edigestlen && tsmemcmp(buf, edigest, edigestlen) == 0){ - free(buf); + jehanne_free(buf); return nil; } el = nil; - memset(&e, 0, sizeof(e)); + jehanne_memset(&e, 0, sizeof(e)); if(buflen < 0 || decode(buf, buflen, &e) != ASN_OK || !is_seq(&e, &el) || elistlen(el) != 2 || !is_octetstring(&el->tl->hd, &digest)) { err = "signature parse error"; @@ -2288,7 +2288,7 @@ X509rsaverifydigest(uint8_t *sig, int siglen, uint8_t *edigest, int edigestlen, err = nil; end: freevalfields(&e.val); - free(buf); + jehanne_free(buf); return err; } @@ -2380,7 +2380,7 @@ X509toRSApub(uint8_t *cert, int ncert, char *name, int nname) RSApub *pub; if(name != nil) - memset(name, 0, nname); + jehanne_memset(name, 0, nname); b = makebytes(cert, ncert); c = decode_cert(b); @@ -2388,10 +2388,10 @@ X509toRSApub(uint8_t *cert, int ncert, char *name, int nname) if(c == nil) return nil; if(name != nil && c->subject != nil){ - e = strchr(c->subject, ','); + e = jehanne_strchr(c->subject, ','); if(e != nil) *e = 0; /* take just CN part of Distinguished Name */ - strncpy(name, c->subject, nname); + jehanne_strncpy(name, c->subject, nname); } pub = nil; if(c->publickey_alg == ALG_rsaEncryption) @@ -2462,7 +2462,7 @@ mkbigint(mpint *p) e.val.tag = VBigInt; buflen = mptobe(p, nil, 0, &buf); e.val.u.bigintval = makebytes(buf, buflen); - free(buf); + jehanne_free(buf); return e; } @@ -2475,7 +2475,7 @@ printable(char *s) if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') - || strchr("'=()+,-./:? ", c) != nil) + || jehanne_strchr("'=()+,-./:? ", c) != nil) continue; return 0; } @@ -2527,12 +2527,12 @@ mkutc(int32_t t) { Elem e; char utc[50]; - Tm *tm = gmtime(t); + Tm *tm = jehanne_gmtime(t); e.tag.class = Universal; e.tag.num = UTCTime; e.val.tag = VString; - snprint(utc, sizeof(utc), "%.2d%.2d%.2d%.2d%.2d%.2dZ", + jehanne_snprint(utc, sizeof(utc), "%.2d%.2d%.2d%.2d%.2d%.2dZ", tm->year % 100, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec); e.val.u.stringval = estrdup(utc); return e; @@ -2610,17 +2610,17 @@ mkDN(char *dn) char *f[20], *prefix, *d2 = estrdup(dn); Elist* el = nil; - nf = tokenize(d2, f, nelem(f)); + nf = jehanne_tokenize(d2, f, nelem(f)); for(i=nf-1; i>=0; i--){ for(j=0; jlen; - memmove(buf, bytes->data, len); + jehanne_memmove(buf, bytes->data, len); freebytes(bytes); return len; } @@ -2688,12 +2688,12 @@ mkaltname(char *s) int i; for(i=0; ilen; - cert = malloc(certbytes->len); + cert = jehanne_malloc(certbytes->len); if(cert != nil) - memmove(cert, certbytes->data, certbytes->len); + jehanne_memmove(cert, certbytes->data, certbytes->len); freebytes(certbytes); errret: freevalfields(&e.val); - free(subj); + jehanne_free(subj); return cert; } @@ -2895,18 +2895,18 @@ X509rsareq(RSApriv *priv, char *subj, int *certlen) mkel(mkalg(sigalg), mkel(mkbits(buf, buflen), nil)))); - free(buf); + jehanne_free(buf); if(encode(e, &certbytes) != ASN_OK) goto errret; if(certlen) *certlen = certbytes->len; - cert = malloc(certbytes->len); + cert = jehanne_malloc(certbytes->len); if(cert != nil) - memmove(cert, certbytes->data, certbytes->len); + jehanne_memmove(cert, certbytes->data, certbytes->len); freebytes(certbytes); errret: freevalfields(&e.val); - free(subj); + jehanne_free(subj); return cert; } @@ -2916,7 +2916,7 @@ tagdump(Tag tag) static char buf[32]; if(tag.class != Universal){ - snprint(buf, sizeof(buf), "class%d,num%d", tag.class, tag.num); + jehanne_snprint(buf, sizeof(buf), "class%d,num%d", tag.class, tag.num); return buf; } switch(tag.num){ @@ -2947,7 +2947,7 @@ tagdump(Tag tag) case UniversalString: return "UniversalString"; case BMPString: return "BMPString"; default: - snprint(buf, sizeof(buf), "Universal,num%d", tag.num); + jehanne_snprint(buf, sizeof(buf), "Universal,num%d", tag.num); return buf; } } @@ -2959,33 +2959,33 @@ edump(Elem e) Elist *el; int i; - print("%s{", tagdump(e.tag)); + jehanne_print("%s{", tagdump(e.tag)); v = e.val; switch(v.tag){ - case VBool: print("Bool %d",v.u.boolval); break; - case VInt: print("Int %d",v.u.intval); break; - case VOctets: print("Octets[%d] %.2x%.2x...",v.u.octetsval->len,v.u.octetsval->data[0],v.u.octetsval->data[1]); break; - case VBigInt: print("BigInt[%d] %.2x%.2x...",v.u.bigintval->len,v.u.bigintval->data[0],v.u.bigintval->data[1]); break; - case VReal: print("Real..."); break; - case VOther: print("Other..."); break; - case VBitString: print("BitString[%d]...", v.u.bitstringval->len*8 - v.u.bitstringval->unusedbits); break; - case VNull: print("Null"); break; - case VEOC: print("EOC..."); break; - case VObjId: print("ObjId"); + case VBool: jehanne_print("Bool %d",v.u.boolval); break; + case VInt: jehanne_print("Int %d",v.u.intval); break; + case VOctets: jehanne_print("Octets[%d] %.2x%.2x...",v.u.octetsval->len,v.u.octetsval->data[0],v.u.octetsval->data[1]); break; + case VBigInt: jehanne_print("BigInt[%d] %.2x%.2x...",v.u.bigintval->len,v.u.bigintval->data[0],v.u.bigintval->data[1]); break; + case VReal: jehanne_print("Real..."); break; + case VOther: jehanne_print("Other..."); break; + case VBitString: jehanne_print("BitString[%d]...", v.u.bitstringval->len*8 - v.u.bitstringval->unusedbits); break; + case VNull: jehanne_print("Null"); break; + case VEOC: jehanne_print("EOC..."); break; + case VObjId: jehanne_print("ObjId"); for(i = 0; ilen; i++) - print(" %d", v.u.objidval->data[i]); + jehanne_print(" %d", v.u.objidval->data[i]); break; - case VString: print("String \"%s\"",v.u.stringval); break; - case VSeq: print("Seq\n"); + case VString: jehanne_print("String \"%s\"",v.u.stringval); break; + case VSeq: jehanne_print("Seq\n"); for(el = v.u.seqval; el!=nil; el = el->tl) edump(el->hd); break; - case VSet: print("Set\n"); + case VSet: jehanne_print("Set\n"); for(el = v.u.setval; el!=nil; el = el->tl) edump(el->hd); break; } - print("}\n"); + jehanne_print("}\n"); } void @@ -2994,8 +2994,8 @@ asn1dump(uint8_t *der, int len) Elem e; if(decode(der, len, &e) != ASN_OK){ - print("didn't parse\n"); - exits("didn't parse"); + jehanne_print("didn't parse\n"); + jehanne_exits("didn't parse"); } edump(e); } @@ -3012,39 +3012,39 @@ X509dump(uint8_t *cert, int ncert) int digestlen; uint8_t digest[MAXdlen]; - print("begin X509dump\n"); + jehanne_print("begin X509dump\n"); b = makebytes(cert, ncert); c = decode_cert(b); if(c == nil){ freebytes(b); - print("cannot decode cert\n"); + jehanne_print("cannot decode cert\n"); return; } digestlen = digest_certinfo(b, digestalg[c->signature_alg], digest); freebytes(b); if(digestlen <= 0){ freecert(c); - print("cannot decode certinfo\n"); + jehanne_print("cannot decode certinfo\n"); return; } - print("serial %d\n", c->serial); - print("issuer %s\n", c->issuer); - print("validity %s %s\n", c->validity_start, c->validity_end); - print("subject %s\n", c->subject); - print("sigalg=%d digest=%.*H\n", c->signature_alg, digestlen, digest); - print("publickey_alg=%d pubkey[%d] %.*H\n", c->publickey_alg, c->publickey->len, + jehanne_print("serial %d\n", c->serial); + jehanne_print("issuer %s\n", c->issuer); + jehanne_print("validity %s %s\n", c->validity_start, c->validity_end); + jehanne_print("subject %s\n", c->subject); + jehanne_print("sigalg=%d digest=%.*H\n", c->signature_alg, digestlen, digest); + jehanne_print("publickey_alg=%d pubkey[%d] %.*H\n", c->publickey_alg, c->publickey->len, c->publickey->len, c->publickey->data); switch(c->publickey_alg){ case ALG_rsaEncryption: rsapub = decode_rsapubkey(c->publickey); if(rsapub != nil){ - print("rsa pubkey e=%B n(%d)=%B\n", rsapub->ek, mpsignif(rsapub->n), rsapub->n); + jehanne_print("rsa pubkey e=%B n(%d)=%B\n", rsapub->ek, mpsignif(rsapub->n), rsapub->n); e = X509rsaverifydigest(c->signature->data, c->signature->len, digest, digestlen, rsapub); if(e==nil) e = "nil (meaning ok)"; - print("self-signed X509rsaverifydigest returns: %s\n", e); + jehanne_print("self-signed X509rsaverifydigest returns: %s\n", e); rsapubfree(rsapub); } break; @@ -3055,12 +3055,12 @@ X509dump(uint8_t *cert, int ncert) e = X509ecdsaverifydigest(c->signature->data, c->signature->len, digest, digestlen, &ecdom, ecpub); if(e==nil) e = "nil (meaning ok)"; - print("self-signed X509ecdsaverifydigest returns: %s\n", e); + jehanne_print("self-signed X509ecdsaverifydigest returns: %s\n", e); ecpubfree(ecpub); } ecdomfree(&ecdom); break; } freecert(c); - print("end X509dump\n"); + jehanne_print("end X509dump\n"); } diff --git a/sys/src/lib/stdio/dtoa.c b/sys/src/lib/stdio/dtoa.c index 6b13982..d379a8c 100644 --- a/sys/src/lib/stdio/dtoa.c +++ b/sys/src/lib/stdio/dtoa.c @@ -17,11 +17,11 @@ * printed as %.17g. Then atof(s) is exactly y. */ #include -#include +#include static Lock _dtoalk[2]; -#define ACQUIRE_DTOA_LOCK(n) lock(&_dtoalk[n]) -#define FREE_DTOA_LOCK(n) unlock(&_dtoalk[n]) +#define ACQUIRE_DTOA_LOCK(n) jehanne_lock(&_dtoalk[n]) +#define FREE_DTOA_LOCK(n) jehanne_unlock(&_dtoalk[n]) #define PRIVATE_mem ((2000+sizeof(double)-1)/sizeof(double)) static double private_mem[PRIVATE_mem], *pmem_next = private_mem; diff --git a/sys/src/lib/stdio/iolib.h b/sys/src/lib/stdio/iolib.h index d46bb8e..a3b62b7 100644 --- a/sys/src/lib/stdio/iolib.h +++ b/sys/src/lib/stdio/iolib.h @@ -26,7 +26,7 @@ * (But plan9 version omits remove and rename, because they are in libc) */ #include -#include +#include #undef END #include "Stdio.h" /* diff --git a/sys/src/lib/thread/channel.c b/sys/src/lib/thread/channel.c index 32d7424..cfe09e0 100644 --- a/sys/src/lib/thread/channel.c +++ b/sys/src/lib/thread/channel.c @@ -45,17 +45,17 @@ _chanfree(Channel *c) c->freed = 1; else{ if(c->qentry) - free(c->qentry); - free(c); + jehanne_free(c->qentry); + jehanne_free(c); } } void chanfree(Channel *c) { - lock(&chanlock); + jehanne_lock(&chanlock); _chanfree(c); - unlock(&chanlock); + jehanne_unlock(&chanlock); } int @@ -114,7 +114,7 @@ alt(Alt *alts) if(t->moribund || _threadexitsallstatus) yield(); /* won't return */ s = _procsplhi(); - lock(&chanlock); + jehanne_lock(&chanlock); t->alt = alts; t->chan = Chanalt; @@ -129,14 +129,14 @@ alt(Alt *alts) c = xa->c; if(c==nil){ - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); t->chan = Channone; return -1; } if(isopenfor((Channel*)c, xa->op) && canexec(xa)) - if(nrand(++n) == 0) + if(jehanne_nrand(++n) == 0) a = xa; } @@ -144,7 +144,7 @@ alt(Alt *alts) if(a==nil){ /* nothing can proceed */ if(xa->op == CHANNOBLK){ - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); t->chan = Channone; if(xa->op == CHANNOBLK) @@ -171,13 +171,13 @@ alt(Alt *alts) if(ca != nil){ /* everything was closed, select last channel */ ca->err = errcl; - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); t->chan = Channone; return ca - alts; } else if(allreadycl){ /* everything was already closed */ - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); t->chan = Channone; return -1; @@ -192,11 +192,11 @@ alt(Alt *alts) * and we flag an error for the entry. */ Again: - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); r = _threadrendezvous(&c, 0); s = _procsplhi(); - lock(&chanlock); + jehanne_lock(&chanlock); if(r==Intred){ /* interrupted */ if(c!=nil) /* someone will meet us; go back */ @@ -217,7 +217,7 @@ alt(Alt *alts) } dequeue(xa); } - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); if(a == nil){ /* we were interrupted */ assert(c==(Channel*)~0); @@ -237,10 +237,10 @@ chanclose(Channel *c) int i, s; s = _procsplhi(); /* note handlers; see :/^alt */ - lock(&chanlock); + jehanne_lock(&chanlock); if(c->closed){ /* Already close; we fail but it's ok. don't print */ - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); return -1; } @@ -261,18 +261,18 @@ chanclose(Channel *c) if(a->op != CHANSND && (a->op != CHANRCV || c->n != 0)) continue; *a->tag = c; - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); while(_threadrendezvous(a->tag, Closed) == Intred) ; s = _procsplhi(); - lock(&chanlock); + jehanne_lock(&chanlock); } c->closed = 2; /* Fully closed */ if(c->freed) _chanfree(c); - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); return 0; } @@ -283,12 +283,12 @@ chanclosing(Channel *c) int n, s; s = _procsplhi(); /* note handlers; see :/^alt */ - lock(&chanlock); + jehanne_lock(&chanlock); if(c->closed == 0) n = -1; else n = c->n; - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(s); return n; } @@ -334,7 +334,7 @@ runop(int op, Channel *c, void *v, int nb) return -1; return 1; default: - fprint(2, "ERROR: channel alt returned %d\n", r); + jehanne_fprint(2, "ERROR: channel alt returned %d\n", r); abort(); return -1; } @@ -368,7 +368,7 @@ static void channelsize(Channel *c, int sz) { if(c->e != sz){ - fprint(2, "expected channel with elements of size %d, got size %d\n", + jehanne_fprint(2, "expected channel with elements of size %d, got size %d\n", sz, c->e); abort(); } @@ -459,10 +459,10 @@ emptyentry(Channel *c) extra = 16; c->nentry += extra; - c->qentry = realloc((void*)c->qentry, c->nentry*sizeof(c->qentry[0])); + c->qentry = jehanne_realloc((void*)c->qentry, c->nentry*sizeof(c->qentry[0])); if(c->qentry == nil) - sysfatal("realloc channel entries: %r"); - memset(&c->qentry[i], 0, extra*sizeof(c->qentry[0])); + jehanne_sysfatal("realloc channel entries: %r"); + jehanne_memset(&c->qentry[i], 0, extra*sizeof(c->qentry[0])); return i; } @@ -553,9 +553,9 @@ altcopy(void *dst, void *src, int sz) { if(dst){ if(src) - memmove(dst, src, sz); + jehanne_memmove(dst, src, sz); else - memset(dst, 0, sz); + jehanne_memset(dst, 0, sz); } } @@ -576,7 +576,7 @@ altexec(Alt *a, int spl) me = a->v; for(i=0; inentry; i++) if(c->qentry[i] && c->qentry[i]->op==otherop && *c->qentry[i]->tag==nil) - if(nrand(++n) == 0) + if(jehanne_nrand(++n) == 0) b = c->qentry[i]; if(b != nil){ _threaddebug(DBGCHAN, "rendez %s alt %p chan %p alt %p", a->op==CHANRCV?"recv":"send", a, c, b); @@ -604,7 +604,7 @@ altexec(Alt *a, int spl) } *b->tag = c; /* commits us to rendezvous */ _threaddebug(DBGCHAN, "unlocking the chanlock"); - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(spl); _threaddebug(DBGCHAN, "chanlock is %lud", *(uint32_t*)&chanlock); @@ -619,7 +619,7 @@ altexec(Alt *a, int spl) else altcopy(buf, me, c->e); - unlock(&chanlock); + jehanne_unlock(&chanlock); _procsplx(spl); return 1; } diff --git a/sys/src/lib/thread/chanprint.c b/sys/src/lib/thread/chanprint.c index 1994e48..deb59d6 100644 --- a/sys/src/lib/thread/chanprint.c +++ b/sys/src/lib/thread/chanprint.c @@ -19,10 +19,10 @@ chanprint(Channel *c, char *fmt, ...) int n; va_start(arg, fmt); - p = vsmprint(fmt, arg); + p = jehanne_vsmprint(fmt, arg); va_end(arg); if(p == nil) - sysfatal("vsmprint failed: %r"); + jehanne_sysfatal("vsmprint failed: %r"); n = sendp(c, p); yield(); /* let recipient handle message immediately */ return n; diff --git a/sys/src/lib/thread/create.c b/sys/src/lib/thread/create.c index d43cbbc..bb295c9 100644 --- a/sys/src/lib/thread/create.c +++ b/sys/src/lib/thread/create.c @@ -21,9 +21,9 @@ nextID(void) static int id; int i; - lock(&l); + jehanne_lock(&l); i = ++id; - unlock(&l); + jehanne_unlock(&l); return i; } @@ -38,21 +38,21 @@ newthread(Proc *p, void (*f)(void *arg), void *arg, uint32_t stacksize, Thread *t; if(stacksize < 32) - sysfatal("bad stacksize %d", stacksize); + jehanne_sysfatal("bad stacksize %d", stacksize); t = _threadmalloc(sizeof(Thread), 1); t->stksize = stacksize; t->stk = _threadmalloc(stacksize, 0); - memset(t->stk, 0xFE, stacksize); + jehanne_memset(t->stk, 0xFE, stacksize); _threadinitstack(t, f, arg); t->grp = grp; if(name) - t->cmdname = strdup(name); + t->cmdname = jehanne_strdup(name); t->id = nextID(); id = t->id; t->next = (Thread*)~0; t->proc = p; _threaddebug(DBGSCHED, "create thread %d.%d name %s", p->pid, t->id, name); - lock(&p->lock); + jehanne_lock(&p->lock); p->nthreads++; if(p->threads.head == nil) p->threads.head = t; @@ -62,7 +62,7 @@ newthread(Proc *p, void (*f)(void *arg), void *arg, uint32_t stacksize, t->nextt = nil; t->state = Ready; _threadready(t); - unlock(&p->lock); + jehanne_unlock(&p->lock); return id; } @@ -91,13 +91,13 @@ _newproc(void (*f)(void *arg), void *arg, uint32_t stacksize, char *name, p->rforkflag = rforkflag; newthread(p, f, arg, stacksize, name, grp); - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); if(_threadpq.head == nil) _threadpq.head = p; else *_threadpq.tail = p; _threadpq.tail = &p->next; - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); return p; } @@ -128,13 +128,13 @@ _freeproc(Proc *p) for(t = p->threads.head; t; t = nextt){ if(t->cmdname) - free(t->cmdname); + jehanne_free(t->cmdname); assert(t->stk != nil); - free(t->stk); + jehanne_free(t->stk); nextt = t->nextt; - free(t); + jehanne_free(t); } - free(p); + jehanne_free(p); } void @@ -144,7 +144,7 @@ _freethread(Thread *t) Thread **l; p = t->proc; - lock(&p->lock); + jehanne_lock(&p->lock); for(l=&p->threads.head; *l; l=&(*l)->nextt){ if(*l == t){ *l = t->nextt; @@ -153,11 +153,11 @@ _freethread(Thread *t) break; } } - unlock(&p->lock); + jehanne_unlock(&p->lock); if (t->cmdname) - free(t->cmdname); + jehanne_free(t->cmdname); assert(t->stk != nil); - free(t->stk); - free(t); + jehanne_free(t->stk); + jehanne_free(t); } diff --git a/sys/src/lib/thread/debug.c b/sys/src/lib/thread/debug.c index fb9f8d1..27b46e8 100644 --- a/sys/src/lib/thread/debug.c +++ b/sys/src/lib/thread/debug.c @@ -25,21 +25,21 @@ _threaddebug(uint32_t flag, char *fmt, ...) if((_threaddebuglevel&flag) == 0) return; - fmtfdinit(&f, 2, buf, sizeof buf); + jehanne_fmtfdinit(&f, 2, buf, sizeof buf); p = _threadgetproc(); if(p==nil) - fmtprint(&f, "noproc "); + jehanne_fmtprint(&f, "noproc "); else if(p->thread) - fmtprint(&f, "%d.%d ", p->pid, p->thread->id); + jehanne_fmtprint(&f, "%d.%d ", p->pid, p->thread->id); else - fmtprint(&f, "%d._ ", p->pid); + jehanne_fmtprint(&f, "%d._ ", p->pid); va_start(arg, fmt); - fmtvprint(&f, fmt, arg); + jehanne_fmtvprint(&f, fmt, arg); va_end(arg); - fmtprint(&f, "\n"); - fmtfdflush(&f); + jehanne_fmtprint(&f, "\n"); + jehanne_fmtfdflush(&f); } void @@ -51,10 +51,10 @@ _threadassert(char *s) p = _threadgetproc(); if(p && p->thread) - n = sprint(buf, "%d.%d ", p->pid, p->thread->id); + n = jehanne_sprint(buf, "%d.%d ", p->pid, p->thread->id); else n = 0; - snprint(buf+n, sizeof(buf)-n, "%s: assertion failed at %#p\n", s, getcallerpc()); - write(2, buf, strlen(buf)); + jehanne_snprint(buf+n, sizeof(buf)-n, "%s: assertion failed at %#p\n", s, jehanne_getcallerpc()); + write(2, buf, jehanne_strlen(buf)); abort(); } diff --git a/sys/src/lib/thread/dial.c b/sys/src/lib/thread/dial.c index ce93259..ae73e12 100644 --- a/sys/src/lib/thread/dial.c +++ b/sys/src/lib/thread/dial.c @@ -63,8 +63,8 @@ _threaddial(const char *dest, const char *local, char *dir, int *cfdp) return rv; err[0] = '\0'; errstr(err, sizeof err); - if(strstr(err, "refused") != 0){ - werrstr("%s", err); + if(jehanne_strstr(err, "refused") != 0){ + jehanne_werrstr("%s", err); return rv; } ds.netdir = "/net.alt"; @@ -74,10 +74,10 @@ _threaddial(const char *dest, const char *local, char *dir, int *cfdp) alterr[0] = 0; errstr(alterr, sizeof alterr); - if(strstr(alterr, "translate") || strstr(alterr, "does not exist")) - werrstr("%s", err); + if(jehanne_strstr(alterr, "translate") || jehanne_strstr(alterr, "does not exist")) + jehanne_werrstr("%s", err); else - werrstr("%s", alterr); + jehanne_werrstr("%s", alterr); return rv; } @@ -90,19 +90,19 @@ csdial(DS *ds) /* * open connection server */ - snprint(buf, sizeof(buf), "%s/cs", ds->netdir); + jehanne_snprint(buf, sizeof(buf), "%s/cs", ds->netdir); fd = open(buf, ORDWR); if(fd < 0){ /* no connection server, don't translate */ - snprint(clone, sizeof(clone), "%s/%s/clone", ds->netdir, ds->proto); + jehanne_snprint(clone, sizeof(clone), "%s/%s/clone", ds->netdir, ds->proto); return call(clone, ds->rem, ds); } /* * ask connection server to translate */ - snprint(buf, sizeof(buf), "%s!%s", ds->proto, ds->rem); - if(write(fd, buf, strlen(buf)) < 0){ + jehanne_snprint(buf, sizeof(buf), "%s!%s", ds->proto, ds->rem); + if(write(fd, buf, jehanne_strlen(buf)) < 0){ close(fd); return -1; } @@ -116,7 +116,7 @@ csdial(DS *ds) seek(fd, 0, 0); while((n = read(fd, buf, sizeof(buf) - 1)) > 0){ buf[n] = 0; - p = strchr(buf, ' '); + p = jehanne_strchr(buf, ' '); if(p == 0) continue; *p++ = 0; @@ -125,15 +125,15 @@ csdial(DS *ds) break; err[0] = '\0'; errstr(err, sizeof err); - if(strstr(err, "does not exist") == 0) - strcpy(besterr, err); + if(jehanne_strstr(err, "does not exist") == 0) + jehanne_strcpy(besterr, err); } close(fd); if(rv < 0 && *besterr) - werrstr("%s", besterr); + jehanne_werrstr("%s", besterr); else - werrstr("%s", err); + jehanne_werrstr("%s", err); return rv; } @@ -145,14 +145,14 @@ call(char *clone, char *dest, DS *ds) /* because cs is in a different name space, replace the mount point */ if(*clone == '/'){ - p = strchr(clone+1, '/'); + p = jehanne_strchr(clone+1, '/'); if(p == nil) p = clone; else p++; } else p = clone; - snprint(cname, sizeof cname, "%s/%s", ds->netdir, p); + jehanne_snprint(cname, sizeof cname, "%s/%s", ds->netdir, p); cfd = open(cname, ORDWR); if(cfd < 0) @@ -167,19 +167,19 @@ call(char *clone, char *dest, DS *ds) name[n] = 0; for(p = name; *p == ' '; p++) ; - snprint(name, sizeof(name), "%ld", strtoul(p, 0, 0)); - p = strrchr(cname, '/'); + jehanne_snprint(name, sizeof(name), "%ld", jehanne_strtoul(p, 0, 0)); + p = jehanne_strrchr(cname, '/'); *p = 0; if(ds->dir) - snprint(ds->dir, NETPATHLEN, "%s/%s", cname, name); - snprint(data, sizeof(data), "%s/%s/data", cname, name); + jehanne_snprint(ds->dir, NETPATHLEN, "%s/%s", cname, name); + jehanne_snprint(data, sizeof(data), "%s/%s/data", cname, name); /* connect */ if(ds->local) - snprint(name, sizeof(name), "connect %s %s", dest, ds->local); + jehanne_snprint(name, sizeof(name), "connect %s %s", dest, ds->local); else - snprint(name, sizeof(name), "connect %s", dest); - if(write(cfd, name, strlen(name)) < 0){ + jehanne_snprint(name, sizeof(name), "connect %s", dest); + if(write(cfd, name, jehanne_strlen(name)) < 0){ close(cfd); return -1; } @@ -205,10 +205,10 @@ _dial_string_parse(const char *str, DS *ds) { char *p, *p2; - strncpy(ds->buf, str, Maxstring); + jehanne_strncpy(ds->buf, str, Maxstring); ds->buf[Maxstring-1] = 0; - p = strchr(ds->buf, '!'); + p = jehanne_strchr(ds->buf, '!'); if(p == 0) { ds->netdir = 0; ds->proto = "net"; diff --git a/sys/src/lib/thread/example.c b/sys/src/lib/thread/example.c index d2ff5e9..2a02fd9 100644 --- a/sys/src/lib/thread/example.c +++ b/sys/src/lib/thread/example.c @@ -35,12 +35,12 @@ mouseproc(void *arg) mc = arg; if((mfd = open("/dev/mouse", OREAD)) < 0) - sysfatal("open /dev/mouse: %r"); + jehanne_sysfatal("open /dev/mouse: %r"); for(;;){ if(read(mfd, m, sizeof m) != sizeof m) - sysfatal("eof"); - if(atoi(m+1+2*12)&4) - sysfatal("button 3"); + jehanne_sysfatal("eof"); + if(jehanne_atoi(m+1+2*12)&4) + jehanne_sysfatal("button 3"); send(mc, m); } } @@ -53,7 +53,7 @@ clockproc(void *arg) c = arg; for(t=0;; t++){ - sleep(1000); + jehanne_sleep(1000); sendul(c, t); } } @@ -82,13 +82,13 @@ threadmain(int argc, char *argv[]) for(;;){ switch(alt(a)){ case 0: /*mouse event */ - fprint(2, "click "); + jehanne_fprint(2, "click "); break; case 1: /* clock event */ - fprint(2, "tic "); + jehanne_fprint(2, "tic "); break; default: - sysfatal("can't happen"); + jehanne_sysfatal("can't happen"); } } } diff --git a/sys/src/lib/thread/exec.c b/sys/src/lib/thread/exec.c index 3c81245..9267ea5 100644 --- a/sys/src/lib/thread/exec.c +++ b/sys/src/lib/thread/exec.c @@ -26,7 +26,7 @@ procexec(Channel *pidc, char *prog, char *args[]) p = _threadgetproc(); t = p->thread; if(p->threads.head != t || p->threads.head->nextt != nil){ - werrstr("not only thread in proc"); + jehanne_werrstr("not only thread in proc"); Bad: if(pidc) sendul(pidc, ~0); @@ -95,7 +95,7 @@ procexecl(Channel *pidc, char *f, ...) while((arg = va_arg(va, char *)) != nil) n++; - char **args = malloc(sizeof(char*)*(n+1)); + char **args = jehanne_malloc(sizeof(char*)*(n+1)); n = 0; while((arg = va_arg(va2, char *)) != nil) diff --git a/sys/src/lib/thread/exit.c b/sys/src/lib/thread/exit.c index 893fd21..14c2908 100644 --- a/sys/src/lib/thread/exit.c +++ b/sys/src/lib/thread/exit.c @@ -26,7 +26,7 @@ threadexits(char *exitstr) t->moribund = 1; if(exitstr==nil) exitstr=""; - utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr); + jehanne_utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr); _sched(); } @@ -41,7 +41,7 @@ threadexitsall(char *exitstr) exitstr = ""; _threadexitsallstatus = exitstr; _threaddebug(DBGSCHED, "_threadexitsallstatus set to %p", _threadexitsallstatus); - mypid = getpid(); + mypid = jehanne_getpid(); /* * signal others. @@ -52,7 +52,7 @@ threadexitsall(char *exitstr) * call threadexitsall... */ for(;;){ - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); npid = 0; for(p = _threadpq.head; p && npid < nelem(pid); p=p->next){ if(p->threadint == 0 && p->pid != mypid){ @@ -60,15 +60,15 @@ threadexitsall(char *exitstr) p->threadint = 1; } } - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); if(npid == 0) break; for(i=0; ipid; - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); for (p = _threadpq.head; p; p = p->next){ - lock(&p->lock); + jehanne_lock(&p->lock); for (t = p->threads.head; t; t = t->nextt) if (t->id == id){ pid = p->pid; - unlock(&p->lock); - unlock(&_threadpq.lock); + jehanne_unlock(&p->lock); + jehanne_unlock(&_threadpq.lock); return pid; } - unlock(&p->lock); + jehanne_unlock(&p->lock); } - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); return -1; } @@ -75,14 +75,14 @@ threadsetname(char *fmt, ...) p = _threadgetproc(); t = p->thread; if (t->cmdname) - free(t->cmdname); + jehanne_free(t->cmdname); va_start(arg, fmt); - t->cmdname = vsmprint(fmt, arg); + t->cmdname = jehanne_vsmprint(fmt, arg); va_end(arg); if(t->cmdname && p->nthreads == 1){ - snprint(buf, sizeof buf, "#p/%lud/args", getpid()); + jehanne_snprint(buf, sizeof buf, "#p/%lud/args", jehanne_getpid()); if((fd = open(buf, OWRITE)) >= 0){ - write(fd, t->cmdname, strlen(t->cmdname)+1); + write(fd, t->cmdname, jehanne_strlen(t->cmdname)+1); close(fd); } } @@ -124,14 +124,14 @@ tprivalloc(void) { int i; - lock(&privlock); + jehanne_lock(&privlock); for(i=0; i= NPRIV) abort(); - lock(&privlock); + jehanne_lock(&privlock); privmask &= ~(1<c, &io) == -1){ - werrstr("interrupted"); + jehanne_werrstr("interrupted"); return -1; } assert(!io->inuse); @@ -33,7 +33,7 @@ iocall(Ioproc *io, int32_t (*op)(va_list*), ...) inted = 1; } if(inted){ - werrstr("interrupted"); + jehanne_werrstr("interrupted"); return -1; } diff --git a/sys/src/lib/thread/iodial.c b/sys/src/lib/thread/iodial.c index 745b87c..501ee1f 100644 --- a/sys/src/lib/thread/iodial.c +++ b/sys/src/lib/thread/iodial.c @@ -23,7 +23,7 @@ _iodial(va_list *arg) dir = va_arg(*arg, char*); cdfp = va_arg(*arg, int*); - return dial(addr, local, dir, cdfp); + return jehanne_dial(addr, local, dir, cdfp); } int diff --git a/sys/src/lib/thread/ioproc.c b/sys/src/lib/thread/ioproc.c index 02db7a5..90bb5c2 100644 --- a/sys/src/lib/thread/ioproc.c +++ b/sys/src/lib/thread/ioproc.c @@ -50,7 +50,7 @@ xioproc(void *a) io->ret = io->op(&io->arg); if(io->ret < 0) - rerrstr(io->err, sizeof io->err); + jehanne_rerrstr(io->err, sizeof io->err); while(send(io->creply, &io) == -1) ; while(recv(io->creply, &x) == -1) @@ -63,9 +63,9 @@ ioproc(void) { Ioproc *io; - io = mallocz(sizeof(*io), 1); + io = jehanne_mallocz(sizeof(*io), 1); if(io == nil) - sysfatal("ioproc malloc: %r"); + jehanne_sysfatal("ioproc malloc: %r"); io->c = chancreate(sizeof(void*), 0); io->creply = chancreate(sizeof(void*), 0); io->tid = proccreate(xioproc, io, STACK); @@ -82,5 +82,5 @@ closeioproc(Ioproc *io) ; chanfree(io->c); chanfree(io->creply); - free(io); + jehanne_free(io); } diff --git a/sys/src/lib/thread/ioreadn.c b/sys/src/lib/thread/ioreadn.c index b38bbb7..853e256 100644 --- a/sys/src/lib/thread/ioreadn.c +++ b/sys/src/lib/thread/ioreadn.c @@ -22,7 +22,7 @@ _ioreadn(va_list *arg) fd = va_arg(*arg, int); a = va_arg(*arg, void*); n = va_arg(*arg, int32_t); - return readn(fd, a, n); + return jehanne_readn(fd, a, n); } int32_t diff --git a/sys/src/lib/thread/iosleep.c b/sys/src/lib/thread/iosleep.c index 8ed5fd0..40b2131 100644 --- a/sys/src/lib/thread/iosleep.c +++ b/sys/src/lib/thread/iosleep.c @@ -18,7 +18,7 @@ _iosleep(va_list *arg) int32_t n; n = va_arg(*arg, int32_t); - sleep(n); + jehanne_sleep(n); return 0; } diff --git a/sys/src/lib/thread/kill.c b/sys/src/lib/thread/kill.c index fe2d470..7b4a242 100644 --- a/sys/src/lib/thread/kill.c +++ b/sys/src/lib/thread/kill.c @@ -20,18 +20,18 @@ threadxxxgrp(int grp, int dokill) Proc *p; Thread *t; - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); for(p=_threadpq.head; p; p=p->next){ - lock(&p->lock); + jehanne_lock(&p->lock); for(t=p->threads.head; t; t=t->nextt) if(t->grp == grp){ if(dokill) t->moribund = 1; tinterrupt(p, t); } - unlock(&p->lock); + jehanne_unlock(&p->lock); } - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); _threadbreakrendez(); } @@ -41,22 +41,22 @@ threadxxx(int id, int dokill) Proc *p; Thread *t; - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); for(p=_threadpq.head; p; p=p->next){ - lock(&p->lock); + jehanne_lock(&p->lock); for(t=p->threads.head; t; t=t->nextt) if(t->id == id){ if(dokill) t->moribund = 1; tinterrupt(p, t); - unlock(&p->lock); - unlock(&_threadpq.lock); + jehanne_unlock(&p->lock); + jehanne_unlock(&_threadpq.lock); _threadbreakrendez(); return; } - unlock(&p->lock); + jehanne_unlock(&p->lock); } - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); _threaddebug(DBGNOTE, "Can't find thread to kill"); return; } @@ -90,7 +90,7 @@ tinterrupt(Proc *p, Thread *t) { switch(t->state){ case Running: - postnote(PNPROC, p->pid, "threadint"); + jehanne_postnote(PNPROC, p->pid, "threadint"); break; case Rendezvous: _threadflagrendez(t); diff --git a/sys/src/lib/thread/lib.c b/sys/src/lib/thread/lib.c index 6d8d692..6a32de2 100644 --- a/sys/src/lib/thread/lib.c +++ b/sys/src/lib/thread/lib.c @@ -19,17 +19,17 @@ _threadmalloc(int32_t size, int z) { void *m; - m = malloc(size); + m = jehanne_malloc(size); if (m == nil) - sysfatal("Malloc of size %ld failed: %r", size); - setmalloctag(m, getcallerpc()); + jehanne_sysfatal("Malloc of size %ld failed: %r", size); + jehanne_setmalloctag(m, jehanne_getcallerpc()); totalmalloc += size; if (size > 100000000) { - fprint(2, "Malloc of size %ld, total %ld\n", size, totalmalloc); + jehanne_fprint(2, "Malloc of size %ld, total %ld\n", size, totalmalloc); abort(); } if (z) - memset(m, 0, size); + jehanne_memset(m, 0, size); return m; } @@ -40,11 +40,11 @@ _threadsysfatal(char *fmt, ...) char buf[1024]; /* size doesn't matter; we're about to exit */ va_start(arg, fmt); - vseprint(buf, buf+sizeof(buf), fmt, arg); + jehanne_vseprint(buf, buf+sizeof(buf), fmt, arg); va_end(arg); if(argv0) - fprint(2, "%s: %s\n", argv0, buf); + jehanne_fprint(2, "%s: %s\n", argv0, buf); else - fprint(2, "%s\n", buf); + jehanne_fprint(2, "%s\n", buf); threadexitsall(buf); } diff --git a/sys/src/lib/thread/main.c b/sys/src/lib/thread/main.c index ccd997d..c6a86be 100644 --- a/sys/src/lib/thread/main.c +++ b/sys/src/lib/thread/main.c @@ -40,12 +40,12 @@ main(int argc, char **argv) rfork(RFREND); mainp = &p; - if(setjmp(_mainjmp)) + if(jehanne_setjmp(_mainjmp)) _schedinit(p); //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0; _systhreadinit(); - _qlockinit(_threadrendezvous); + jehanne__qlockinit(_threadrendezvous); _sysfatal = _threadsysfatal; _dial = _threaddial; __assert = _threadassert; @@ -81,10 +81,10 @@ efork(Execargs *e) close(e->fd[0]); exec(e->prog, e->args); _threaddebug(DBGEXEC, "_schedexec failed: %r"); - rerrstr(buf, sizeof buf); + jehanne_rerrstr(buf, sizeof buf); if(buf[0]=='\0') - strcpy(buf, "exec failed"); - write(e->fd[1], buf, strlen(buf)); + jehanne_strcpy(buf, "exec failed"); + write(e->fd[1], buf, jehanne_strlen(buf)); close(e->fd[1]); _exits(buf); } @@ -110,7 +110,7 @@ _schedfork(Proc *p) switch(pid = rfork(RFPROC|RFMEM|RFNOWAIT|p->rforkflag)){ case 0: *mainp = p; /* write to stack, so local to proc */ - longjmp(_mainjmp, 1); + jehanne_longjmp(_mainjmp, 1); default: return pid; } @@ -122,7 +122,7 @@ _schedexit(Proc *p) char ex[ERRMAX]; Proc **l; - lock(&_threadpq.lock); + jehanne_lock(&_threadpq.lock); for(l=&_threadpq.head; *l; l=&(*l)->next){ if(*l == p){ *l = p->next; @@ -131,10 +131,10 @@ _schedexit(Proc *p) break; } } - unlock(&_threadpq.lock); + jehanne_unlock(&_threadpq.lock); - utfecpy(ex, ex+sizeof ex, p->exitstr); - free(p); + jehanne_utfecpy(ex, ex+sizeof ex, p->exitstr); + jehanne_free(p); _exits(ex); } @@ -154,18 +154,18 @@ _schedexecwait(void) rfork(RFCFDG); for(;;){ - w = wait(); + w = jehanne_wait(); if(w == nil) break; if(w->pid == pid) break; - free(w); + jehanne_free(w); } if(w != nil){ if((c = _threadwaitchan) != nil) sendp(c, w); else - free(w); + jehanne_free(w); } threadexits("procexec"); } @@ -175,7 +175,7 @@ static Proc **procp; void _systhreadinit(void) { - procp = (Proc **)privalloc(); + procp = (Proc **)jehanne_privalloc(); } Proc* diff --git a/sys/src/lib/thread/note.c b/sys/src/lib/thread/note.c index 4e5c24d..8d6a547 100644 --- a/sys/src/lib/thread/note.c +++ b/sys/src/lib/thread/note.c @@ -45,14 +45,14 @@ threadnotify(int (*f)(void*, char*), int in) to = nil; topid = 0; } - lock(&onnotelock); + jehanne_lock(&onnotelock); for(i=0; is, p); if(v != nil) noted(NDFLT); - else if(strncmp(n->s, "sys:", 4)==0) + else if(jehanne_strncmp(n->s, "sys:", 4)==0) abort(); threadexitsall(n->s); } n->proc = nil; - unlock(&n->inuse); + jehanne_unlock(&n->inuse); } } } @@ -96,7 +96,7 @@ _threadnote(void *v, char *s) Note *n; _threaddebug(DBGNOTE, "Got note %s", s); - if(strncmp(s, "sys:", 4) == 0) + if(jehanne_strncmp(s, "sys:", 4) == 0) noted(NDFLT); if(_threadexitsallstatus){ @@ -104,7 +104,7 @@ _threadnote(void *v, char *s) _exits(_threadexitsallstatus); } - if(strcmp(s, "threadint")==0) + if(jehanne_strcmp(s, "threadint")==0) noted(NCONT); p = _threadgetproc(); @@ -112,11 +112,11 @@ _threadnote(void *v, char *s) noted(NDFLT); for(n=notes; ninuse)) + if(jehanne_canlock(&n->inuse)) break; if(n==enotes) - sysfatal("libthread: too many delayed notes"); - utfecpy(n->s, n->s+ERRMAX, s); + jehanne_sysfatal("libthread: too many delayed notes"); + jehanne_utfecpy(n->s, n->s+ERRMAX, s); n->proc = p; p->pending = 1; if(!p->splhi) diff --git a/sys/src/lib/thread/ref.c b/sys/src/lib/thread/ref.c index 766d153..ef352fd 100644 --- a/sys/src/lib/thread/ref.c +++ b/sys/src/lib/thread/ref.c @@ -15,11 +15,11 @@ void incref(Ref *r) { - ainc(&r->ref); + jehanne_ainc(&r->ref); } int32_t decref(Ref *r) { - return adec(&r->ref); + return jehanne_adec(&r->ref); } diff --git a/sys/src/lib/thread/rendez.c b/sys/src/lib/thread/rendez.c index 3619055..ed1c5d2 100644 --- a/sys/src/lib/thread/rendez.c +++ b/sys/src/lib/thread/rendez.c @@ -23,13 +23,13 @@ finish(Thread *t, void *val) ret = t->rendval; t->rendval = val; while(t->state == Running) - sleep(0); - lock(&t->proc->lock); + jehanne_sleep(0); + jehanne_lock(&t->proc->lock); if(t->state == Rendezvous){ /* not always true: might be Dead */ t->state = Ready; _threadready(t); } - unlock(&t->proc->lock); + jehanne_unlock(&t->proc->lock); return ret; } @@ -39,14 +39,14 @@ _threadrendezvous(void *tag, void *val) void *ret; Thread *t, **l; - lock(&_threadrgrp.lock); + jehanne_lock(&_threadrgrp.lock); l = &_threadrgrp.hash[((uintptr_t)tag)%nelem(_threadrgrp.hash)]; for(t=*l; t; l=&t->rendhash, t=*l){ if(t->rendtag==tag){ _threaddebug(DBGREND, "Rendezvous with thread %d.%d", t->proc->pid, t->id); *l = t->rendhash; ret = finish(t, val); - unlock(&_threadrgrp.lock); + jehanne_unlock(&_threadrgrp.lock); return ret; } } @@ -61,7 +61,7 @@ _threadrendezvous(void *tag, void *val) *l = t; t->nextstate = Rendezvous; _threaddebug(DBGREND, "Rendezvous for tag %p", t->rendtag); - unlock(&_threadrgrp.lock); + jehanne_unlock(&_threadrgrp.lock); _sched(); t->inrendez = 0; _threaddebug(DBGREND, "Woke after rendezvous; val is %p", t->rendval); @@ -88,9 +88,9 @@ _threadbreakrendez(void) if(isdirty == 0) return; - lock(&_threadrgrp.lock); + jehanne_lock(&_threadrgrp.lock); if(isdirty == 0){ - unlock(&_threadrgrp.lock); + jehanne_unlock(&_threadrgrp.lock); return; } isdirty = 0; @@ -104,5 +104,5 @@ _threadbreakrendez(void) l=&t->rendhash; } } - unlock(&_threadrgrp.lock); + jehanne_unlock(&_threadrgrp.lock); } diff --git a/sys/src/lib/thread/sched.c b/sys/src/lib/thread/sched.c index 26facbf..af2cf1c 100644 --- a/sys/src/lib/thread/sched.c +++ b/sys/src/lib/thread/sched.c @@ -40,13 +40,13 @@ _schedinit(void *arg) p = arg; _threadsetproc(p); - p->pid = getpid(); - while(setjmp(p->sched)) + p->pid = jehanne_getpid(); + while(jehanne_setjmp(p->sched)) ; _threaddebug(DBGSCHED, "top of schedinit, _threadexitsallstatus=%p", _threadexitsallstatus); if(_threadexitsallstatus) - exits(_threadexitsallstatus); - lock(&p->lock); + jehanne_exits(_threadexitsallstatus); + jehanne_lock(&p->lock); if((t=p->thread) != nil){ p->thread = nil; if(t->moribund){ @@ -59,14 +59,14 @@ _schedinit(void *arg) p->nthreads--; break; } - unlock(&p->lock); + jehanne_unlock(&p->lock); if(t->inrendez){ _threadflagrendez(t); _threadbreakrendez(); } - free(t->stk); - free(t->cmdname); - free(t); /* XXX how do we know there are no references? */ + jehanne_free(t->stk); + jehanne_free(t->cmdname); + jehanne_free(t); /* XXX how do we know there are no references? */ t = nil; _sched(); } @@ -82,7 +82,7 @@ _schedinit(void *arg) if(t->state == Ready) _threadready(t); } - unlock(&p->lock); + jehanne_unlock(&p->lock); _sched(); } @@ -97,9 +97,9 @@ needstack(int n) t = p->thread; if((uint8_t*)&x - n < (uint8_t*)t->stk){ - fprint(2, "%s %lud: &x=%p n=%d t->stk=%p\n", - argv0, getpid(), &x, n, t->stk); - fprint(2, "%s %lud: stack overflow\n", argv0, getmainpid()); + jehanne_fprint(2, "%s %lud: &x=%p n=%d t->stk=%p\n", + argv0, jehanne_getpid(), &x, n, t->stk); + jehanne_fprint(2, "%s %lud: stack overflow\n", argv0, jehanne_getmainpid()); abort(); } } @@ -115,8 +115,8 @@ Resched: if((t = p->thread) != nil){ needstack(128); _threaddebug(DBGSCHED, "pausing, state=%s", psstate(t->state)); - if(setjmp(t->sched)==0) - longjmp(p->sched, 1); + if(jehanne_setjmp(t->sched)==0) + jehanne_longjmp(p->sched, 1); return; }else{ t = runthread(p); @@ -132,7 +132,7 @@ Resched: } t->state = Running; t->nextstate = Ready; - longjmp(t->sched, 1); + jehanne_longjmp(t->sched, 1); } } @@ -145,20 +145,20 @@ runthread(Proc *p) if(p->nthreads==0) return nil; q = &p->ready; - lock(&p->readylock); + jehanne_lock(&p->readylock); if(q->head == nil){ q->asleep = 1; _threaddebug(DBGSCHED, "sleeping for more work"); - unlock(&p->readylock); + jehanne_unlock(&p->readylock); while(rendezvous(q, 0) == (void*)~0){ if(_threadexitsallstatus) - exits(_threadexitsallstatus); + jehanne_exits(_threadexitsallstatus); } /* lock picked up from _threadready */ } t = q->head; q->head = t->next; - unlock(&p->readylock); + jehanne_unlock(&p->readylock); return t; } @@ -170,7 +170,7 @@ _threadready(Thread *t) assert(t->state == Ready); _threaddebug(DBGSCHED, "readying %d.%d", t->proc->pid, t->id); q = &t->proc->ready; - lock(&t->proc->readylock); + jehanne_lock(&t->proc->readylock); t->next = nil; if(q->head==nil) q->head = t; @@ -183,10 +183,10 @@ _threadready(Thread *t) _threaddebug(DBGSCHED, "waking process %d", t->proc->pid); while(rendezvous(q, 0) == (void*)~0){ if(_threadexitsallstatus) - exits(_threadexitsallstatus); + jehanne_exits(_threadexitsallstatus); } }else - unlock(&t->proc->readylock); + jehanne_unlock(&t->proc->readylock); } void diff --git a/sys/src/lib/thread/test.c b/sys/src/lib/thread/test.c index 8c9aedd..51c740e 100644 --- a/sys/src/lib/thread/test.c +++ b/sys/src/lib/thread/test.c @@ -13,11 +13,11 @@ void printabcd(int a, int b, int c, int d) { - print("%d %d %d %d\n", a, b, c, d); + jehanne_print("%d %d %d %d\n", a, b, c, d); } void main(int argc, char **argv) { - printabcd(atoi(argv[0]), atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); + printabcd(jehanne_atoi(argv[0]), jehanne_atoi(argv[1]), jehanne_atoi(argv[2]), jehanne_atoi(argv[3])); } diff --git a/sys/src/lib/thread/tprimes.c b/sys/src/lib/thread/tprimes.c index a221882..aff2072 100644 --- a/sys/src/lib/thread/tprimes.c +++ b/sys/src/lib/thread/tprimes.c @@ -27,7 +27,7 @@ primethread(void *arg) if(p > goal) threadexitsall(nil); if(!quiet) - print("%d\n", p); + jehanne_print("%d\n", p); nc = chancreate(sizeof(ulong), buffer); (*fn)(primethread, nc, 1024); for(;;){ @@ -48,7 +48,7 @@ threadmain(int argc, char **argv) quiet = 1; break; case 'b': - buffer = atoi(ARGF()); + buffer = jehanne_atoi(ARGF()); break; case 'p': fn=proccreate; @@ -56,7 +56,7 @@ threadmain(int argc, char **argv) }ARGEND if(argc>0) - goal = atoi(argv[0]); + goal = jehanne_atoi(argv[0]); else goal = 100;