History

20121205-1740

forsyth committed 13 years ago

Commit 63a80ccNo parent (first commit)9462 files · +1777217 −-3784Browse files

Unified · Split

1063 files
  1. CHANGES +931 −0
  2. DragonFly/386/bin/.dreg +0 −0
  3. DragonFly/386/include/emu.h +30 −0
  4. DragonFly/386/include/fpuctl.h +76 −0
  5. DragonFly/386/include/lib9.h +472 −0
  6. DragonFly/386/lib/.dreg +0 −0
  7. FreeBSD/386/bin/data2c +0 −0
  8. FreeBSD/386/bin/iyacc +0 −0
  9. FreeBSD/386/bin/mk +0 −0
  10. FreeBSD/386/bin/mkext +0 −0
  11. FreeBSD/386/include/emu.h +30 −0
  12. FreeBSD/386/include/fpuctl.h +76 −0
  13. FreeBSD/386/include/lib9.h +473 −0
  14. Hp/s800/include/emu.h +21 −0
  15. INSTALL +86 −0
  16. Inferno/386/include/lib9.h +8 −0
  17. Inferno/386/include/u.h +64 −0
  18. Inferno/386/include/ureg.h +25 −0
  19. Inferno/arm/include/lib9.h +8 −0
  20. Inferno/arm/include/u.h +65 −0
  21. Inferno/arm/include/ureg.h +24 −0
  22. Inferno/mips/include/lib9.h +8 −0
  23. Inferno/mips/include/u.h +65 −0
  24. Inferno/power/include/lib9.h +4 −0
  25. Inferno/power/include/u.h +84 −0
  26. Inferno/power/include/ureg.h +43 −0
  27. Inferno/sparc/include/lib9.h +9 −0
  28. Inferno/sparc/include/u.h +64 −0
  29. Inferno/sparc/include/ureg.h +45 −0
  30. Inferno/spim/include/lib9.h +8 −0
  31. Inferno/spim/include/u.h +56 −0
  32. Inferno/thumb/include/lib9.h +8 −0
  33. Inferno/thumb/include/u.h +65 −0
  34. Inferno/thumb/include/ureg.h +24 −0
  35. Irix/mips/bin/awk +0 −0
  36. Irix/mips/bin/data2c +0 −0
  37. Irix/mips/bin/iyacc +0 −0
  38. Irix/mips/bin/mk +0 −0
  39. Irix/mips/bin/mkext +0 −0
  40. Irix/mips/include/emu.h +22 −0
  41. Irix/mips/include/lib9.h +454 −0
  42. Linux/386/bin/data2c +0 −0
  43. Linux/386/bin/iyacc +0 −0
  44. Linux/386/bin/mk +0 −0
  45. Linux/386/bin/mkext +0 −0
  46. Linux/386/include/emu.h +33 −0
  47. Linux/386/include/fpuctl.h +76 −0
  48. Linux/386/include/lib9.h +462 −0
  49. Linux/arm/include/emu.h +34 −0
  50. Linux/arm/include/fpuctl.h +52 −0
  51. Linux/arm/include/lib9.h +470 −0
  52. Linux/power/bin/data2c +0 −0
  53. Linux/power/bin/iyacc +0 −0
  54. Linux/power/bin/limbo +0 −0
  55. Linux/power/bin/mk +0 −0
  56. Linux/power/bin/mkext +0 −0
  57. Linux/power/include/emu.h +37 −0
  58. Linux/power/include/fpuctl.h +83 −0
  59. Linux/power/include/lib9.h +463 −0
  60. Linux/spim/include/emu.h +39 −0
  61. Linux/spim/include/fpuctl.h +65 −0
  62. Linux/spim/include/lib9.h +464 −0
  63. MacOSX/386/bin/data2c +0 −0
  64. MacOSX/386/bin/iyacc +0 −0
  65. MacOSX/386/bin/mk +0 −0
  66. MacOSX/386/bin/mkext +0 −0
  67. MacOSX/386/include/emu.h +34 −0
  68. MacOSX/386/include/fpuctl.h +76 −0
  69. MacOSX/386/include/lib9.h +487 −0
  70. MacOSX/README +72 −0
  71. MacOSX/power/bin/data2c +0 −0
  72. MacOSX/power/bin/iyacc +0 −0
  73. MacOSX/power/bin/mk +0 −0
  74. MacOSX/power/bin/mkext +0 −0
  75. MacOSX/power/include/emu.h +22 −0
  76. MacOSX/power/include/fpuctl.h +81 −0
  77. MacOSX/power/include/lib9.h +487 −0
  78. MacOSX/tcshrc +12 −0
  79. NOTICE +32 −0
  80. NetBSD/386/bin/data2c +0 −0
  81. NetBSD/386/bin/mk +0 −0
  82. NetBSD/386/bin/mkext +0 −0
  83. NetBSD/386/bin/yacc +0 −0
  84. NetBSD/386/include/emu.h +30 −0
  85. NetBSD/386/include/fpuctl.h +76 −0
  86. NetBSD/386/include/lib9.h +476 −0
  87. Nt/386/bin/awk.exe +0 −0
  88. Nt/386/bin/c2l.exe +0 −0
  89. Nt/386/bin/cp.exe +0 −0
  90. Nt/386/bin/data2c.exe +0 −0
  91. Nt/386/bin/echo.exe +0 −0
  92. Nt/386/bin/format.exe +0 −0
  93. Nt/386/bin/gzip.exe +0 −0
  94. Nt/386/bin/infdb.exe +0 −0
  95. Nt/386/bin/iyacc.exe +0 −0
  96. Nt/386/bin/mk.exe +0 −0
  97. Nt/386/bin/mkdir.exe +0 −0
  98. Nt/386/bin/mkext.exe +0 −0
  99. Nt/386/bin/mv.exe +0 −0
  100. Nt/386/bin/rcsh.exe +0 −0
  101. Nt/386/bin/rm.exe +0 −0
  102. Nt/386/bin/sed.exe +0 −0
  103. Nt/386/bin/test.exe +0 −0
  104. Nt/386/bin/tr.exe +0 −0
  105. Nt/386/include/emu.h +24 −0
  106. Nt/386/include/lib9.h +485 −0
  107. OpenBSD/386/include/emu.h +30 −0
  108. OpenBSD/386/include/fpuctl.h +76 −0
  109. OpenBSD/386/include/lib9.h +473 −0
  110. Plan9/386/bin/data2c +0 −0
  111. Plan9/386/include/emu.h +22 −0
  112. Plan9/386/include/lib9.h +658 −0
  113. Plan9/386/include/u.h +64 −0
  114. Plan9/arm/bin/.dreg +0 −0
  115. Plan9/arm/include/emu.h +22 −0
  116. Plan9/arm/include/lib9.h +658 −0
  117. Plan9/arm/include/u.h +65 −0
  118. Plan9/arm/lib/.dreg +0 −0
  119. Plan9/include/lib9.h +20 −0
  120. Plan9/include/lib9x.h +20 −0
  121. Plan9/mips/include/emu.h +23 −0
  122. Plan9/mips/include/lib9.h +657 −0
  123. Plan9/mips/include/u.h +65 −0
  124. Plan9/power/include/emu.h +30 −0
  125. Plan9/power/include/lib9.h +657 −0
  126. Plan9/power/include/u.h +84 −0
  127. Plan9/sparc/include/emu.h +22 −0
  128. Plan9/sparc/include/lib9.h +657 −0
  129. Plan9/sparc/include/os.h +17 −0
  130. Plan9/sparc/include/u.h +64 −0
  131. README.gcode +11 −0
  132. Solaris/386/include/emu.h +21 −0
  133. Solaris/386/include/lib9.h +393 −0
  134. Solaris/sparc/bin/data2c +0 −0
  135. Solaris/sparc/bin/iyacc +0 −0
  136. Solaris/sparc/bin/mk +0 −0
  137. Solaris/sparc/bin/mkext +0 −0
  138. Solaris/sparc/include/emu.h +21 −0
  139. Solaris/sparc/include/fpuctl.h +75 −0
  140. Solaris/sparc/include/lib9.h +468 −0
  141. acme/acid/Acid.dis +0 −0
  142. acme/acid/Acid0.dis +0 −0
  143. acme/acid/guide +2 −0
  144. acme/acid/readme +12 −0
  145. acme/bin/guide +5 −0
  146. acme/bin/readme +25 −0
  147. acme/dis/adiff.dis +0 −0
  148. acme/dis/agrep.dis +0 −0
  149. acme/dis/awd.dis +0 −0
  150. acme/dis/cd.dis +0 −0
  151. acme/dis/new.dis +0 −0
  152. acme/dis/spout.dis +0 −0
  153. acme/dis/win.dis +0 −0
  154. acme/dis/winm.dis +0 −0
  155. acme/edit/a.dis +0 −0
  156. acme/edit/c.dis +0 −0
  157. acme/edit/d.dis +0 −0
  158. acme/edit/e.dis +0 −0
  159. acme/edit/g.dis +0 −0
  160. acme/edit/guide +4 −0
  161. acme/edit/i.dis +0 −0
  162. acme/edit/p.dis +0 −0
  163. acme/edit/pipe.dis +0 −0
  164. acme/edit/readme +31 −0
  165. acme/edit/x.dis +0 −0
  166. acme/mail/Mail.dis +0 −0
  167. acme/mail/Mailpop3.dis +0 −0
  168. acme/mail/guide +5 −0
  169. acme/mail/mkbox.dis +0 −0
  170. acme/mail/readme +29 −0
  171. appl/NOTICE +25 −0
  172. appl/acme/acme.b +1112 −0
  173. appl/acme/acme.m +32 −0
  174. appl/acme/acme/acid/guide +2 −0
  175. appl/acme/acme/acid/mkfile +24 −0
  176. appl/acme/acme/acid/readme +12 −0
  177. appl/acme/acme/acid/src/Acid.b +31 −0
  178. appl/acme/acme/acid/src/Acid0.b +86 −0
  179. appl/acme/acme/acid/src/mkfile +20 −0
  180. appl/acme/acme/bin/guide +5 −0
  181. appl/acme/acme/bin/mkfile +24 −0
  182. appl/acme/acme/bin/readme +25 −0
  183. appl/acme/acme/bin/src/adiff.b +155 −0
  184. appl/acme/acme/bin/src/agrep.b +46 −0
  185. appl/acme/acme/bin/src/awd.b +45 −0
  186. appl/acme/acme/bin/src/cd.b +70 −0
  187. appl/acme/acme/bin/src/mkfile +22 −0
  188. appl/acme/acme/bin/src/new.b +70 −0
  189. appl/acme/acme/bin/src/spout.b +143 −0
  190. appl/acme/acme/bin/src/win.b +770 −0
  191. appl/acme/acme/bin/src/winm.b +791 −0
  192. appl/acme/acme/edit/guide +4 −0
  193. appl/acme/acme/edit/mkfile +24 −0
  194. appl/acme/acme/edit/readme +31 −0
  195. appl/acme/acme/edit/src/a.b +89 −0
  196. appl/acme/acme/edit/src/c.b +104 −0
  197. appl/acme/acme/edit/src/d.b +30 −0
  198. appl/acme/acme/edit/src/e.b +154 −0
  199. appl/acme/acme/edit/src/findfile.b +210 −0
  200. appl/acme/acme/edit/src/g.b +95 −0
  201. appl/acme/acme/edit/src/i.b +88 −0
  202. appl/acme/acme/edit/src/input.b +84 −0
  203. appl/acme/acme/edit/src/mkfile +23 −0
  204. appl/acme/acme/edit/src/p.b +109 −0
  205. appl/acme/acme/edit/src/pipe.b +212 −0
  206. appl/acme/acme/edit/src/x.b +123 −0
  207. appl/acme/acme/edit/src/xxx.b +327 −0
  208. appl/acme/acme/mail/guide +5 −0
  209. appl/acme/acme/mail/mkbox.b +25 −0
  210. appl/acme/acme/mail/mkfile +34 −0
  211. appl/acme/acme/mail/readme +29 −0
  212. appl/acme/acme/mail/src/Mail.b +1715 −0
  213. appl/acme/acme/mail/src/Mailp.b +1684 −0
  214. appl/acme/acme/mail/src/Mailpop3.b +1720 −0
  215. appl/acme/acme/mail/src/mashfile +18 −0
  216. appl/acme/acme/mail/src/mkfile +16 −0
  217. appl/acme/acme/mkfile +9 −0
  218. appl/acme/buff.b +380 −0
  219. appl/acme/buff.m +34 −0
  220. appl/acme/col.b +610 −0
  221. appl/acme/col.m +26 −0
  222. appl/acme/common.m +30 −0
  223. appl/acme/dat.b +107 −0
  224. appl/acme/dat.m +280 −0
  225. appl/acme/disk.b +136 −0
  226. appl/acme/disk.m +19 −0
  227. appl/acme/ecmd.b +1350 −0
  228. appl/acme/ecmd.m +18 −0
  229. appl/acme/edit.b +676 −0
  230. appl/acme/edit.m +85 −0
  231. appl/acme/elog.b +353 −0
  232. appl/acme/elog.m +24 −0
  233. appl/acme/exec.b +1350 −0
  234. appl/acme/exec.m +19 −0
  235. appl/acme/file.b +331 −0
  236. appl/acme/file.m +40 −0
  237. appl/acme/frame.b +1189 −0
  238. appl/acme/frame.m +54 −0
  239. appl/acme/fsys.b +866 −0
  240. appl/acme/fsys.m +18 −0
  241. appl/acme/graph.b +82 −0
  242. appl/acme/graph.m +18 −0
  243. appl/acme/gui.b +126 −0
  244. appl/acme/gui.m +15 −0
  245. appl/acme/look.b +743 −0
  246. appl/acme/look.m +17 −0
  247. appl/acme/mkfile +90 −0
  248. appl/acme/regx.b +1050 −0
  249. appl/acme/regx.m +13 −0
  250. appl/acme/row.b +767 −0
  251. appl/acme/row.m +29 −0
  252. appl/acme/scrl.b +187 −0
  253. appl/acme/scrl.m +9 −0
  254. appl/acme/styxaux.b +174 −0
  255. appl/acme/styxaux.m +24 −0
  256. appl/acme/text.b +1404 −0
  257. appl/acme/text.m +65 −0
  258. appl/acme/time.b +129 −0
  259. appl/acme/time.m +10 −0
  260. appl/acme/util.b +574 −0
  261. appl/acme/util.m +52 −0
  262. appl/acme/wind.b +558 −0
  263. appl/acme/wind.m +67 −0
  264. appl/acme/xfid.b +1087 −0
  265. appl/acme/xfid.m +34 −0
  266. appl/alphabet/abc/abc.b +53 −0
  267. appl/alphabet/abc/autoconvert.b +80 −0
  268. appl/alphabet/abc/autodeclare.b +42 −0
  269. appl/alphabet/abc/declare.b +70 −0
  270. appl/alphabet/abc/declares.b +124 −0
  271. appl/alphabet/abc/define.b +52 −0
  272. appl/alphabet/abc/eval.b +66 −0
  273. appl/alphabet/abc/import.b +53 −0
  274. appl/alphabet/abc/mkfile +29 −0
  275. appl/alphabet/abc/newtypeset.b +147 −0
  276. appl/alphabet/abc/rewrite.b +71 −0
  277. appl/alphabet/abc/type.b +53 −0
  278. appl/alphabet/abc/typeset.b +51 −0
  279. appl/alphabet/abc/undeclare.b +48 −0
  280. appl/alphabet/alphabet.b +1677 −0
  281. appl/alphabet/alphabet.proto +29 −0
  282. appl/alphabet/alphabet.shmod.b +413 −0
  283. appl/alphabet/auxi/endpoints.b +105 −0
  284. appl/alphabet/auxi/endpointsrv.b +58 −0
  285. appl/alphabet/auxi/fsfilter.b +62 −0
  286. appl/alphabet/auxi/mkfile +21 −0
  287. appl/alphabet/auxi/rexecsrv.b +301 −0
  288. appl/alphabet/declare.sh +25 −0
  289. appl/alphabet/eval.b +757 −0
  290. appl/alphabet/extvalues.b +49 −0
  291. appl/alphabet/fs/and.b +70 −0
  292. appl/alphabet/fs/bundle.b +210 −0
  293. appl/alphabet/fs/bundle.m +9 −0
  294. appl/alphabet/fs/chstat.b +189 −0
  295. appl/alphabet/fs/compose.b +105 −0
  296. appl/alphabet/fs/depth.b +54 −0
  297. appl/alphabet/fs/entries.b +91 −0
  298. appl/alphabet/fs/exec.b +172 −0
  299. appl/alphabet/fs/filter.b +66 −0
  300. appl/alphabet/fs/ls.b +107 −0
  301. appl/alphabet/fs/match.b +84 −0
  302. appl/alphabet/fs/merge.b +192 −0
  303. appl/alphabet/fs/mergewrite.b +244 −0
  304. appl/alphabet/fs/mkext.b +266 −0
  305. appl/alphabet/fs/mkfile +55 −0
  306. appl/alphabet/fs/mode.b +125 −0
  307. appl/alphabet/fs/newer.b +64 −0
  308. appl/alphabet/fs/not.b +53 −0
  309. appl/alphabet/fs/or.b +70 −0
  310. appl/alphabet/fs/path.b +82 −0
  311. appl/alphabet/fs/pipe.b +230 −0
  312. appl/alphabet/fs/print.b +61 −0
  313. appl/alphabet/fs/proto.b +416 −0
  314. appl/alphabet/fs/query.b +135 −0
  315. appl/alphabet/fs/run.b +65 −0
  316. appl/alphabet/fs/select.b +60 −0
  317. appl/alphabet/fs/setroot.b +109 −0
  318. appl/alphabet/fs/size.b +64 −0
  319. appl/alphabet/fs/unbundle.b +259 −0
  320. appl/alphabet/fs/unbundle.m +9 −0
  321. appl/alphabet/fs/walk.b +242 −0
  322. appl/alphabet/fs/write.b +137 −0
  323. appl/alphabet/fsdecl.sh +13 −0
  324. appl/alphabet/getendpoint.sh +13 −0
  325. appl/alphabet/grid/farm.b +144 −0
  326. appl/alphabet/grid/line2rec.b +91 −0
  327. appl/alphabet/grid/local.b +86 −0
  328. appl/alphabet/grid/mkfile +22 −0
  329. appl/alphabet/grid/remote.b +88 −0
  330. appl/alphabet/grid/rexec.b +112 −0
  331. appl/alphabet/main/auth.b +157 −0
  332. appl/alphabet/main/cat.b +78 −0
  333. appl/alphabet/main/create.b +55 −0
  334. appl/alphabet/main/dial.b +85 −0
  335. appl/alphabet/main/echo.b +51 −0
  336. appl/alphabet/main/export.b +52 −0
  337. appl/alphabet/main/fd.b +83 −0
  338. appl/alphabet/main/filter.b +114 −0
  339. appl/alphabet/main/genfilter.b +79 −0
  340. appl/alphabet/main/mkfile +36 −0
  341. appl/alphabet/main/mount.b +80 −0
  342. appl/alphabet/main/par.b +50 −0
  343. appl/alphabet/main/parse.b +43 −0
  344. appl/alphabet/main/pretty.b +116 −0
  345. appl/alphabet/main/print.b +55 −0
  346. appl/alphabet/main/read.b +56 −0
  347. appl/alphabet/main/readall.b +46 −0
  348. appl/alphabet/main/rewrite.b +97 −0
  349. appl/alphabet/main/rw.b +50 −0
  350. appl/alphabet/main/seq.b +66 −0
  351. appl/alphabet/main/unparse.b +38 −0
  352. appl/alphabet/main/w2fd.b +61 −0
  353. appl/alphabet/main/wait.b +35 −0
  354. appl/alphabet/mkendpoint.sh +14 −0
  355. appl/alphabet/mkfile +49 −0
  356. appl/alphabet/newtypesets +229 −0
  357. appl/alphabet/proxy.b +304 −0
  358. appl/alphabet/reports.b +189 −0
  359. appl/alphabet/rexecsrv.sh +9 −0
  360. appl/alphabet/setup +63 −0
  361. appl/alphabet/typesets/abc.b +180 −0
  362. appl/alphabet/typesets/abctypes.b +229 −0
  363. appl/alphabet/typesets/fs.b +226 −0
  364. appl/alphabet/typesets/fstypes.b +230 −0
  365. appl/alphabet/typesets/grid.b +160 −0
  366. appl/alphabet/typesets/gridtypes.b +230 −0
  367. appl/alphabet/typesets/mkfile +34 −0
  368. appl/charon/build.b +2864 −0
  369. appl/charon/build.m +478 −0
  370. appl/charon/charon.b +2171 −0
  371. appl/charon/charon.m +20 −0
  372. appl/charon/chutils.b +2045 −0
  373. appl/charon/chutils.m +370 −0
  374. appl/charon/common.m +23 −0
  375. appl/charon/cookiesrv.b +595 −0
  376. appl/charon/cookiesrv.m +12 −0
  377. appl/charon/ctype.b +70 −0
  378. appl/charon/ctype.m +24 −0
  379. appl/charon/date.b +62 −0
  380. appl/charon/date.m +12 −0
  381. appl/charon/event.b +273 −0
  382. appl/charon/event.m +100 −0
  383. appl/charon/file.b +134 −0
  384. appl/charon/ftp.b +314 −0
  385. appl/charon/gui.b +560 −0
  386. appl/charon/gui.m +48 −0
  387. appl/charon/http.b +1040 −0
  388. appl/charon/img.b +3607 −0
  389. appl/charon/img.m +115 −0
  390. appl/charon/jscript.b +3025 −0
  391. appl/charon/layout.b +4832 −0
  392. appl/charon/layout.m +235 −0
  393. appl/charon/lex.b +1340 −0
  394. appl/charon/lex.m +105 −0
  395. appl/charon/mkfile +92 −0
  396. appl/charon/paginate.b +511 −0
  397. appl/charon/paginate.m +16 −0
  398. appl/charon/rgb.inc +620 −0
  399. appl/charon/script.m +14 −0
  400. appl/charon/transport.m +13 −0
  401. appl/charon/url.b +225 −0
  402. appl/charon/url.m +30 −0
  403. appl/charon/xxx.inc +75 −0
  404. appl/charon/ycbcr.inc +621 −0
  405. appl/cmd/9660srv.b +1504 −0
  406. appl/cmd/9export.b +165 −0
  407. appl/cmd/9srvfs.b +99 −0
  408. appl/cmd/9win.b +453 −0
  409. appl/cmd/B.b +107 −0
  410. appl/cmd/ar.b +857 −0
  411. appl/cmd/archfs.b +630 −0
  412. appl/cmd/auplay.b +114 −0
  413. appl/cmd/auth/aescbc.b +240 −0
  414. appl/cmd/auth/ai2key.b +144 −0
  415. appl/cmd/auth/changelogin.b +304 −0
  416. appl/cmd/auth/convpasswd.b +120 −0
  417. appl/cmd/auth/countersigner.b +64 −0
  418. appl/cmd/auth/createsignerkey.b +144 −0
  419. appl/cmd/auth/dsagen.b +62 −0
  420. appl/cmd/auth/factotum/authio.m +85 −0
  421. appl/cmd/auth/factotum/factotum.b +1066 −0
  422. appl/cmd/auth/factotum/feedkey.b +321 −0
  423. appl/cmd/auth/factotum/mkfile +27 −0
  424. appl/cmd/auth/factotum/proto/authquery.b +204 −0
  425. appl/cmd/auth/factotum/proto/infauth.b +431 −0
  426. appl/cmd/auth/factotum/proto/keyreps.b +173 −0
  427. appl/cmd/auth/factotum/proto/keyreps.m +23 −0
  428. appl/cmd/auth/factotum/proto/mkfile +24 −0
  429. appl/cmd/auth/factotum/proto/p9any.b +237 −0
  430. appl/cmd/auth/factotum/proto/pass.b +34 −0
  431. appl/cmd/auth/factotum/proto/rsa.b +126 −0
  432. appl/cmd/auth/factotum/rpc.b +68 −0
  433. appl/cmd/auth/getpk.b +83 −0
  434. appl/cmd/auth/keyfs.b +806 −0
  435. appl/cmd/auth/keysrv.b +199 −0
  436. appl/cmd/auth/logind.b +244 −0
  437. appl/cmd/auth/mkauthinfo.b +125 −0
  438. appl/cmd/auth/mkfile +39 −0
  439. appl/cmd/auth/passwd.b +290 −0
  440. appl/cmd/auth/rsagen.b +76 −0
  441. appl/cmd/auth/secstore.b +332 −0
  442. appl/cmd/auth/signer.b +132 −0
  443. appl/cmd/auth/verify.b +85 −0
  444. appl/cmd/auxi/cpuslave.b +79 −0
  445. appl/cmd/auxi/digest.b +91 −0
  446. appl/cmd/auxi/fpgaload.b +67 −0
  447. appl/cmd/auxi/mangaload.b +350 −0
  448. appl/cmd/auxi/mkfile +24 −0
  449. appl/cmd/auxi/pcmcia.b +491 −0
  450. appl/cmd/auxi/rdbgsrv.b +222 −0
  451. appl/cmd/auxi/rstyxd.b +110 −0
  452. appl/cmd/avr/burn.b +859 −0
  453. appl/cmd/avr/mkfile +10 −0
  454. appl/cmd/basename.b +50 −0
  455. appl/cmd/bind.b +66 −0
  456. appl/cmd/bit2gif.b +86 −0
  457. appl/cmd/broke.b +84 −0
  458. appl/cmd/bytes.b +212 −0
  459. appl/cmd/cal.b +295 −0
  460. appl/cmd/calc.b +2547 −0
  461. appl/cmd/cat.b +48 −0
  462. appl/cmd/cd.b +48 −0
  463. appl/cmd/cddb.b +247 −0
  464. appl/cmd/chgrp.b +58 −0
  465. appl/cmd/chmod.b +125 −0
  466. appl/cmd/cleanname.b +45 −0
  467. appl/cmd/cmp.b +151 −0
  468. appl/cmd/comm.b +124 −0
  469. appl/cmd/cook.b +1924 −0
  470. appl/cmd/cp.b +237 −0
  471. appl/cmd/cprof.b +190 −0
  472. appl/cmd/cpu.b +168 −0
  473. appl/cmd/crypt.b +263 −0
  474. appl/cmd/date.b +71 −0
  475. appl/cmd/dbfs.b +518 −0
  476. appl/cmd/dbm/delete.b +34 −0
  477. appl/cmd/dbm/fetch.b +37 −0
  478. appl/cmd/dbm/keys.b +32 −0
  479. appl/cmd/dbm/list.b +34 −0
  480. appl/cmd/dbm/mkfile +19 −0
  481. appl/cmd/dbm/store.b +69 −0
  482. appl/cmd/dd.b +625 −0
  483. appl/cmd/dial.b +148 −0
  484. appl/cmd/diff.b +854 −0
  485. appl/cmd/disdep.b +250 −0
  486. appl/cmd/disdump.b +52 −0
  487. appl/cmd/disk/format.b +755 −0
  488. appl/cmd/disk/ftl.b +911 −0
  489. appl/cmd/disk/kfs.b +3844 −0
  490. appl/cmd/disk/kfscmd.b +53 −0
  491. appl/cmd/disk/mbr.b +134 −0
  492. appl/cmd/disk/mkext.b +352 −0
  493. appl/cmd/disk/mkfile +25 −0
  494. appl/cmd/disk/mkfs.b +732 −0
  495. appl/cmd/disk/prep/calc.tab.b +454 −0
  496. appl/cmd/disk/prep/calc.tab.m +7 −0
  497. appl/cmd/disk/prep/calc.y +174 −0
  498. appl/cmd/disk/prep/fdisk.b +924 −0
  499. appl/cmd/disk/prep/mkfile +26 −0
  500. appl/cmd/disk/prep/pedit.b +503 −0
  501. appl/cmd/disk/prep/pedit.m +53 −0
  502. appl/cmd/disk/prep/prep.b +508 −0
  503. appl/cmd/dossrv.b +3431 −0
  504. appl/cmd/du.b +163 −0
  505. appl/cmd/echo.b +36 −0
  506. appl/cmd/ed.b +1588 −0
  507. appl/cmd/emuinit.b +110 −0
  508. appl/cmd/env.b +52 −0
  509. appl/cmd/export.b +57 −0
  510. appl/cmd/fc.b +612 −0
  511. appl/cmd/fcp.b +312 −0
  512. appl/cmd/fmt.b +204 −0
  513. appl/cmd/fone.b +560 −0
  514. appl/cmd/fortune.b +100 −0
  515. appl/cmd/freq.b +112 −0
  516. appl/cmd/fs.b +109 −0
  517. appl/cmd/fs/and.b +65 −0
  518. appl/cmd/fs/bundle.b +195 −0
  519. appl/cmd/fs/chstat.b +185 −0
  520. appl/cmd/fs/compose.b +100 −0
  521. appl/cmd/fs/depth.b +49 −0
  522. appl/cmd/fs/entries.b +86 −0
  523. appl/cmd/fs/eval.b +648 −0
  524. appl/cmd/fs/exec.b +162 −0
  525. appl/cmd/fs/filter.b +64 −0
  526. appl/cmd/fs/ls.b +97 −0
  527. appl/cmd/fs/match.b +79 −0
  528. appl/cmd/fs/merge.b +187 −0
  529. appl/cmd/fs/mergewrite.b +186 −0
  530. appl/cmd/fs/mkfile +60 −0
  531. appl/cmd/fs/mode.b +120 −0
  532. appl/cmd/fs/not.b +48 −0
  533. appl/cmd/fs/or.b +65 −0
  534. appl/cmd/fs/path.b +77 −0
  535. appl/cmd/fs/pipe.b +223 −0
  536. appl/cmd/fs/print.b +51 −0
  537. appl/cmd/fs/proto.b +393 −0
  538. appl/cmd/fs/query.b +130 −0
  539. appl/cmd/fs/readfile.b +144 −0
  540. appl/cmd/fs/run.b +60 −0
  541. appl/cmd/fs/select.b +56 −0
  542. appl/cmd/fs/setroot.b +104 −0
  543. appl/cmd/fs/size.b +54 −0
  544. appl/cmd/fs/template.b +35 −0
  545. appl/cmd/fs/unbundle.b +259 −0
  546. appl/cmd/fs/void.b +33 −0
  547. appl/cmd/fs/walk.b +233 −0
  548. appl/cmd/fs/write.b +111 −0
  549. appl/cmd/ftest.b +153 −0
  550. appl/cmd/ftpfs.b +1955 −0
  551. appl/cmd/getauthinfo.b +185 −0
  552. appl/cmd/getfile.b +74 −0
  553. appl/cmd/gettar.b +248 −0
  554. appl/cmd/gif2bit.b +101 −0
  555. appl/cmd/grep.b +155 −0
  556. appl/cmd/gunzip.b +139 −0
  557. appl/cmd/gzip.b +228 −0
  558. appl/cmd/idea.b +116 −0
  559. appl/cmd/import.b +165 −0
  560. appl/cmd/install/NOTICE +6 −0
  561. appl/cmd/install/applylog.b +699 −0
  562. appl/cmd/install/arch.b +288 −0
  563. appl/cmd/install/arch.m +36 −0
  564. appl/cmd/install/archfs.b +579 −0
  565. appl/cmd/install/archfs.m +7 −0
  566. appl/cmd/install/ckproto.b +267 −0
  567. appl/cmd/install/create.b +445 −0
  568. appl/cmd/install/eproto.b +357 −0
  569. appl/cmd/install/info.b +73 −0
  570. appl/cmd/install/inst.b +500 −0
  571. appl/cmd/install/install.b +430 −0
  572. appl/cmd/install/log.b +76 −0
  573. appl/cmd/install/logs.b +287 −0
  574. appl/cmd/install/logs.m +44 −0
  575. appl/cmd/install/mergelog.b +239 −0
  576. appl/cmd/install/mkfile +43 −0
  577. appl/cmd/install/mkproto.b +99 −0
  578. appl/cmd/install/proto.b +320 −0
  579. appl/cmd/install/proto.m +6 −0
  580. appl/cmd/install/proto2list.b +209 −0
  581. appl/cmd/install/protocaller.m +8 −0
  582. appl/cmd/install/updatelog.b +386 −0
  583. appl/cmd/install/wdiff.b +148 −0
  584. appl/cmd/install/wfind.b +204 −0
  585. appl/cmd/install/wrap.b +684 −0
  586. appl/cmd/install/wrap.m +41 −0
  587. appl/cmd/install/wrap2list.b +305 −0
  588. appl/cmd/iostats.b +635 −0
  589. appl/cmd/ip/bootpd.b +661 −0
  590. appl/cmd/ip/dhcp.b +162 −0
  591. appl/cmd/ip/mkfile +29 −0
  592. appl/cmd/ip/nppp/mkfile +24 −0
  593. appl/cmd/ip/nppp/modem.b +469 −0
  594. appl/cmd/ip/nppp/modem.m +47 −0
  595. appl/cmd/ip/nppp/pppchat.b +322 −0
  596. appl/cmd/ip/nppp/ppplink.b +782 −0
  597. appl/cmd/ip/nppp/ppptest.b +90 −0
  598. appl/cmd/ip/nppp/script.b +171 −0
  599. appl/cmd/ip/nppp/script.m +15 −0
  600. appl/cmd/ip/ping.b +358 −0
  601. appl/cmd/ip/ppp/mkfile +27 −0
  602. appl/cmd/ip/ppp/modem.b +468 −0
  603. appl/cmd/ip/ppp/modem.m +41 −0
  604. appl/cmd/ip/ppp/pppclient.b +216 −0
  605. appl/cmd/ip/ppp/pppclient.m +31 −0
  606. appl/cmd/ip/ppp/pppdial.b +283 −0
  607. appl/cmd/ip/ppp/pppgui.b +373 −0
  608. appl/cmd/ip/ppp/pppgui.m +21 −0
  609. appl/cmd/ip/ppp/ppptest.b +86 −0
  610. appl/cmd/ip/ppp/script.b +168 −0
  611. appl/cmd/ip/ppp/script.m +14 −0
  612. appl/cmd/ip/rip.b +625 −0
  613. appl/cmd/ip/sntp.b +310 −0
  614. appl/cmd/ip/tftpd.b +512 −0
  615. appl/cmd/ip/virgild.b +126 −0
  616. appl/cmd/irtest.b +70 −0
  617. appl/cmd/itest.b +478 −0
  618. appl/cmd/itreplay.b +230 −0
  619. appl/cmd/kill.b +146 −0
  620. appl/cmd/lego/clock.b +214 −0
  621. appl/cmd/lego/clockface.b +384 −0
  622. appl/cmd/lego/firmdl.b +294 −0
  623. appl/cmd/lego/link.b +603 −0
  624. appl/cmd/lego/mkfile +23 −0
  625. appl/cmd/lego/rcxsend.b +240 −0
  626. appl/cmd/lego/rcxsend.m +6 −0
  627. appl/cmd/lego/send.b +86 −0
  628. appl/cmd/lego/timers.b +263 −0
  629. appl/cmd/lego/timers.m +17 −0
  630. appl/cmd/limbo/arg.m +50 −0
  631. appl/cmd/limbo/asm.b +263 −0
  632. appl/cmd/limbo/com.b +1402 −0
  633. appl/cmd/limbo/decls.b +1177 −0
  634. appl/cmd/limbo/dis.b +560 −0
  635. appl/cmd/limbo/disoptab.m +355 −0
  636. appl/cmd/limbo/ecom.b +2345 −0
  637. appl/cmd/limbo/gen.b +1011 −0
  638. appl/cmd/limbo/isa.m +247 −0
  639. appl/cmd/limbo/lex.b +1178 −0
  640. appl/cmd/limbo/limbo.b +3100 −0
  641. appl/cmd/limbo/limbo.m +527 −0
  642. appl/cmd/limbo/limbo.y +1974 −0
  643. appl/cmd/limbo/mkfile +35 −0
  644. appl/cmd/limbo/nodes.b +1402 −0
  645. appl/cmd/limbo/opname.m +109 −0
  646. appl/cmd/limbo/optim.b +3 −0
  647. appl/cmd/limbo/sbl.b +397 −0
  648. appl/cmd/limbo/stubs.b +575 −0
  649. appl/cmd/limbo/typecheck.b +3223 −0
  650. appl/cmd/limbo/types.b +4234 −0
  651. appl/cmd/listen.b +261 −0
  652. appl/cmd/lockfs.b +778 −0
  653. appl/cmd/logfile.b +259 −0
  654. appl/cmd/look.b +384 −0
  655. appl/cmd/ls.b +332 −0
  656. appl/cmd/lstar.b +120 −0
  657. appl/cmd/m4.b +946 −0
  658. appl/cmd/man2html.b +1366 −0
  659. appl/cmd/man2txt.b +79 −0
  660. appl/cmd/manufacture.b +42 −0
  661. appl/cmd/mash/builtins.b +347 −0
  662. appl/cmd/mash/depends.b +228 −0
  663. appl/cmd/mash/dump.b +199 −0
  664. appl/cmd/mash/exec.b +401 −0
  665. appl/cmd/mash/expr.b +158 −0
  666. appl/cmd/mash/eyacc.b +2785 −0
  667. appl/cmd/mash/eyaccpar +223 −0
  668. appl/cmd/mash/history.b +206 −0
  669. appl/cmd/mash/lex.b +547 −0
  670. appl/cmd/mash/make.b +723 −0
  671. appl/cmd/mash/mash.b +154 −0
  672. appl/cmd/mash/mash.m +372 −0
  673. appl/cmd/mash/mash.y +269 −0
  674. appl/cmd/mash/mashfile +36 −0
  675. appl/cmd/mash/mashlib.b +60 −0
  676. appl/cmd/mash/mashparse.b +662 −0
  677. appl/cmd/mash/mashparse.m +56 −0
  678. appl/cmd/mash/misc.b +313 −0
  679. appl/cmd/mash/mkfile +78 −0
  680. appl/cmd/mash/serve.b +154 −0
  681. appl/cmd/mash/symb.b +265 −0
  682. appl/cmd/mash/tk.b +603 −0
  683. appl/cmd/mash/xeq.b +543 −0
  684. appl/cmd/mc.b +154 −0
  685. appl/cmd/md5sum.b +65 −0
  686. appl/cmd/mdb.b +537 −0
  687. appl/cmd/memfs.b +648 −0
  688. appl/cmd/metamorph.b +94 −0
  689. appl/cmd/mk/ar.m +26 −0
  690. appl/cmd/mk/mk.b +4190 −0
  691. appl/cmd/mk/mkbinds +2 −0
  692. appl/cmd/mk/mkconfig +28 −0
  693. appl/cmd/mk/mkfile +19 −0
  694. appl/cmd/mk/mksubdirs +16 −0
  695. appl/cmd/mkdir.b +75 −0
  696. appl/cmd/mkfile +229 −0
  697. appl/cmd/mntgen.b +188 −0
  698. appl/cmd/mount.b +346 −0
  699. appl/cmd/mouse.b +394 −0
  700. appl/cmd/mpc/mkfile +14 −0
  701. appl/cmd/mpc/qconfig.b +193 −0
  702. appl/cmd/mpc/qflash.b +188 −0
  703. appl/cmd/mprof.b +260 −0
  704. appl/cmd/mv.b +183 −0
  705. appl/cmd/ndb/cs.b +686 −0
  706. appl/cmd/ndb/csquery.b +97 −0
  707. appl/cmd/ndb/dns.b +1871 −0
  708. appl/cmd/ndb/dnsquery.b +177 −0
  709. appl/cmd/ndb/mkfile +28 −0
  710. appl/cmd/ndb/mkhash.b +119 −0
  711. appl/cmd/ndb/query.b +135 −0
  712. appl/cmd/ndb/registry.b +776 −0
  713. appl/cmd/ndb/regquery.b +104 −0
  714. appl/cmd/netkey.b +166 −0
  715. appl/cmd/netstat.b +91 −0
  716. appl/cmd/newer.b +36 −0
  717. appl/cmd/ns.b +157 −0
  718. appl/cmd/nsbuild.b +41 −0
  719. appl/cmd/os.b +168 −0
  720. appl/cmd/p.b +141 −0
  721. appl/cmd/palm/connex.b +124 −0
  722. appl/cmd/palm/desklink.b +843 −0
  723. appl/cmd/palm/desklink.m +90 −0
  724. appl/cmd/palm/mkfile +16 −0
  725. appl/cmd/palm/palmsrv.b +901 −0
  726. appl/cmd/pause.b +17 −0
  727. appl/cmd/plumb.b +128 −0
  728. appl/cmd/plumber.b +766 −0
  729. appl/cmd/prof.b +243 −0
  730. appl/cmd/promptstring.b +66 −0
  731. appl/cmd/ps.b +61 −0
  732. appl/cmd/puttar.b +183 −0
  733. appl/cmd/pwd.b +28 −0
  734. appl/cmd/ramfile.b +97 −0
  735. appl/cmd/randpass.b +41 −0
  736. appl/cmd/raw2iaf.b +122 −0
  737. appl/cmd/rawdbfs.b +812 −0
  738. appl/cmd/rcmd.b +170 −0
  739. appl/cmd/rdp.b +1230 −0
  740. appl/cmd/read.b +62 −0
  741. appl/cmd/rioimport.b +620 −0
  742. appl/cmd/rm.b +99 −0
  743. appl/cmd/runas.b +60 −0
  744. appl/cmd/sed.b +911 −0
  745. appl/cmd/sendmail.b +252 −0
  746. appl/cmd/sh/arg.b +181 −0
  747. appl/cmd/sh/csv.b +244 −0
  748. appl/cmd/sh/doc/History +14 −0
  749. appl/cmd/sh/echo.b +96 −0
  750. appl/cmd/sh/expr.b +281 −0
  751. appl/cmd/sh/file2chan.b +459 −0
  752. appl/cmd/sh/mkfile +65 −0
  753. appl/cmd/sh/mload.b +348 −0
  754. appl/cmd/sh/mpexpr.b +435 −0
  755. appl/cmd/sh/regex.b +220 −0
  756. appl/cmd/sh/sexprs.b +271 −0
  757. appl/cmd/sh/sh.b +2876 −0
  758. appl/cmd/sh/sh.y +2628 −0
  759. appl/cmd/sh/std.b +812 −0
  760. appl/cmd/sh/string.b +212 −0
  761. appl/cmd/sh/test.b +96 −0
  762. appl/cmd/sh/tk.b +438 −0
  763. appl/cmd/sha1sum.b +65 −0
  764. appl/cmd/sleep.b +46 −0
  765. appl/cmd/sort.b +129 −0
  766. appl/cmd/spki/mkfile +22 −0
  767. appl/cmd/spki/verify.b +107 −0
  768. appl/cmd/src.b +96 −0
  769. appl/cmd/stack.b +184 −0
  770. appl/cmd/stackv.b +502 −0
  771. appl/cmd/stream.b +97 −0
  772. appl/cmd/strings.b +87 −0
  773. appl/cmd/styxchat.b +546 −0
  774. appl/cmd/styxlisten.b +262 −0
  775. appl/cmd/styxmon.b +110 −0
  776. appl/cmd/sum.b +59 −0
  777. appl/cmd/tail.b +379 −0
  778. appl/cmd/tarfs.b +438 −0
  779. appl/cmd/tclsh.b +48 −0
  780. appl/cmd/tcs.b +204 −0
  781. appl/cmd/tee.b +79 −0
  782. appl/cmd/telnet.b +469 −0
  783. appl/cmd/test.b +284 −0
  784. appl/cmd/time.b +97 −0
  785. appl/cmd/timestamp.b +42 −0
  786. appl/cmd/tkcmd.b +190 −0
  787. appl/cmd/tokenize.b +33 −0
  788. appl/cmd/touch.b +77 −0
  789. appl/cmd/touchcal.b +278 −0
  790. appl/cmd/tr.b +319 −0
  791. appl/cmd/trfs.b +213 −0
  792. appl/cmd/tsort.b +133 −0
  793. appl/cmd/unicode.b +162 −0
  794. appl/cmd/uniq.b +79 −0
  795. appl/cmd/units.b +1061 −0
  796. appl/cmd/units.y +771 −0
  797. appl/cmd/unmount.b +44 −0
  798. appl/cmd/usb/mkfile +11 −0
  799. appl/cmd/usb/usbd.b +835 −0
  800. appl/cmd/uudecode.b +132 −0
  801. appl/cmd/uuencode.b +101 −0
  802. appl/cmd/vacfs.b +467 −0
  803. appl/cmd/vacget.b +205 −0
  804. appl/cmd/vacput.b +329 −0
  805. appl/cmd/wav2iaf.b +171 −0
  806. appl/cmd/wc.b +303 −0
  807. appl/cmd/webgrab.b +571 −0
  808. appl/cmd/wish.b +191 −0
  809. appl/cmd/wmexport.b +556 −0
  810. appl/cmd/wmimport.b +64 −0
  811. appl/cmd/xargs.b +86 −0
  812. appl/cmd/xd.b +316 −0
  813. appl/cmd/yacc.b +2809 −0
  814. appl/cmd/zeros.b +68 −0
  815. appl/collab/clients/chat.b +224 −0
  816. appl/collab/clients/poll.b +282 −0
  817. appl/collab/clients/poller.b +330 −0
  818. appl/collab/clients/whiteboard.b +586 −0
  819. appl/collab/collabsrv.b +176 −0
  820. appl/collab/connect.b +156 −0
  821. appl/collab/lib/messages.b +86 −0
  822. appl/collab/lib/messages.m +42 −0
  823. appl/collab/mkfile +62 −0
  824. appl/collab/proxy.b +177 −0
  825. appl/collab/proxy.m +5 −0
  826. appl/collab/runcollab +8 −0
  827. appl/collab/servers/chatsrv.b +263 −0
  828. appl/collab/servers/memfssrv.b +20 −0
  829. appl/collab/servers/mpx.b +301 −0
  830. appl/collab/servers/wbsrv.b +226 −0
  831. appl/collab/service.m +4 −0
  832. appl/collab/srvmgr.b +190 −0
  833. appl/collab/srvmgr.m +22 −0
  834. appl/demo/camera/camera.b +2557 −0
  835. appl/demo/camera/camload.bit +0 −0
  836. appl/demo/camera/camproc.bit +0 −0
  837. appl/demo/camera/mkfile +42 −0
  838. appl/demo/camera/runcam.sh +3 −0
  839. appl/demo/camera/runcamlocal.sh +3 −0
  840. appl/demo/camera/tkinterface.b +2508 −0
  841. appl/demo/chat/chat.b +203 −0
  842. appl/demo/chat/chatclient.sh +20 −0
  843. appl/demo/chat/chatsrv.b +268 −0
  844. appl/demo/chat/mkfile +30 −0
  845. appl/demo/cpupool/mkfile +26 −0
  846. appl/demo/cpupool/regpoll.b +63 −0
  847. appl/demo/cpupool/runrstyx.sh +50 −0
  848. appl/demo/lego/clockface.b +367 −0
  849. appl/demo/lego/clockreg.sh +17 −0
  850. appl/demo/lego/firmdl.b +294 −0
  851. appl/demo/lego/legolink.b +601 −0
  852. appl/demo/lego/mkfile +36 −0
  853. appl/demo/lego/rcxsend.b +240 −0
  854. appl/demo/lego/rcxsend.m +4 −0
  855. appl/demo/lego/styx.srec +329 −0
  856. appl/demo/lego/timers.b +263 −0
  857. appl/demo/lego/timers.m +15 −0
  858. appl/demo/mkfile +14 −0
  859. appl/demo/ns/mkfile +27 −0
  860. appl/demo/ns/ns.b +124 −0
  861. appl/demo/ns/runns.sh +7 −0
  862. appl/demo/odbc/mkfile +31 −0
  863. appl/demo/odbc/odbcmnt.b +428 −0
  864. appl/demo/odbc/runodbc.sh +17 −0
  865. appl/demo/spree/mkfile +23 −0
  866. appl/demo/spree/spreeclient.sh +44 −0
  867. appl/demo/whiteboard/mkfile +28 −0
  868. appl/demo/whiteboard/runwb.sh +7 −0
  869. appl/demo/whiteboard/wbsrv.b +268 −0
  870. appl/demo/whiteboard/whiteboard.b +605 −0
  871. appl/ebook/checkxml.b +132 −0
  872. appl/ebook/cssfont.b +179 −0
  873. appl/ebook/cssfont.m +9 −0
  874. appl/ebook/cssparser.b +143 −0
  875. appl/ebook/cssparser.m +11 −0
  876. appl/ebook/dtd/oebdoc101.dtd +524 −0
  877. appl/ebook/dtd/oebpkg101.dtd +280 −0
  878. appl/ebook/ebook.b +1893 −0
  879. appl/ebook/mimeimage.b +96 −0
  880. appl/ebook/mimeimage.m +7 −0
  881. appl/ebook/mkfile +36 −0
  882. appl/ebook/oebpackage.b +276 −0
  883. appl/ebook/oebpackage.m +34 −0
  884. appl/ebook/reader.b +1797 −0
  885. appl/ebook/reader.m +120 −0
  886. appl/ebook/strcache.m +6 −0
  887. appl/ebook/strmap.b +40 −0
  888. appl/ebook/strmap.m +12 −0
  889. appl/ebook/stylesheet.b +156 −0
  890. appl/ebook/stylesheet.m +42 −0
  891. appl/ebook/table.b +176 −0
  892. appl/ebook/table.m +11 −0
  893. appl/ebook/tst.txt +379 −0
  894. appl/ebook/understandingoeb.opf +65 −0
  895. appl/ebook/units.b +146 −0
  896. appl/ebook/units.m +6 −0
  897. appl/grid/README +2 −0
  898. appl/grid/blurdemo.b +977 −0
  899. appl/grid/cpupool.b +917 −0
  900. appl/grid/demo/block.b +212 −0
  901. appl/grid/demo/blur.b +654 −0
  902. appl/grid/demo/mkfile +32 −0
  903. appl/grid/find.b +262 −0
  904. appl/grid/jpg2bit.b +47 −0
  905. appl/grid/lib/announce.b +42 −0
  906. appl/grid/lib/browser.b +1178 −0
  907. appl/grid/lib/browser.m +97 −0
  908. appl/grid/lib/fbrowse.b +390 −0
  909. appl/grid/lib/mkfile +27 −0
  910. appl/grid/lib/pathreader.m +3 −0
  911. appl/grid/lib/srvbrowse.b +719 −0
  912. appl/grid/mkfile +56 −0
  913. appl/grid/query.b +399 −0
  914. appl/grid/readjpg.b +1146 −0
  915. appl/grid/register.b +239 −0
  916. appl/grid/reglisten.b +305 −0
  917. appl/grid/regstyxlisten.b +279 −0
  918. appl/grid/remotelogon.b +427 −0
  919. appl/grid/usercreatesrv.b +93 −0
  920. appl/lib/NOTICE +25 −0
  921. appl/lib/arg.b +118 −0
  922. appl/lib/asn1.b +1030 −0
  923. appl/lib/attrdb.b +486 −0
  924. appl/lib/attrhash.b +109 −0
  925. appl/lib/auth.b +326 −0
  926. appl/lib/auth9.b +342 −0
  927. appl/lib/bloomfilter.b +72 −0
  928. appl/lib/bufio.b +534 −0
  929. appl/lib/cfg.b +234 −0
  930. appl/lib/cfgfile.b +152 −0
  931. appl/lib/chanfill.b +52 −0
  932. appl/lib/complete.b +92 −0
  933. appl/lib/convcs/8bit_stob.b +24 −0
  934. appl/lib/convcs/big5_btos.b +87 −0
  935. appl/lib/convcs/big5_stob.b +93 −0
  936. appl/lib/convcs/convcs.b +165 −0
  937. appl/lib/convcs/cp932_btos.b +179 −0
  938. appl/lib/convcs/cp_btos.b +45 −0
  939. appl/lib/convcs/cp_stob.b +49 −0
  940. appl/lib/convcs/euc-jp_btos.b +162 −0
  941. appl/lib/convcs/gb2312_btos.b +70 −0
  942. appl/lib/convcs/genbig5.b +1790 −0
  943. appl/lib/convcs/gencp.b +28 −0
  944. appl/lib/convcs/gencp932.b +7814 −0
  945. appl/lib/convcs/gengb2312.b +1143 −0
  946. appl/lib/convcs/genjisx0201kana.b +117 −0
  947. appl/lib/convcs/genjisx0208-1997.b +6958 −0
  948. appl/lib/convcs/genjisx0212.b +6146 −0
  949. appl/lib/convcs/ibm437.b +34 −0
  950. appl/lib/convcs/ibm850.b +34 −0
  951. appl/lib/convcs/ibm866.b +34 −0
  952. appl/lib/convcs/iso8859-1.b +42 −0
  953. appl/lib/convcs/iso8859-10.b +43 −0
  954. appl/lib/convcs/iso8859-15.b +42 −0
  955. appl/lib/convcs/iso8859-2.b +42 −0
  956. appl/lib/convcs/iso8859-3.b +42 −0
  957. appl/lib/convcs/iso8859-4.b +42 −0
  958. appl/lib/convcs/iso8859-5.b +42 −0
  959. appl/lib/convcs/iso8859-6.b +42 −0
  960. appl/lib/convcs/iso8859-7.b +42 −0
  961. appl/lib/convcs/iso8859-8.b +42 −0
  962. appl/lib/convcs/iso8859-9.b +42 −0
  963. appl/lib/convcs/koi8-r.b +43 −0
  964. appl/lib/convcs/mkdata +40 −0
  965. appl/lib/convcs/mkfile +29 −0
  966. appl/lib/convcs/utf16_btos.b +66 −0
  967. appl/lib/convcs/utf16_stob.b +47 −0
  968. appl/lib/convcs/utf8_btos.b +34 −0
  969. appl/lib/convcs/utf8_stob.b +17 −0
  970. appl/lib/convcs/windows-1250.b +26 −0
  971. appl/lib/convcs/windows-1251.b +34 −0
  972. appl/lib/convcs/windows-1252.b +26 −0
  973. appl/lib/crc.b +45 −0
  974. appl/lib/crypt/mkfile +24 −0
  975. appl/lib/crypt/pkcs.b +572 −0
  976. appl/lib/crypt/ssl3.b +5557 −0
  977. appl/lib/crypt/sslsession.b +176 −0
  978. appl/lib/crypt/x509.b +4125 −0
  979. appl/lib/csv.b +86 −0
  980. appl/lib/daytime.b +511 −0
  981. appl/lib/db.b +253 −0
  982. appl/lib/dbm.b +463 −0
  983. appl/lib/dbsrv.b +124 −0
  984. appl/lib/debug.b +1496 −0
  985. appl/lib/deflate.b +1453 −0
  986. appl/lib/devpointer.b +123 −0
  987. appl/lib/dhcpclient.b +1029 −0
  988. appl/lib/dial.b +384 −0
  989. appl/lib/dialog.b +190 −0
  990. appl/lib/dict.b +57 −0
  991. appl/lib/dis.b +609 −0
  992. appl/lib/diskblocks.b +122 −0
  993. appl/lib/disks.b +363 −0
  994. appl/lib/dividers.b +242 −0
  995. appl/lib/ecmascript/builtin.b +1480 −0
  996. appl/lib/ecmascript/date.b +495 −0
  997. appl/lib/ecmascript/ecmascript.b +2626 −0
  998. appl/lib/ecmascript/exec.b +863 −0
  999. appl/lib/ecmascript/mkfile +23 −0
  1000. appl/lib/ecmascript/obj.b +836 −0
  1001. appl/lib/ecmascript/pprint.b +378 −0
  1002. appl/lib/ecmascript/regexp.b +1286 −0
  1003. appl/lib/ecmascript/uri.b +140 −0
  1004. appl/lib/encoding/base16.b +43 −0
  1005. appl/lib/encoding/base32.b +60 −0
  1006. appl/lib/encoding/base32a.b +57 −0
  1007. appl/lib/encoding/base64.b +92 −0
  1008. appl/lib/encoding/mkfile +16 −0
  1009. appl/lib/env.b +91 −0
  1010. appl/lib/ether.b +83 −0
  1011. appl/lib/exception.b +59 −0
  1012. appl/lib/factotum.b +521 −0
  1013. appl/lib/filepat.b +169 −0
  1014. appl/lib/format.b +147 −0
  1015. appl/lib/fsfilter.b +67 −0
  1016. appl/lib/fslib.b +400 −0
  1017. appl/lib/fsproto.b +385 −0
  1018. appl/lib/gamer.b +147 −0
  1019. appl/lib/hash.b +80 −0
  1020. appl/lib/html.b +664 −0
  1021. appl/lib/ida/NOTICE +33 −0
  1022. appl/lib/ida/ida.b +228 −0
  1023. appl/lib/ida/idatab.b +65549 −0
  1024. appl/lib/ida/idatab.dist +0 −0
  1025. appl/lib/ida/idatest.b +84 −0
  1026. appl/lib/ida/mkfile +21 −0
  1027. appl/lib/ida/mktab.b +32 −0
  1028. appl/lib/imageremap.b +738 −0
  1029. appl/lib/inflate.b +820 −0
  1030. appl/lib/ip.b +656 −0
  1031. appl/lib/ipattr.b +217 −0
  1032. appl/lib/ir.b +95 −0
  1033. appl/lib/irmpath.b +118 −0
  1034. appl/lib/irsage.b +99 −0
  1035. appl/lib/irsim.b +83 −0
  1036. appl/lib/itslib.b +45 −0
  1037. appl/lib/json.b +619 −0
  1038. appl/lib/keyset.b +89 −0
  1039. appl/lib/libc.b +148 −0
  1040. appl/lib/libc0.b +249 −0
  1041. appl/lib/lists.b +142 −0
  1042. appl/lib/lock.b +26 −0
  1043. appl/lib/login.b +175 −0
  1044. appl/lib/man.b +139 −0
  1045. appl/lib/memfs.b +46 −0
  1046. appl/lib/mkfile +247 −0
  1047. appl/lib/mpeg.b +148 −0
  1048. appl/lib/msgio.b +152 −0
  1049. appl/lib/names.b +154 −0
  1050. appl/lib/nametree.b +277 −0
  1051. appl/lib/newns.b +465 −0
  1052. appl/lib/ninep.b +914 −0
  1053. appl/lib/oldauth.b +344 −0
  1054. appl/lib/palm.b +504 −0
  1055. appl/lib/palmdb.b +576 −0
  1056. appl/lib/palmfile.b +703 −0
  1057. appl/lib/parseman.b +806 −0
  1058. appl/lib/plumbing.b +254 −0
  1059. appl/lib/plumbing.m +23 −0
  1060. appl/lib/plumbmsg.b +190 −0
  1061. appl/lib/pop3.b +290 −0
  1062. appl/lib/popup.b +124 −0
  1063. appl/lib/powerman.b +59 −0
CHANGES+931−0
@@ -0,0 +1,931 @@
120121205
2 appl/cmd/mk/mksubdirs [issue 290 change suggested by powerman]
320120918
4 remove unused/unusable debug/setdebug from appl/lib/auth9.b; use crypt not keyring
520120820
6 emu/port/devip.c reset headers flag in Conv
720120725
8 increase KSTACK for Linux/arm
920120615
10 add configuration emu/FreeBSD/emu-g [powerman]
1120120509
12 utils/libmach: add missing user stack top initialisers, minor changes to sync with 9
1320120507
14 mkfiles/mkfile-MacOSX-386 change cc to gcc
15 emu/MacOSX/win.c null out drawcursor
1620120424
17 utils/cc/Posix.c and utils/c2l/Posix.c: correct definition of mydup for POSIX dup/dup2
18 libbio/bprint.c error handling if flush or print fails
1920120305
20 add -I$ROOT/(Plan9|Inferno)/include to CFLAGS in mkfiles/^(mkfile-Plan9* mkfile-Inferno*)
21 change specific object type to $OBJTYPE in the same
22 libmath/fdlibm/fdlibm.h and libmath/dtoa.c, if USE_FPdbleword defined, use FPdbleword to crack doubles into integers
2320120304
24 rabin(2) added (preliminary)
2520120213
26 styxservers: add .error operation (preliminary)
2720120116
28 lib9.h: internally rename qsort as infqsort to avoid C library clash
29 lib9/qsort.c: include lib9.h
30 lib9/mkfile: move qsort to IMPORTFILES from COMMONFILES
3120120103
32 avoid re-defining isnan; use isNaN instead
3320111231
34 Linux/*/include/emu.h adjustments for USE_PTHREADS for non-x86 processors
3520111221
36 add `...` uninterpreted string literals to limbo/lex.c, appl/cmd/limbo/lex.b
3720111215
38 liblogfs,libnandfs: use logfsos.h (added to include) to make library source independent of os
39 add fonts/vera
40 add fonts/courier
4120111214
42 change Linux port to use pthreads instead of clone directly
43 emu/Linux: rename os.c to os-clone.c; rename osp.c to os.c
44 emu/Linux/mkfile: remove -lrt, add kproc-pthreads.$O
45 Linux/*/include: define USE_PTHREADS
46 Linux/386/include/emu.h: increase KSTACK to 32k for Linux gethost* functions
4720111003
48 libinterp/heap.c:/^dtype discount size of map [issue 258]
4920110820
50 emu/*/devfs.c, emu/port/devfs-posix.c - stubs for osdisksize, Linux implementation of osdisksize
51 emu/port/devfs-posix.c - also try SOCK_DGRAM for AF_UNIX [issue 269]
5220110819
53 appl/cmd/mk/mk.b - use raise "fail:..." for exit status [issue 268]
5420110629
55 change x86 getcallerpc to avoid use of %ebp [issue 266]
56 change type of getcallerpc to uintptr from ulong
5720110619
58 emu/port/devfs-posix.c: put major/minor st_dev into path without mapping (with luck)
59 emu/port/kproc-pthreads.c: ensure pthread stack is at least PTHREAD_STACK_MIN (plus slop)
6020110526
61 change osyield in Windows to use SwitchToThread instead of sleep(0) [e-mail list]
6220110525
63 utils/[5678kqv]c/mkfile - include -I. before $CFLAGS to ensure right gc.h [issue 264]
6420110516
65 merge changes from vac branch of mechiel-inferno-os (googlecode)
6620110426
67 emu/Linux/asm-arm.S linux system call interface changed [issue 215, mechiel]
6820110419
69 libinterp/tk.c:/^Tk_rect shouldn't return non-canonical rectangles
70 /appl/wm/mand.b handle reshape to empty rectangles
7120110408
72 appl/lib/json.b - have writeval produce same (correct) form as .text for Real [issue 230]
7320110407
74 fix embarrassingly broken Lists->delete; add Lists->find [issue 257]
75 add some extra explanation to sys-dup(2) about fildes
7620110404
77 update Nt/386/bin
78 /limbo/com.c - count constants in qualifiers, not qualifiers [issue 212, mechiel]
79 /appl/cmd/limbo/com.b [also issue 212]
8020110403
81 secstore(2) and secstore(1) updated to implement writing [issue 256, mechiel]
8220110402
83 revision to devsrv.c change [issue 244] to avoid two calls to delwaiting
8420110330
85 call strtol not atoi for hex numbers [issue 255, mechiel]
8620110329
87 utils/mkdir/mkdir.c - add -p option [mechiel, issue 250]
88 emu/Linux/mkfile - try searching -lpthread after -lrt for sem_* [issue 247]
89 emu/port/devfs-posix.c - treat unix domain sockets as files (open/read/write/close) [npe, rsc, issue 254]
90 emu/port/devfs-posix.c - use volatile correctly; slight code tidy
91 emu/lib9/errstr-posix.c replace EINTR's error string by Eintr's text
9220110315
93 libtk/textw.c - fix mysterious control characters for editing (D and K) [issue 253, fix from mechiel]
9420110225
95 split emu.h from lib9.h for all platforms
96 kproc in emu is now a void type as in os
9720110224
98 move private mem flag to Progs [issue 240, mechiel]
9920110224
10020110208
101 emu/Linux/os.c - use -lrt's semaphores instead of signals
102 emu/Linux/mkfile - add -lrt to library list, and push out separation of X11LIBS from SYSLIBS for emu-g done ages ago
10320110126
104 emu/MacOSX/os.c - move a free to a more sensible place
10520110117
106 emu/Nt/ipif.c changed to work with ipv6 interface changes
10720110116
108 add Plan9/arm support [provided by richard miller]
10920110110
110 utils/libmach/qdb.c [issue 245] restore renaming of qdiv as qmuldiv
11120110104
112 emu/MacOSX/win.c detect double clicks [issue 232, jas]
113 emu/MacOSX/os.c replace erendezvous by a per-kproc semaphore for osblock/osready
11420101220
115 changes to srv(3) to notify client when server vanishes [issue 244, thanks to powerman and roger]
11620101205
117 change a few types in ipif-posix.c to appease the gods
118 emu/MacOSX/mkfile - include portmkfile at correct point for LIBFILES to work (and other, minor, changes) [issue 24]
11920101127
120 emu/port/*ip*.[ch] and emu/Nt/ipif*.c updated with new interface for ipv6 support [mechiel] [issue 193]
121 emu/Linux/os.c address compilation warnings (setfcr etc still to do)
12220101125
123 asm/assem.c don't attempt to use missing src (issue 243)
12420100925
125 appl/lib/w3c/uris.b - handle existing Unicode characters if they happen not to have been encoded into string
126 appl/svc/httpd/parser.b - similar [response to issue 233]
12720100914
128 emu/Nt/os.c - replace trap handling
12920100822
130 correct handling of mouse focus in sub-widgets of widget windowed in text [issue 241]
131 add various warnings to mkfile-Linux-386
13220100821
133 correct handling of mouse focus in sub-widgets of widget windowed in canvas [issue 241]
13420100819
135 failed to push Solaris/sparc/include/lib9.h with u64int change [issue 151]
136 appl/cmd/ar.b eliminate false error return
13720100810
138 initial introduction of crypt-*(2) and ipints(2)
139 replace keyring.m in module/runt.m by ipints.m and crypt.m; compensate in libinterp and libkeyring by using keyringif.m to generate Keyring's interface
14020100802
141 various changes held back by accident, notably stackv in stack(1), better diagnostics by cat(1)
14220100801
143 libtk/coval.c - simplify vlong expression for some compilers [issue 216, mechiel]
14420100727
145 on Linux and MacOSX, look at faulting address to decide if it's dereference of nil
14620100722
147 include/bio.h add varargck and repair resulting diagnostics in utils and limbo/ [issue 237, mechiel]
14820100719
149 appl/cmd/disk/mkfs.b change getname/getpath to cope with missing newline [issue 236]
15020100715
151 appl/wm/toolbar.b changed not to create new /chan/snarf if one exists, unless -p (private) option given [toolbar(1)]
152 utils/cc/macbody - add overlooked change to implement __VA_ARGS__
153 other minor updates to the compilers to resync
15420100714
155 correctly initialise types in utils/cc/sub.c
15620100504
157 change lib9/strtoull.c for MS
15820100503
159 updated libmach/8db.c to avoid [] initialisers
16020100501
161 update libmach to compensate for MS compiler
16220100426
163 updated libmach
164 updated compiler suites (continuing)
16520100425
166 appl/wm/wm.b shorten processing of wmctl close if client hadn't started
16720100406
168 fix handling of boundary case in libtk/utils.c
16920100402
170 add new option OPTflags to libtk for later use
17120100325
172 more swizzling of libtk for later use. revised radio and check buttons.
17320100322
174 a few tweaks to Tk for later use
17520100320
176 appl/lib/json.b dis/lib/json.dis - use %f not string <real-value> to ensure json value acceptable [issue 230, powerman]
17720100310
178 stop tabs(2) from issuing pointless tk cmd that produces diagnostics
17920100305
180 add emu/Linux/audio-oss.c from saoret.one [issue 226]
18120100226
182 mention -n nvram option in keyfs(4)
18320100220
184 appl/cmd/keyfs.b wasn't clunking fids on error in remove [issue 225]
18520100213
186 apply saoret.one's changes for thumb [issue 155]
18720100205
188 update man pages to replace most references to Styx by 9P
189 update man pages to replace references to sys-dial(2) by dial(2)
190 add DragonFly files (from fgudin and extrudedaluminiu, issue 181); possibly should automatically keep aligned with FreeBSD
191 fpe handling in OpenBSD and FreeBSD [mechiel, issue 190]
192 appl/cmd/vacfs.b apply fix from mechiel [issue 204]
19320100203
194 appl/lib/cfg.b treat \r as white space [issue 69, issue 70]
195 add u64int to lib9.h files that needed it
196 add sha2.c sha256block.c sha512block.c to libsec/port and include/libsec.h [issue 185, mechiel]
197 add new sha functions to module/keyring.m and libinterp/keyring.c
19820100115
199 appl/cmd/tarfs.b man/4/tarfs changes to permission handling from mechiel [issue 220]
200 appl/spree/mkfile add explicit -I$ROOT/module [issue 209, powerman]
20120100110
202 appl/cmd/tcs.b [issue 12, arvindht]: process unconverted bytes next cycle, flush conversion state; improve error checking
20320091219
204 change default roots in Nt utils to c:\inferno
20520091215
206 factotum(2) updated to include keyspec in signature
207 appl/cmd/mount.b uses -k value as keyspec if -9 selected [not to much purpose with current factotum's p9any]
208 bind(1) [for mount] updated to describe -k used for keyspec if -9 selected
20920091214
210 switch more commands to use dial(2)
211 change emu/Linux/emu-g not to require X11 libs (again)
21220091213
213 temper the tendancy of port/dis.c to yield during idle gc: it's compensating for os scheduling, but yield less often
21420091208
215 add mkdir -p to makemk.sh to ensure output directories exist [issue 213]
21620091127
217 problems fixed in styxconv(2), which can now convert both ways [rog]
21820091119
219 emu/port/devfs-posix.c missing waserror in dirread (obscure but possible failure)
22020091007
221 remove intermediate exception-raising function from charon implementation
22220091004
223 restore "keyring" to lib section of emu/Plan9/emu
22420090930
225 emu/*/ipif*.c make "hangup" act as in native Inferno; also delete unused so_setsockopt
226 provide correct version of devmnt.c
22720090928
228 update import(4) to remove the restriction to Plan 9 (can use Inferno's own factotum)
229 (emu os)^/port/devmnt.c fix from plan 9 (don't access vanished data)
23020090830
231 check subexp length in ed [cmbrannon79]
23220090825
233 add netmkaddr call to /appl/cmd/ftpfs.b; send errors to standard error
23420090824
235 delete unused (and somewhat incomplete) pin support
23620090822
237 in the what were we thinking dept: appl/cmd/touch.b and dis/touch.dis updated to avoid using an Arg after nil'ing it [thanks to cmbrannon]
238 make progmode propagate to pgrps; recover from exceptions in pgrp creation
23920090821
240 emu/Nt/^(os.c ie-os.c) add #include <excpt.h>
24120090819
242 appl/cmd/mk/mk.b replace maketmp/mktemp (issue 202, mechiel); also old change: don't persist with bulkmtime on non-directories
24320090816
244 registry(4) Event.post increased rootvers when entries are written or removed (issue 179, powerman)
24520090809
246 bring mkfs(8) up to date (issue 176)
247 remove -q options from mkfs and mkext (-q was a transitional option to suppress quoting of file names)
24820090806
249 increase `backlog' value in all listen calls in hosted Inferno (emu/*/ipif*.c) [powerman]
25020090805
251 further checking added to libinterp/keyring.c: rejects incorrect states and out of bounds values of f->n
252 add lib/emptydirs and mkdirs target to /mkfile (utils/mkdir needs to be changed for Windows use)
25320090730
254 improve the error checking in strtosk and strtopk to help detect mangled or inappropriate keys
25520090728
256 emu/port/main.c: put host's working directory name as emuwdir
257 document initial environment variables in emu(1)
258 appl/lib/bufio.b dis/lib/bufio.dis [issue 199] don't lose track of actual file seek offset (following second suggestion of mjl)
259 issue 196: after general apologies for appl/svc/httpd/cache.b (don't look if you don't need it, not one of ours, etc. etc.) will patch as suggested by extrudedaluminiu(!) [vs]
26020090719
261 correct order of operands to memset(!), eg in ipif [mjl]
26220090718
263 fix appl/cmd/stream.b error exits to include fail: [mjl]
26420090717
265 fix appl/lib/ip.b (see issue 186) [mjl]
266 re-enable XK_ keys in port/win-x11a.c [mjl]
26720090716
268 add segflush calls to comp-386.c [probably need different name eventually to avoid time wasting when not needed]
26920090630
270 add sig (see man(1)) [via p9p and caerwyn]
27120090627
272 push changes described for arm in 20090330 (but not previously pushed)
273 begin change of inferno-os.googlecode.com from svn to mercurial
274200090612
275 added support for Linux-power (ericvh; and further simplified)
27620090605
277 appl/cmd/disk/kfs.b dis/disk/kfs.dis - don't try to update super block if readonly(!) [issue 175]
27820090526
279 emu/Nt/os.c allow /dev/hoststdin input on file or pipe (thanks to caerwyn, issue 173)
280 emu/port/devfs-posix.c correct handling of error return from pread (issue 172, but goes beyond that)
281 emu/port/exportfs.c os/port/exportfs.c use vlong for offset
28220090524
283 appl/cmd/tarfs.b dis/tarfs.dis - remove accidentally small limit on file size in tar file (issue 172)
28420090521
285 module/vac.m appl/cmd/vacfs.b appl/lib/vac.b [issue 152] (Mecchiel)
28620090505
287 add -h/-t header/trailer options to man2html
28820090430
289 filter-deflate(2), appl/lib/^(inflate.b deflate.b): changes from mjl to support zlib headers for deflate streams as well as gzip's
29020090417
291 add m4(1) in its initial form (might split the macro processing proper off into a library module)
29220090409
293 tools/odbc/odbc.c data read should return 0 if no columns or rows (issue 170)
29420090408
295 tools/odbc/odbc.c use strecpy and more care in allocation (issue 169)
29620090403
297 change ,2 to ,#function in Solaris sparc assembler files (apparently works in gcc and sun's)
298 make appl/wm/brutus.b pass input to its widgets (issue 105)
299 enable fullscreen mode in MacOSX (issue 148)
30020090402
301 add missing emu/Linux/segflush-*.c files and remove ARM segflush from os.c
30220090402
303 ramfile and logfile shouldn't set Sys->MCREATE (issue 137)
30420090401
305 appl/cmd/limbo/typecheck.b check correctly for function prevented from inline expansion
30620090330
307 use (low, high) order for words in vlong and fp on arm: libinterp/comp-arm.c, Inferno/arm/include/^(lib9.h u.h)
308 also os/*/fpi.h (for arm platforms), exchanging order of ulongs in Double
309 also libkern/^(vlrt-arm.c vlop-arm.s vlop-thumb.s frexp-arm.c frexp-thumb.c)
310 include changes from richard miller for little-endian mips (spim) and Linux/spim hosted
311 libmath/dtoa.c: use simpler code to avoid gcc bug on mips and perhaps other platforms (rmiller)
31220090330-branches/forse
313 include appl/cmd/ssh source (won't compile here because it needs the keyring changes)
31420090325-branches/forse
315 emu/* adopt changes to Chan (Dev* dev pointer instead of int type)
31620090320
317 emu/port/win-x11a.c: unintuitively use xdisplay not xkbdcon to send to kbdproc (with big stack) to change cursor
318 (the big stack is needed because XCreateBitmapFromData and XPutImage pass control to theme-related code that uses lots of stack space)
319 use uname not aname for user name in libstyx and set aname to "" by default
320 make odbc's new file have mode 666 so others can open it
321 add styxsetowner function to styxserver.h to set default owner (eve)
322 move styxserver.h to inferno's include directory
32320090222
324 appl/cmd/ndb/registry.b and dis/registry.dis - implement flush for event file (issue 162)
32520090217
326 appl/cmd/limbo/stubs.b limbo/stubs.c - include length parameter to builtinmod (could just be 0 in most cases)
327 change f->ret/destroy code in stubs.c/stubs.b to destroy correctly in case of exceptions
32820090202
329 emu/port/win-x11a.c: might as well try this everywhere now
33020090127
331 libinterp/xec.c: fix gc problem with self
33220090122
333 libinterp/string.c: slicer can return H for empty slice after bounds check (brucee)
33420081119
335 os/pc/^(main.c fns.h) more idle idlehands
33620081112
337 emu/Linux/asm-arm.S old failure to use different regs for swp finally changed here
338 libmath/blas.c compensate for gcc bug on arm
33920081107
340 replace calls to calloc by malloc
34120081106
342 os/port/dis.c prevent new spawns during killgrp
343 also synchronise two killgrps of the same group
34420081105
345 emu/port/dis.c prevent new spawns during killgrp [#117]
34620081022
347 sh: ignore leading white space in fail: strings, and change empty tail to "failed"
348 /emu/port/devfs-posix.c don't call readdir after it has returned end of file
34920081021
350 /appl/cmd/auth/ai2key.b new command to convert authinfo files to factotum keys
351 /appl/cmd/auth/factotum/proto/infauth.b allow new key format
35220081019
353 /appl/cmd/man2html.b implement "\ " => "&nbsp;"
354 /man/3/prog change way a literal " was formatted
355 /man/8/srv deleted (obsolete)
356 removed reference to srv(8) from sys-pctl(2)
35720080909
358 /appl/cmd/puttar.b add extra empty block at end of archive as required by format
35920080907
360 include some changes from acme-sac in emu/Nt/devfs.c; need further control of usesec (or discard it)
36120080723
362 rename Inferno's yacc to iyacc to avoid clash with system's own (now that Linux and others distribute it)
36320080707
364 update emu/port/win-x11a.c (fix someone's earlier patch to stop using undefined value)
365 emu/port/main.c mark obsolete options and remove from usage
36620080705
367 update utils/sed, eliminating anonymous unions (just by commenting them out, to keep source in step with 9)
368 and several other changes for portability
36920080703
370 remove anonymous unions (and unused structs) from unpacking structures in emu/Nt/vlrt.c, not that it's used
37120080617
372 win-x11a.c add sqweek's change to pass on KeyRelease values (but perhaps 1-byte values are no longer enough?)
37320080614
374 change os/port/devcons.c to use error not panic in sysfatal
37520080612
376 change several libmp/port functions to use sysfatal not abort
377 change emu/port/main.c to have sysfatal call error not exit
37820080611
379 Keyring->dhparams to use DSAprimes in special case
380 IPint.random now ignores minint (will go next revision)
381 BigInt -> mpint*
382 checkIPint in libinterp/ipint.c
383 default keys in auth/createsignerkey are 1024 not 512 bits
384 update os/boot/pc
38520080610
386 push sh-mload(1) and changes to sh-expr(1)
38720080609
388 _tas type changed from ulong to int
38920080530
390 issue 91: _declspec changed to __declspec in Nt files
391 issue 92: argv0 declaration changed to extern from static in emu/Nt/win.c
39220080529
393 limbo/stubs.c: allow pick adt types
39420080528
395 emu/port/win-x11a.c screen depth checks from drawterm via tim@nop.cx
39620080524
397 add missing NetBSD files
39820080522
399 dis/lib/msgio.dis appl/lib/msgio.b - fix incorrect check for 16rFF
400 add OpenBSD changes from tim@nop.cx (more changes to follow shortly that cause changes elsewhere)
40120080416
402 fix emu/Nt/os.c use of wrong name for null value
403 move win/win-x11a references to emu/*/emu config files from emu/*/mkfile
40420080415
405 googlecode update with correct dis files for acme
406 tidier code for hoststderr
407 emu/port/win-x11a.c changes that attempt to satisfy libxcb's locking requirements
40820080322
409 enable hoststderr, following acme-sac
41020080319
411 ip/sntp neither read nor set the time correctly
41220080311
413 in appl/lib/names.b define "" as valid prefix for anything
41420080304
415 auth/secstore uses dial module
41620080210
417 add auth/dsagen
41820080204
419 emu/*/*ipif*.c and devip.c: try to allow local address to be set (changes so_bind signature in emu/ip.h)
42020080201
421 change foldbranch in limbo/gen.c to prevent loss of `no return value' diagnostics
42220080131
423 update emu/Nt/^(os.c ie-os.c ie-win.c ie emu), but properly this time [issue 81]
424 remove _USE_32BIT_TIME_T from Nt/386/include/lib9.h, and time() def'n from emu/Nt/*.c [issue 81]
42520080130
426 failed to return nil from Jvalue.get in appl/lib/json.b if member name didn't match
427 similar problem in appl/lib/ubfa.b
428 add msgio(2)
42920080124
430 fix emu/port/devssl.c os/port/devssl.c not to keep the directory numbers(!)
43120080122
432 update appl/lib/db.b: allow for split i/o on pipes or tcp/ip; eliminate lock process
433 eliminate more unused identifier warnings (courtesy acme-sac)
43420080121
435 skip trailing '=' in b64 rep of IPint
43620080120
437 forgot to push updated appl/lib/x509.b during keyring changes
43820080116
439 add rsa to factotum
440 set but not used changes from Acme-sac
441 mdb(1) changes from Acme-sac
442 ftpfs uses new dial(2)
443 add qbypass to emu/port/qio.c
444 sed fix issue 49
445 add blowfish to keyring-crypt(2)
446 add challenge/response to factotum(2)
44720080115
448 add blowfish to keyring (not yet documented)
449 add explicit public and private key types to keyring (in development: not yet documented)
450 add IPint.mod, IPint.iptob64z
45120080111
452 add newuser to newns(2)
45320080109
454 Sys->iounit should accept any valid file descriptor, not just ORDWR
45520071227
456 add styxflush(2) etc.
457 add NetBSD, emu/NetBSD
45820071217
459 emu/port/devmnt.c needs volatile for alloc
46020071213
461 emu/port/dev.c needs volatile for alloc
46220071129
463 emu/port/devip.c: moan about bad IP addresses
46420071127
465 added /module/dial.m and /appl/lib/dial.b
46620071031
467 module/keyring.m and libinterp/keyring.c: add algorithm-specific adts for public key systems
468 appl/lib/spki/spki.b: correct names for dsa parameters
46920071030
470 libkeyring/rsaalg.c should call rsaprivfree not free
47120071027
472 appl/lib/names.b correction for "/" as prefix
47320071019
474 change emu/port/devfs-posix.c to update uid/gid map incrementally
47520071015
476 add cap creation to infauth in server role in factotum
47720071011
478 remove obsolete references to sh-exception(2)
47920071010
480 add abhey's changes for cmd key as unicode compose key for MacOS X to emu/MacOSX/win.c
48120071008
482 nemo's change to emu/port/random.c; really the file needs a little rewriting for clarity (too many overlapping states)
48320071002
484 ensure fmtdef.h included by some lib9 functions so that va_copy is defined on older systems that lack that needless notion
485 <{} and >{} added to sh(1)
48620070929
487 move emu/MacOSX/mkfile to .../mkfile-x11 and replace it by the variant that builds for Carbon, now the default
48820070927
489 add working drawcursor to emu/MacOSX/win.c, based on mirtchovski's changes (but mapping general cursor images to Mac's form)
49020070910
491 update spki(2) [change handling of hashes, add signature functions] appl/lib/spki/spki.b module/spki.m, updated for GSoC
49220070906
493 add toreal to string(2)
49420070905
495 /appl/cmd/ed.b (caerwyn's fix for g/.../d)
496 also /appl/lib/ecmascript/builtin.b (toupper fix)
49720070902
498 make /appl/lib/daytime.b accept Daytime->text's output; add string2tm to man page (issue 59)
49920070901
500 add andrey's changes to emu/MacOSX/win.c (used by emu/MacOSX/mkfile-a)
501 add saoret's changes to dis/lookman, dis/man (issue 58)
502 add micah.stetson's change to /appl/cmd/src.b (issue 57)
50320070817
504 two old changes that weren't in the distribution...
505 libkeyring/rsaalg.c: previously failed to ensure the output key was the right length (really rsagen should do that)
506 libinterp/alt.c: use a better random number generator
50720070814
508 bufio.b didn't update the buffer pointers correctly on write errors
50920070807
510 libinterp/keyring.c don't include owner= if owner is nil or ""
511 add auth/rsagen
51220070806
513 /module/lists.m add PATH(!), also simplify concat implementation
51420070725
515 /dis/man initialise fils correctly to empty list and remove hack (issue 56)
51620070720
517 utils/5l/asm.c: ensure SBZ field in MOV is regarded as MBZ (ie, force to zero)
51820070714
519 add Sys->readn, update sys-read(2)
520 copy two repairs from emu/port/inferno.c to os/port/inferno.c
521 remove readn implementation from several commands
522 print correct diagnostic in appl/cmd/crypt.b
523 prevent window titlebars from being dragged out of the main window in wm/wm.b
52420070619
525 remembered to include /appl/cmd/trfs.b /dis/trfs.dis
52620070614
527 /appl/lib/venti.b bug fixes, a few more errstrs, remove prints to stderr
528 add initial module/vac.m appl/lib/vac.b from mjl (gsoc project ventivac)
529 add initial /appl/cmd/^(vacfs.b vacget.b vacput.b) /man/4/vacfs /man/1/vacget from mjl (gsoc:ventivac)
530 include omitted man/mkfile man/lib
53120070608
532 update /lib9 functions to use silly va_copy (and then va_end) instead of just assigning, to account for silly C implementations
533 change /appl/cmd/mc.b not to require Draw or Env (so lc works on smaller systems)
534 update acme to include the font size data (eg, for use by mc(1))
53520070607
536 /appl/wm/man.b /appl/lib/man.b to allow 10.1 etc as section references
53720070605
538 add another xopen #define to lib9.h includes for Linux
539 copy plan9 acme's colormix
54020070601
541 /appl/cmd/ls.b /dis/ls.dis /man/1/ls: document new -F option and -T option
542 /appl/cmd/auth/factotum/factotum.b: ignore empty writes, don't fail; make a few diagnostics match plan 9
543 rename /appl/cmd/mc.b to /appl/cmd/calc.b; also /man/1/mc to /man/1/calc; /dis/mc.dis to /dis/calc.dis
544 add /appl/cmd/mc.b (initial version)
545 replace /dis/lc.dis by /dis/lc; remove /appl/cmd/lc.b
546 remove /appl/cmd/mathcalc.b /dis/mathcalc.dis /man/1/mathcalc
54720070510
548 quickly remove references to udp's "oldheaders" because plan 9 removed it
549 remove obootpd completely
55020070418
551 add scan code to X11 (issue 45)
55220070411
553 if mkconfig has been changed from the distribution, use it to set parameters in makemk.sh (issue 41)
554 add iso8859-15 (what? will the line stretch on to the crack of doom?) (issue 43)
55520070410
556 fix some porting errors in /appl/cmd/look.b
557 document look's -r option in look(1)
55820070407
559 /os/port/^(portdat.h lib.h portfns.h xalloc.c) compatiblity changes with plan 9
560 /os/pc ether drivers updated to match plan 9, and os/ip (and a few files in /os/port) also updated, including removing some unreachable code
561 /os/ip/tcp.c changes from plan 9 for out-of-sequence segments
56220070319
563 emu/port/devsrv.c and os/port/devsrv.c delete wc at correct time
56420070312
565 rename -D and -k options to plumb (old ones still accepted); add -i option to take data from standard input; update man page
566 enable 64-bit seeks in /emu/Nt/devfs.c
56720070302
568 change /mkfile to build yacc earlier, mainly to make bootstrap of a new host easier (makemk.sh and mk install)
569 change /utils/mkfile not to build k[acl] and q[acl] on Plan 9, since the system ones are the same
57020070228
571 make array bounds checking the default for on-the-fly compilers (emu/port/main.c)
572 improve wording in security-ssl(2) and ssl(3)
57320070227
574 /include/fcall.h: ensure unsigned promotion to counter ansi sign-extending rules for GBIT64
575 /libmemdraw/draw.c: copy fix to memfillcolor
57620070220
577 add 0x92 as chip ID for ether91c111.c
57820070217
579 repair /appl/lib/libc.b and /appl/lib/libc0.b strncmp implementations (used only by c2l output) [inferno-os issue 9]
580 /emu/port/devip.c, get socket fd on reopen of ctl
581 /appl/acme/exec.b, trim string correctly [inferno-os issue 11]
58220070216
583 add /module/lists.m, /appl/lib/lists.b, and lists(2)
58420070209
585 remove debugging -d option to exportfs call in emu/Plan9/devsrv9.c(!)
58620070206
587 /appl/svc/auth.sh: replace exit by raise
588 /man/2/styxservers: document replychan and replydirect
58920070201
590 update US timezone files to save energy
59120070131
592 add /appl/lib/convcs/utf16_btos.b, utf16_stob.b etc [rog]
59320070130
594 fix wording in some of the licence files (eg, remove references to old liberal licence)
59520070123
596 check lengths properly in devenv.c
597 move all of doc into lib/proto/inferno from lib/proto/src
59820070122
599 add doc/port.ms, doc/port.pdf to src proto. add brief instructions for source rebuild to port.ms
60020070118
601 add json(2) {/appl/lib/json.b, /module/json.m, /dis/lib/json.dis} for RFC4627 notation [json(6)]
60220070117
603 remove duplicate libmp/libsec reference from /mkfile (i assume it wasn't necessary to visit them twice!)
60420070116
605 move Man from /dis/man.dis (which vanished a few changes ago) to /dis/lib/man.dis. honestly. wm/man works again.
60620070114
607 remove some unused static declarations in /utils/mk/shprint.c
60820070111
609 delete drawxflush from devdraw.c (call drawq(un)?lock instead)
61020070107
611 have emu (/emu/port/main.c) check environment variables INFERNO and ROOT before EMU and -r, for inferno root directory
612 (haven't yet changed the build system and mkfiles to match)
613 remove /include/libcrypt_o.h since the library isn't used
614 add complete(2)
61520070103
616 replace man.dis by Salva Peiró's sh version of plan 9's man script
61720061221
618 add data2c to Irix package prototype
619 remove unwanted .dis/.sbl files from /appl packages
620 change liblogfs to GPLv2 from proprietary, to fit google code
621 correct cmd(3) to account for new stderr file
62220061219
623 cmd(3) and thus os(1) change to separate standard output and error streams
624 all /emu/*/cmd.c change to account for that (original changes to devcmd.c and MacOSX/cmd.c courtesy Cibernet)
62520061215
626 replaced things like <???> because gcc annoyingly whines even with 1950's trigraphs off
627 libtk/textu.c: uninitialised field in boundary case
628 libtk/textw.c: possibly uninitialised value; leave unchanged
629 utils/ql/l.h: uchar as to ushort, because of extra ops
63020061214
631 added fopen to xml.m to allow bufio->sopen and others to be used
63220061213
633 added MacOSX/386 components
63420061013
635 updated /os/ip/lookbackmedium.c and /os/ip/rudp.c
63620061021
637 change /os/port/exportfs.c to allow negotiating up to 64k msize
638 (matching /emu/port/exportfs.c)
63920060809
640 /appl/lib/newns.b uses String->unquoted, if it can load it
64120060803
642 /libtk/textw.c: default page up/down scrolls 0.75 of a page (to give context); also allows fractional value
64320060801
644 /utils/data2s/data2s.c: allocate at least one linker byte to empty files to avoid complaints
64520060715
646 /appl/lib/pop3.b remove defaultserver(); update pop3(2) to remove references to /services
647 similarly update smtp(2)
648 avoid some boundary cases in /appl/charon/^(build.b layout.b)
64920060625
650 added caerwynj@gmail.com changes to /appl/acme/acme/mail/src/Mailpop3.b
65120060622
652 /appl/lib/sets*.b: correct op's implementation of 2r1101
65320060613
654 added csv(2), /module/csv.m, /appl/lib/csv.b
65520060608
656 preliminary rfc822(2), /appl/lib/rfc822.b
65720060605
658 /appl/lib/chanfill.b: remove alt => *
65920060601
660 fix /appl/lib/dis.b to save the real array once read in
66120060526
662 /appl/lib/venti.b: fix g64's byte ordering [not that it is, or can be called yet]
66320060524
664 copy end fix to lib*/utfecpy.c
66520060523
666 w3c-uris(2): add a .copy() operation
66720060518
668 /Nt/386/include/lib9.h define _USE_32BIT_TIME_T and deprecate `deprecated' warnings
66920060504
670 remove use of HEAP_ALIGN from /*/port/devprof.c; change Heap.pad to Heap.hprof in /include/interp.h
67120060426
672 correct text and selection colours in wm/sh for loss-of-focus and holding modes
67320060423
674 add /appl/lib/w3c/uris.b w3c-uris(2) /module/uris.m
67520060419
676 /emu/port/devcmd.c: correct wakeup state for started command
67720060412
678 /appl/svc/webget include caerwyn's changes
67920060411
680 put `|| exit 1' after each (command-list) in the mkfiles, just for bash
68120060410
682 /appl/cmd/limbo/typecheck.b /limbo/typecheck.c - stop wrong warning wrt use of ref fn
68320060313
684 remembered to install cddb port from last year... cddb(7)
68520060312
686 /emu/Nt/win.c; #define windows names out of the way to remove IPoint etc
687 /emu/Nt/os.c, simplify osblock/osready and eliminate erendezvous
688 /emu/port/devcons.c, tug into line with /os/port, to prepare for single-window changes
689 echo ^U on CAN (ctrl-U)
69020060311
691 replace Limbo version of shutdown by sh script; it's still a bit silly
69220060309
693 /*/port/inferno.c: 0 or -1 return value from dial functions
694 /os/port/portmkfile: remove reference to ../kfs
695 /man/8/httpd document -a; /appl/svc/httpd/httpd.b
696 /libmp/port/mptouv.c sign extension fix from 9
697 /module/keyring.m, /libinterp/ipint.c: add some bitwise operators
698 change (undocumented) /appl/cmd/test.b so that `host' mkfiles will work in Inferno
699 should probably change the mkfiles to replace it
70020060303
701 /emu/Plan9/win.c replace ldepthof
70220060302
703 add KPX11 flag to hosted kproc to boost the stack for silly x11 & co.
704 put keyboard and cursor processing into a separate kproc with big stack in /emu/port/win-x11a.c
705 change various os.c to match
70620060301
707 /appl/cmd/rioimport.b fix initialisation race
70820060227
709 fix /utils/ql/l.h: oprange should be [ALAST] (with extra 405xx opcodes), also AEND->ALIST elsewhere
710 put faster gethunk in ql and kl (mimic other compilers)
71120060226
712 enable /emu/port/devpointer.c, with changes to /emu/*/win*.c to call mousetrack, /emu/port/main.c to bind #m,
713 and code for pointer and cursor removed from devcons.c
714 update Nt/win.c and port/win-x11a.c from drawterm to get/put host snarf buffer
715 change devmem.c from #m to #% not to clash with pointer
71620060225
717 add /emu/port/devsnarf.c (#^) and put clipread from drawterm in /emu/Nt/win.c
71820060224
719 modify /appl/lib/secstore.b, /module/secstore.m, secstore(2) [add dial, auth, mkseckey, mkfilekey, remove]
720 add /appl/cmd/auth/secstore.b, secstore(1)
721 remove strange exception handling in /appl/cmd/dd.b
722 add dhcpclient(2)
72320060223
724 add /appl/cmd/auth/aescbc.c
725 add /appl/cmd/crypt.b [rog]
726 add crypt(1)
727 add /appl/lib/secstore.b /module/secstore.m secstore(2)
72820060221
729 /libsec/port/hmac.c: treat existing but not seeded digest correctly
730 /libinterp/ipint.c, /module/keyring.m, add new operator `invert'
73120060220
732 add ida(2), /appl/lib/ida, /module/ida.m
73320060216
734 add ubfa(2), ubfa(6), /module/ubfa.m, /appl/lib/ubfa.b
73520060214
736 [rog] add cursor changing support to tk, wm, wmlib (eg, for acme)
73720060213
738 remove libcrypt_o from distribution
73920060211
740 add /man/1/9win [rog]
741 change /appl/cmd/auth/keyfs.b to confirm key only when creating the file [rog]
742 punt floating-point conversions in powerpc jit on macos for time being
743 (have particular values in certain FP registers when native)
74420060210
745 update /libmemdraw/draw.c to include 9's changes for concurrent use
746 remove canlock as assembly language interface, replaced by _tas
747 replace native use of tas by _tas; make declarations all agree
748 add holdon/holdoff ctl request to wm/sh
749 wmproxy in appl/lib/wmlib.b does not create new pgrp
75020060206
751 update /appl/cmd/cp.b with digbyt's changes (mode/uid/gid correct on copied directories)
75220060203
753 update /appl/cmd/ip/dhcp.b /appl/cmd/lib/dhcpclient.b
754 update /os/init/i4e.b to use it
755 add /man/8/dhcp
75620060118
757 add ksize(10.1), kstrip(10.1), /utils/kstrip
758 new _MAGIC definitions in utils/libmach/a.out.h
75920060114
760 change /os/boot/arm1110 mkfile to work on unix and windows; add to /lib/proto/os
76120060111
762 -s (exportonly) -x/-y (geometry) options to 9win (TODO: rog, manual page!)
763 wm/sh.b: correct hold mode; remove little-used and undocumented history file
76420060109
765 delete #pragma from flate.h
766 ensure lib9 compiles replacement sbrk for MacOSX
76720060106
768 update compilers
769 update compilers' manual page
770 fix os/port/portmkfile for Plan 9: don't use $OBJDIR but Inferno/$OBJTYPE
771 have os/port/portmkfile check for i$CONF.p9 and use that not i$CONF for acid
772 add srclist(10.1)
77320060105
774 account for new definition of rendezvous (void* not ulong)
775 add dummy setmalloctag to utils where needed (for Plan 9)
776 set profileflg only for ATEXT in utils/?c/txt.c
777 update /os/boot/pc
77820060103
779 /os/ip updated from Plan 9
780 /os/ip/^(bootp.c dhcp.c ihbootp.c) changed to use announce not connect for udp
78120051215
782 /man/6/keytext added
78320051207
784 /tools/odbc.c portability changes, and fix modes on several files
78520051202
786 /emu/Plan9/devfs.c strip Inferno root from file system diagnostics
78720051130
788 change /appl/svc/httpd to use lock(2) not lockprocs
78920051123
790 /appl/cmd/bind.b changed not to use arg.dis, implement -q, and diagnostic change
791 /appl/cmd/mount.b acquired a -q option as well
79220051114
793 avoid limit==0 in wm/memory.b
79420051108
795 have poolmaxsize return 0 for pool of size 0
796 remove /os/*/u.h (in favour of /$SYSTARG/$OBJTYPE/include/u.h)
797 update mkfiles accordingly
798 adjust mkfiles for libsec and libmp compilation for native kernels
79920051107
800 added /os/manga
80120051101
802 fixed /os/port/devloopback.c
803 updated netif.c netif.h
80420051028
805 updated gettar(1) and /appl/cmd/gettar.b
80620051025
807 fix British Summer Time in locales
80820051021
809 updated /appl/lib/newns.b and namespace(6) for environment variable substitution
81020051018
811 moved in changes from home to os/port: cis.c devbridge.c ethermii.c portclock.c devuart.c devbench.c random.c portfns.h tod.c uart.h
812 - mainly for changes to implement fasttick and timers
81320051017
814 /limbo/ecom.c and /appl/cmd/limbo/ecom.c: ensure src set in temporary Node to avoid `no file specified' in sbl.[bc]
81520050925
816 added format(2)
81720050922
818 iostats(4) added
81920050919
820 improve behaviour in wm/sh when in raw mode
82120050916
822 /appl/lib/styx.b: return value for Rmsg.unpack for Rstat didn't include len[2]
82320050912
824 update /appl/lib/disks.b, disks(2)
825 update /appl/cmd/disk/format.b
826 add /appl/cmd/disk/prep, /appl/cmd/disk/mbr.b
827 replace format(8) by prep(8)
828 delete undocumented /appl/cmd/disk/part.b
82920050908
830 added disks(2) and scsiio(2)
83120050906
832 os/port/devsrv.c and emu/port/devsrv.c to allow setting length by wstat (also DMAPPEND)
833 appl/cmd/dossrv.b fix to interpret aname:offset
834 usb updated to support current native uhci drivers
835 /appl/lib/usb/usbmass.b changed to work with new driver and more devices
83620050901
837 new /appl/cmd/ip/sntp.b, sntp(8)
83820050824
839 cp(1): added -gux options
84020050810
841 mangaload(8): new
84220050812
843 /appl/cmd/limbo/nodes.b didn't always initialise n.c (eg, a != a)
84420050712
845 updated utils/[12][acl] to match Plan 9's
84620050627
847 added streamcp (renamed fcp since that's what plan 9 calls a similar thing)
84820050626
849 added write lock to emu/port/devip.c to stop Linux (and perhaps others) splitting socket writes by different processes
85020050620
851 added w3c-xpointers(2) [/module/xpointers.m; /appl/lib/w3c/xpointers.b]
85220050617
853 fixed qid array reference in /appl/cmd/lockfs.b [cjones83]
85420050610
855 updated lib/ndb/dns
856 fixed count < 0 when reading beyond end of file in disk/kfs
85720050526
858 fixed factotum's p9any to use user= attribute in key not /dev/user
859 fix /appl/lib/daytime.b's handling of dlpairs; also read /env/timezone if that's there
860 update /appl/lib/w3c/css.b to read CSS2.1
861 add w3c-css(2); possibly should move module file to w3c/css.m?
86220050518
863 added GPL/LGPL notice files
864 made single mk.b from many included source files
865 added MIT-template or LGPL NOTICE files to lib* directories
866 updated doc/port.ms
867 included libmp and libsec in lib/proto/src (Lucent Public License), not yet used
868 fix bug in cmd(3) introduced by killonclose
86920050425
870 add sexprs(6)
871 add truerand/ntruerand and nsec[defined as osnsec] to lib9.h
872 redefine fmax and log2 in lib9.h
873 some/all FreeBSD-5.x-y don't initialise rfork_thread's procmask from parent (contrary to docs); compensate in FreeBSD/os.c
874 finally copy last year's changes to 1c from home
875 call logs->init in applylog
876 changed /appl/cmd/cmp.b to work correctly for differing buffer sizes, errors, etc.
877 included /os/pc/sd53c8xx.[in] and added /utils/na [not compiled by default]
878 mask off OEXCL in (emu/port os/port)^/sysfile.c:/^kcreate's openmode
879 wm/sh.b: keep menuitem 0 if noscroll selected
880 added units(1)
88120050413
882 licence following MIT-template replaces `free for all' instances
883 "-N nice" option in os(1)
884 geodesy(2) is new
885 ebook(1) is newly released (Open Ebook browser)
886 wm-sh(1) has a rearranged menu, with scroll/noscroll option added
887 /doc/asm.ms has been updated
888 section 10 has been updated
889 limbo compiler will make simple functions inline if possible
890 limbo compiler supports `ref fn' type
891 /doc/limbo/addendum.ms [also .ps .pdf] updated to reflect `ref fn' and other changes
892 keyring-ipint(2) has a few new operations (shl, shr, copy)
893 DigestState has new copy operation replacing cloneDigestState
894 Keyring has new functions certtoattr, pktoattr and sktoattr each returning
895 a string containing attr=value ... representations of certificates and keys
896 u.h has been updated for all platforms, hosted and native
897 new ptrint, u8int, u16int, u64int, FPdbleword, and more accurate varargs for < 4 byte values
898 lib9.h has extra encode/decode functions moved from libcrypt
899 string.m has new quotec function [TODO: man page]
900 crypt/ssl3.b handles a particular certificate type better
901 charon has several bug fixes in javascript, notably parsing of certain expressions
902 /doc/descent/* `Descent into Limbo' updated
903 internally libinterp uses a different representation for parts of the linkage table
904 /doc/lprof.ms [also .ps and .pdf] gives overview of Limbo profiling
905 /doc/ebookimp.ms [also .ps and .pdf] discusses implementation of its XML browsing
906 /doc/compiler.ms has been updated
907 /doc/dis.ms eclr has been removed
908 emu(1) -b enables bounds checking in JIT
909 cs(8) handles general query (!attr=val ...)
910 mkfs/mkext(8) handles big archives
911 emuinit tries sh -c on command if not immediately dis
912 /appl/lib/string.b: rewritten unquoted for correct handling of embedded quotes
913 limbo warns about unused local variables
914 limbo: -F enables new implementation of function ref
915 limbo: -O runs optimiser
916 mount -9 uses 9fs not styx as service address
917 cmd(3) adds "killonclose" and parameter to "nice"
918 TODO: group check in styxserver
919 styxlisten accumulates algs correctly
920 os/port/mkdevc builds vgacursor table
921 touch uses OEXCL
922 /appl/lib/debug knows about ref fn
923 ecmascript: for(... in ...) parsed correctly
924 getuserpasswd added to factotum(2)
925 /appl/lib/print reincorporated
926 wm/clock
927 ftpfs calls factotum (getuserpasswd)
928 hoststdin/hoststdout/hoststderr [preliminary]
929 /os/boot/pc updated, as is its shipping list
93020041217
931 base point
DragonFly/386/bin/.dreg+0−0

Empty file added.

DragonFly/386/include/emu.h+30−0
@@ -0,0 +1,30 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16#define KSTACK (32 * 1024)
17
18static __inline Proc *getup(void) {
19 Proc *p;
20 __asm__( "movl %%esp, %%eax\n\t"
21 : "=a" (p)
22 );
23 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
24};
25
26#define up (getup())
27
28typedef sigjmp_buf osjmpbuf;
29#define ossetjmp(buf) sigsetjmp(buf, 1)
30
DragonFly/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * Linux 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
DragonFly/386/include/lib9.h+472−0
@@ -0,0 +1,472 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#ifndef _BSD_SOURCE
3#define _BSD_SOURCE
4#endif
5/* these aren't really needed because FreeBSD does the right thing and makes off_t 64 bits, full stop */
6#define _LARGEFILE64_SOURCE 1
7#define _FILE_OFFSET_BITS 64
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <stdlib.h>
11#include <stdarg.h>
12#include <unistd.h>
13#include <errno.h>
14#include <string.h>
15#include "math.h"
16#include <fcntl.h>
17#include <setjmp.h>
18#include <float.h>
19#include <time.h>
20
21#define getwd infgetwd
22
23#define round infround
24#define fmax inffmax
25#define log2 inflog2
26
27#ifndef EMU
28typedef struct Proc Proc;
29#endif
30
31/*
32 * math module dtoa
33 */
34#define __LITTLE_ENDIAN
35
36#define nil ((void*)0)
37
38typedef unsigned char uchar;
39typedef signed char schar;
40typedef unsigned long ulong;
41typedef unsigned short Rune;
42typedef long long int vlong;
43typedef unsigned long long int uvlong;
44typedef unsigned int u32int;
45typedef uvlong u64int;
46typedef unsigned int mpdigit; /* for /sys/include/mp.h */
47typedef unsigned short u16int;
48typedef unsigned char u8int;
49typedef unsigned long uintptr;
50
51typedef signed char int8;
52typedef unsigned char uint8;
53typedef short int16;
54typedef unsigned short uint16;
55typedef int int32;
56typedef unsigned int uint32;
57typedef long long int64;
58typedef unsigned long long uint64;
59
60#define USED(x) if(x){}else{}
61#define SET(x)
62
63#undef nelem
64#define nelem(x) (sizeof(x)/sizeof((x)[0]))
65#undef offsetof
66#define offsetof(s, m) (ulong)(&(((s*)0)->m))
67#undef assert
68#define assert(x) if(x){}else _assert("x")
69
70/*
71 * most mem and string routines are declared by ANSI/POSIX files above
72 */
73
74extern char* strecpy(char*, char*, char*);
75extern char* strdup(const char*);
76extern int cistrncmp(char*, char*, int);
77extern int cistrcmp(char*, char*);
78extern char* cistrstr(char*, char*);
79extern int tokenize(char*, char**, int);
80
81enum
82{
83 UTFmax = 3, /* maximum bytes per rune */
84 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
85 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
86 Runeerror = 0x80 /* decoding error in UTF */
87};
88
89/*
90 * rune routines
91 */
92extern int runetochar(char*, Rune*);
93extern int chartorune(Rune*, char*);
94extern int runelen(long);
95extern int runenlen(Rune*, int);
96extern int fullrune(char*, int);
97extern int utflen(char*);
98extern int utfnlen(char*, long);
99extern char* utfrune(char*, long);
100extern char* utfrrune(char*, long);
101extern char* utfutf(char*, char*);
102extern char* utfecpy(char*, char*, char*);
103
104extern Rune* runestrcat(Rune*, Rune*);
105extern Rune* runestrchr(Rune*, Rune);
106extern int runestrcmp(Rune*, Rune*);
107extern Rune* runestrcpy(Rune*, Rune*);
108extern Rune* runestrncpy(Rune*, Rune*, long);
109extern Rune* runestrecpy(Rune*, Rune*, Rune*);
110extern Rune* runestrdup(Rune*);
111extern Rune* runestrncat(Rune*, Rune*, long);
112extern int runestrncmp(Rune*, Rune*, long);
113extern Rune* runestrrchr(Rune*, Rune);
114extern long runestrlen(Rune*);
115extern Rune* runestrstr(Rune*, Rune*);
116
117extern Rune tolowerrune(Rune);
118extern Rune totitlerune(Rune);
119extern Rune toupperrune(Rune);
120extern int isalpharune(Rune);
121extern int islowerrune(Rune);
122extern int isspacerune(Rune);
123extern int istitlerune(Rune);
124extern int isupperrune(Rune);
125
126/*
127 * malloc
128 */
129extern void* malloc(size_t);
130extern void* mallocz(ulong, int);
131extern void free(void*);
132extern ulong msize(void*);
133extern void* calloc(size_t, size_t);
134extern void* realloc(void*, size_t);
135extern void setmalloctag(void*, ulong);
136extern void setrealloctag(void*, ulong);
137extern ulong getmalloctag(void*);
138extern ulong getrealloctag(void*);
139extern void* malloctopoolblock(void*);
140
141/*
142 * print routines
143 */
144typedef struct Fmt Fmt;
145struct Fmt{
146 uchar runes; /* output buffer is runes or chars? */
147 void *start; /* of buffer */
148 void *to; /* current place in the buffer */
149 void *stop; /* end of the buffer; overwritten if flush fails */
150 int (*flush)(Fmt *); /* called when to == stop */
151 void *farg; /* to make flush a closure */
152 int nfmt; /* num chars formatted so far */
153 va_list args; /* args passed to dofmt */
154 int r; /* % format Rune */
155 int width;
156 int prec;
157 ulong flags;
158};
159
160enum{
161 FmtWidth = 1,
162 FmtLeft = FmtWidth << 1,
163 FmtPrec = FmtLeft << 1,
164 FmtSharp = FmtPrec << 1,
165 FmtSpace = FmtSharp << 1,
166 FmtSign = FmtSpace << 1,
167 FmtZero = FmtSign << 1,
168 FmtUnsigned = FmtZero << 1,
169 FmtShort = FmtUnsigned << 1,
170 FmtLong = FmtShort << 1,
171 FmtVLong = FmtLong << 1,
172 FmtComma = FmtVLong << 1,
173 FmtByte = FmtComma << 1,
174
175 FmtFlag = FmtByte << 1
176};
177
178extern int print(char*, ...);
179extern char* seprint(char*, char*, char*, ...);
180extern char* vseprint(char*, char*, char*, va_list);
181extern int snprint(char*, int, char*, ...);
182extern int vsnprint(char*, int, char*, va_list);
183extern char* smprint(char*, ...);
184extern char* vsmprint(char*, va_list);
185extern int sprint(char*, char*, ...);
186extern int fprint(int, char*, ...);
187extern int vfprint(int, char*, va_list);
188
189extern int runesprint(Rune*, char*, ...);
190extern int runesnprint(Rune*, int, char*, ...);
191extern int runevsnprint(Rune*, int, char*, va_list);
192extern Rune* runeseprint(Rune*, Rune*, char*, ...);
193extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
194extern Rune* runesmprint(char*, ...);
195extern Rune* runevsmprint(char*, va_list);
196
197extern int fmtfdinit(Fmt*, int, char*, int);
198extern int fmtfdflush(Fmt*);
199extern int fmtstrinit(Fmt*);
200extern char* fmtstrflush(Fmt*);
201extern int runefmtstrinit(Fmt*);
202extern Rune* runefmtstrflush(Fmt*);
203
204extern int fmtinstall(int, int (*)(Fmt*));
205extern int dofmt(Fmt*, char*);
206extern int dorfmt(Fmt*, Rune*);
207extern int fmtprint(Fmt*, char*, ...);
208extern int fmtvprint(Fmt*, char*, va_list);
209extern int fmtrune(Fmt*, int);
210extern int fmtstrcpy(Fmt*, char*);
211extern int fmtrunestrcpy(Fmt*, Rune*);
212/*
213 * error string for %r
214 * supplied on per os basis, not part of fmt library
215 */
216extern int errfmt(Fmt *f);
217
218/*
219 * quoted strings
220 */
221extern char *unquotestrdup(char*);
222extern Rune *unquoterunestrdup(Rune*);
223extern char *quotestrdup(char*);
224extern Rune *quoterunestrdup(Rune*);
225extern int quotestrfmt(Fmt*);
226extern int quoterunestrfmt(Fmt*);
227extern void quotefmtinstall(void);
228extern int (*doquote)(int);
229
230/*
231 * random number
232 */
233extern int nrand(int);
234extern ulong truerand(void);
235extern ulong ntruerand(ulong);
236
237/*
238 * math
239 */
240extern int isNaN(double);
241extern int isInf(double, int);
242extern double pow(double, double);
243
244/*
245 * Time-of-day
246 */
247
248typedef struct Tm Tm;
249struct Tm {
250 int sec;
251 int min;
252 int hour;
253 int mday;
254 int mon;
255 int year;
256 int wday;
257 int yday;
258 char zone[4];
259 int tzoff;
260};
261extern vlong osnsec(void);
262#define nsec osnsec
263
264/*
265 * one-of-a-kind
266 */
267extern void _assert(char*);
268extern double charstod(int(*)(void*), void*);
269extern char* cleanname(char*);
270extern double frexp(double, int*);
271extern uintptr getcallerpc(void*);
272extern int getfields(char*, char**, int, int, char*);
273extern char* getuser(void);
274extern char* getwd(char*, int);
275extern double ipow10(int);
276extern double ldexp(double, int);
277extern double modf(double, double*);
278#define pow10 infpow10
279extern double pow10(int);
280extern vlong strtoll(const char*, char**, int);
281#define qsort infqsort
282extern void qsort(void*, long, long, int (*)(void*, void*));
283extern uvlong strtoull(const char*, char**, int);
284extern void sysfatal(char*, ...);
285extern int dec64(uchar*, int, char*, int);
286extern int enc64(char*, int, uchar*, int);
287extern int dec32(uchar*, int, char*, int);
288extern int enc32(char*, int, uchar*, int);
289extern int dec16(uchar*, int, char*, int);
290extern int enc16(char*, int, uchar*, int);
291extern int encodefmt(Fmt*);
292
293/*
294 * synchronization
295 */
296typedef
297struct Lock {
298 int val;
299 int pid;
300} Lock;
301
302extern int _tas(int*);
303
304extern void lock(Lock*);
305extern void unlock(Lock*);
306extern int canlock(Lock*);
307
308typedef struct QLock QLock;
309struct QLock
310{
311 Lock use; /* to access Qlock structure */
312 Proc *head; /* next process waiting for object */
313 Proc *tail; /* last process waiting for object */
314 int locked; /* flag */
315};
316
317extern void qlock(QLock*);
318extern void qunlock(QLock*);
319extern int canqlock(QLock*);
320extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
321
322typedef
323struct RWLock
324{
325 Lock l; /* Lock modify lock */
326 QLock x; /* Mutual exclusion lock */
327 QLock k; /* Lock for waiting writers */
328 int readers; /* Count of readers in lock */
329} RWLock;
330
331extern int canrlock(RWLock*);
332extern int canwlock(RWLock*);
333extern void rlock(RWLock*);
334extern void runlock(RWLock*);
335extern void wlock(RWLock*);
336extern void wunlock(RWLock*);
337
338/*
339 * network dialing
340 */
341#define NETPATHLEN 40
342
343/*
344 * system calls
345 *
346 */
347#define STATMAX 65535U /* max length of machine-independent stat structure */
348#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
349#define ERRMAX 128 /* max length of error string */
350
351#define MORDER 0x0003 /* mask for bits defining order of mounting */
352#define MREPL 0x0000 /* mount replaces object */
353#define MBEFORE 0x0001 /* mount goes before others in union directory */
354#define MAFTER 0x0002 /* mount goes after others in union directory */
355#define MCREATE 0x0004 /* permit creation in mounted directory */
356#define MCACHE 0x0010 /* cache some data */
357#define MMASK 0x0017 /* all bits on */
358
359#define OREAD 0 /* open for read */
360#define OWRITE 1 /* write */
361#define ORDWR 2 /* read and write */
362#define OEXEC 3 /* execute, == read but check execute permission */
363#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
364#define OCEXEC 32 /* or'ed in, close on exec */
365#define ORCLOSE 64 /* or'ed in, remove on close */
366#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
367
368#define AEXIST 0 /* accessible: exists */
369#define AEXEC 1 /* execute access */
370#define AWRITE 2 /* write access */
371#define AREAD 4 /* read access */
372
373/* bits in Qid.type */
374#define QTDIR 0x80 /* type bit for directories */
375#define QTAPPEND 0x40 /* type bit for append only files */
376#define QTEXCL 0x20 /* type bit for exclusive use files */
377#define QTMOUNT 0x10 /* type bit for mounted channel */
378#define QTAUTH 0x08 /* type bit for authentication file */
379#define QTFILE 0x00 /* plain file */
380
381/* bits in Dir.mode */
382#define DMDIR 0x80000000 /* mode bit for directories */
383#define DMAPPEND 0x40000000 /* mode bit for append only files */
384#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
385#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
386#define DMAUTH 0x08000000 /* mode bit for authentication file */
387#define DMREAD 0x4 /* mode bit for read permission */
388#define DMWRITE 0x2 /* mode bit for write permission */
389#define DMEXEC 0x1 /* mode bit for execute permission */
390
391typedef
392struct Qid
393{
394 uvlong path;
395 ulong vers;
396 uchar type;
397} Qid;
398
399typedef
400struct Dir {
401 /* system-modified data */
402 ushort type; /* server type */
403 uint dev; /* server subtype */
404 /* file data */
405 Qid qid; /* unique id from server */
406 ulong mode; /* permissions */
407 ulong atime; /* last read time */
408 ulong mtime; /* last write time */
409 vlong length; /* file length */
410 char *name; /* last element of path */
411 char *uid; /* owner name */
412 char *gid; /* group name */
413 char *muid; /* last modifier name */
414} Dir;
415
416extern Dir* dirstat(char*);
417extern Dir* dirfstat(int);
418extern int dirwstat(char*, Dir*);
419extern int dirfwstat(int, Dir*);
420extern long dirread(int, Dir**);
421extern void nulldir(Dir*);
422extern long dirreadall(int, Dir**);
423
424typedef
425struct Waitmsg
426{
427 int pid; /* of loved one */
428 ulong time[3]; /* of loved one & descendants */
429 char *msg;
430} Waitmsg;
431
432extern void _exits(char*);
433
434extern void exits(char*);
435extern int create(char*, int, int);
436extern int errstr(char*, uint);
437
438extern void perror(const char*);
439extern long readn(int, void*, long);
440extern int remove(const char*);
441extern void rerrstr(char*, uint);
442extern vlong seek(int, vlong, int);
443extern int segflush(void*, ulong);
444extern void werrstr(char*, ...);
445
446extern char *argv0;
447#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
448 argv[0] && argv[0][0]=='-' && argv[0][1];\
449 argc--, argv++) {\
450 char *_args, *_argt;\
451 Rune _argc;\
452 _args = &argv[0][1];\
453 if(_args[0]=='-' && _args[1]==0){\
454 argc--; argv++; break;\
455 }\
456 _argc = 0;\
457 while(*_args && (_args += chartorune(&_argc, _args)))\
458 switch(_argc)
459#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
460#define ARGF() (_argt=_args, _args="",\
461 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
462#define EARGF(x) (_argt=_args, _args="",\
463 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
464
465#define ARGC() _argc
466
467/*
468 * Extensions for Inferno to basic libc.h
469 */
470
471#define setbinmode()
472
DragonFly/386/lib/.dreg+0−0

Empty file added.

FreeBSD/386/bin/data2c+0−0

Binary file not shown.

FreeBSD/386/bin/iyacc+0−0

Binary file not shown.

FreeBSD/386/bin/mk+0−0

Binary file not shown.

FreeBSD/386/bin/mkext+0−0

Binary file not shown.

FreeBSD/386/include/emu.h+30−0
@@ -0,0 +1,30 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16#define KSTACK (32 * 1024)
17
18static __inline Proc *getup(void) {
19 Proc *p;
20 __asm__( "movl %%esp, %%eax\n\t"
21 : "=a" (p)
22 );
23 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
24};
25
26#define up (getup())
27
28typedef sigjmp_buf osjmpbuf;
29#define ossetjmp(buf) sigsetjmp(buf, 1)
30
FreeBSD/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * Linux 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
FreeBSD/386/include/lib9.h+473−0
@@ -0,0 +1,473 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#ifndef _BSD_SOURCE
3#define _BSD_SOURCE
4#endif
5/* these aren't really needed because FreeBSD does the right thing and makes off_t 64 bits, full stop */
6#define _LARGEFILE64_SOURCE 1
7#define _FILE_OFFSET_BITS 64
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <stdlib.h>
11#include <stdarg.h>
12#include <unistd.h>
13#include <errno.h>
14#include <string.h>
15#include "math.h"
16#include <fcntl.h>
17#include <setjmp.h>
18#include <float.h>
19#include <time.h>
20
21#define getwd infgetwd
22
23#define round infround
24#define fmax inffmax
25#define log2 inflog2
26
27#ifndef EMU
28typedef struct Proc Proc;
29#endif
30
31/*
32 * math module dtoa
33 */
34#define __LITTLE_ENDIAN
35
36#define nil ((void*)0)
37
38typedef unsigned char uchar;
39typedef signed char schar;
40typedef unsigned long ulong;
41typedef unsigned short Rune;
42typedef long long int vlong;
43typedef unsigned long long int uvlong;
44typedef unsigned int u32int;
45typedef uvlong u64int;
46
47typedef unsigned int mpdigit; /* for /sys/include/mp.h */
48typedef unsigned short u16int;
49typedef unsigned char u8int;
50typedef unsigned long uintptr;
51
52typedef signed char int8;
53typedef unsigned char uint8;
54typedef short int16;
55typedef unsigned short uint16;
56typedef int int32;
57typedef unsigned int uint32;
58typedef long long int64;
59typedef unsigned long long uint64;
60
61#define USED(x) if(x){}else{}
62#define SET(x)
63
64#undef nelem
65#define nelem(x) (sizeof(x)/sizeof((x)[0]))
66#undef offsetof
67#define offsetof(s, m) (ulong)(&(((s*)0)->m))
68#undef assert
69#define assert(x) if(x){}else _assert("x")
70
71/*
72 * most mem and string routines are declared by ANSI/POSIX files above
73 */
74
75extern char* strecpy(char*, char*, char*);
76extern char* strdup(const char*);
77extern int cistrncmp(char*, char*, int);
78extern int cistrcmp(char*, char*);
79extern char* cistrstr(char*, char*);
80extern int tokenize(char*, char**, int);
81
82enum
83{
84 UTFmax = 3, /* maximum bytes per rune */
85 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
86 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
87 Runeerror = 0x80 /* decoding error in UTF */
88};
89
90/*
91 * rune routines
92 */
93extern int runetochar(char*, Rune*);
94extern int chartorune(Rune*, char*);
95extern int runelen(long);
96extern int runenlen(Rune*, int);
97extern int fullrune(char*, int);
98extern int utflen(char*);
99extern int utfnlen(char*, long);
100extern char* utfrune(char*, long);
101extern char* utfrrune(char*, long);
102extern char* utfutf(char*, char*);
103extern char* utfecpy(char*, char*, char*);
104
105extern Rune* runestrcat(Rune*, Rune*);
106extern Rune* runestrchr(Rune*, Rune);
107extern int runestrcmp(Rune*, Rune*);
108extern Rune* runestrcpy(Rune*, Rune*);
109extern Rune* runestrncpy(Rune*, Rune*, long);
110extern Rune* runestrecpy(Rune*, Rune*, Rune*);
111extern Rune* runestrdup(Rune*);
112extern Rune* runestrncat(Rune*, Rune*, long);
113extern int runestrncmp(Rune*, Rune*, long);
114extern Rune* runestrrchr(Rune*, Rune);
115extern long runestrlen(Rune*);
116extern Rune* runestrstr(Rune*, Rune*);
117
118extern Rune tolowerrune(Rune);
119extern Rune totitlerune(Rune);
120extern Rune toupperrune(Rune);
121extern int isalpharune(Rune);
122extern int islowerrune(Rune);
123extern int isspacerune(Rune);
124extern int istitlerune(Rune);
125extern int isupperrune(Rune);
126
127/*
128 * malloc
129 */
130extern void* malloc(size_t);
131extern void* mallocz(ulong, int);
132extern void free(void*);
133extern ulong msize(void*);
134extern void* calloc(size_t, size_t);
135extern void* realloc(void*, size_t);
136extern void setmalloctag(void*, ulong);
137extern void setrealloctag(void*, ulong);
138extern ulong getmalloctag(void*);
139extern ulong getrealloctag(void*);
140extern void* malloctopoolblock(void*);
141
142/*
143 * print routines
144 */
145typedef struct Fmt Fmt;
146struct Fmt{
147 uchar runes; /* output buffer is runes or chars? */
148 void *start; /* of buffer */
149 void *to; /* current place in the buffer */
150 void *stop; /* end of the buffer; overwritten if flush fails */
151 int (*flush)(Fmt *); /* called when to == stop */
152 void *farg; /* to make flush a closure */
153 int nfmt; /* num chars formatted so far */
154 va_list args; /* args passed to dofmt */
155 int r; /* % format Rune */
156 int width;
157 int prec;
158 ulong flags;
159};
160
161enum{
162 FmtWidth = 1,
163 FmtLeft = FmtWidth << 1,
164 FmtPrec = FmtLeft << 1,
165 FmtSharp = FmtPrec << 1,
166 FmtSpace = FmtSharp << 1,
167 FmtSign = FmtSpace << 1,
168 FmtZero = FmtSign << 1,
169 FmtUnsigned = FmtZero << 1,
170 FmtShort = FmtUnsigned << 1,
171 FmtLong = FmtShort << 1,
172 FmtVLong = FmtLong << 1,
173 FmtComma = FmtVLong << 1,
174 FmtByte = FmtComma << 1,
175
176 FmtFlag = FmtByte << 1
177};
178
179extern int print(char*, ...);
180extern char* seprint(char*, char*, char*, ...);
181extern char* vseprint(char*, char*, char*, va_list);
182extern int snprint(char*, int, char*, ...);
183extern int vsnprint(char*, int, char*, va_list);
184extern char* smprint(char*, ...);
185extern char* vsmprint(char*, va_list);
186extern int sprint(char*, char*, ...);
187extern int fprint(int, char*, ...);
188extern int vfprint(int, char*, va_list);
189
190extern int runesprint(Rune*, char*, ...);
191extern int runesnprint(Rune*, int, char*, ...);
192extern int runevsnprint(Rune*, int, char*, va_list);
193extern Rune* runeseprint(Rune*, Rune*, char*, ...);
194extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
195extern Rune* runesmprint(char*, ...);
196extern Rune* runevsmprint(char*, va_list);
197
198extern int fmtfdinit(Fmt*, int, char*, int);
199extern int fmtfdflush(Fmt*);
200extern int fmtstrinit(Fmt*);
201extern char* fmtstrflush(Fmt*);
202extern int runefmtstrinit(Fmt*);
203extern Rune* runefmtstrflush(Fmt*);
204
205extern int fmtinstall(int, int (*)(Fmt*));
206extern int dofmt(Fmt*, char*);
207extern int dorfmt(Fmt*, Rune*);
208extern int fmtprint(Fmt*, char*, ...);
209extern int fmtvprint(Fmt*, char*, va_list);
210extern int fmtrune(Fmt*, int);
211extern int fmtstrcpy(Fmt*, char*);
212extern int fmtrunestrcpy(Fmt*, Rune*);
213/*
214 * error string for %r
215 * supplied on per os basis, not part of fmt library
216 */
217extern int errfmt(Fmt *f);
218
219/*
220 * quoted strings
221 */
222extern char *unquotestrdup(char*);
223extern Rune *unquoterunestrdup(Rune*);
224extern char *quotestrdup(char*);
225extern Rune *quoterunestrdup(Rune*);
226extern int quotestrfmt(Fmt*);
227extern int quoterunestrfmt(Fmt*);
228extern void quotefmtinstall(void);
229extern int (*doquote)(int);
230
231/*
232 * random number
233 */
234extern int nrand(int);
235extern ulong truerand(void);
236extern ulong ntruerand(ulong);
237
238/*
239 * math
240 */
241extern int isNaN(double);
242extern int isInf(double, int);
243extern double pow(double, double);
244
245/*
246 * Time-of-day
247 */
248
249typedef struct Tm Tm;
250struct Tm {
251 int sec;
252 int min;
253 int hour;
254 int mday;
255 int mon;
256 int year;
257 int wday;
258 int yday;
259 char zone[4];
260 int tzoff;
261};
262extern vlong osnsec(void);
263#define nsec osnsec
264
265/*
266 * one-of-a-kind
267 */
268extern void _assert(char*);
269extern double charstod(int(*)(void*), void*);
270extern char* cleanname(char*);
271extern double frexp(double, int*);
272extern uintptr getcallerpc(void*);
273extern int getfields(char*, char**, int, int, char*);
274extern char* getuser(void);
275extern char* getwd(char*, int);
276extern double ipow10(int);
277extern double ldexp(double, int);
278extern double modf(double, double*);
279#define pow10 infpow10
280extern double pow10(int);
281extern vlong strtoll(const char*, char**, int);
282#define qsort infqsort
283extern void qsort(void*, long, long, int (*)(void*, void*));
284extern uvlong strtoull(const char*, char**, int);
285extern void sysfatal(char*, ...);
286extern int dec64(uchar*, int, char*, int);
287extern int enc64(char*, int, uchar*, int);
288extern int dec32(uchar*, int, char*, int);
289extern int enc32(char*, int, uchar*, int);
290extern int dec16(uchar*, int, char*, int);
291extern int enc16(char*, int, uchar*, int);
292extern int encodefmt(Fmt*);
293
294/*
295 * synchronization
296 */
297typedef
298struct Lock {
299 int val;
300 int pid;
301} Lock;
302
303extern int _tas(int*);
304
305extern void lock(Lock*);
306extern void unlock(Lock*);
307extern int canlock(Lock*);
308
309typedef struct QLock QLock;
310struct QLock
311{
312 Lock use; /* to access Qlock structure */
313 Proc *head; /* next process waiting for object */
314 Proc *tail; /* last process waiting for object */
315 int locked; /* flag */
316};
317
318extern void qlock(QLock*);
319extern void qunlock(QLock*);
320extern int canqlock(QLock*);
321extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
322
323typedef
324struct RWLock
325{
326 Lock l; /* Lock modify lock */
327 QLock x; /* Mutual exclusion lock */
328 QLock k; /* Lock for waiting writers */
329 int readers; /* Count of readers in lock */
330} RWLock;
331
332extern int canrlock(RWLock*);
333extern int canwlock(RWLock*);
334extern void rlock(RWLock*);
335extern void runlock(RWLock*);
336extern void wlock(RWLock*);
337extern void wunlock(RWLock*);
338
339/*
340 * network dialing
341 */
342#define NETPATHLEN 40
343
344/*
345 * system calls
346 *
347 */
348#define STATMAX 65535U /* max length of machine-independent stat structure */
349#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
350#define ERRMAX 128 /* max length of error string */
351
352#define MORDER 0x0003 /* mask for bits defining order of mounting */
353#define MREPL 0x0000 /* mount replaces object */
354#define MBEFORE 0x0001 /* mount goes before others in union directory */
355#define MAFTER 0x0002 /* mount goes after others in union directory */
356#define MCREATE 0x0004 /* permit creation in mounted directory */
357#define MCACHE 0x0010 /* cache some data */
358#define MMASK 0x0017 /* all bits on */
359
360#define OREAD 0 /* open for read */
361#define OWRITE 1 /* write */
362#define ORDWR 2 /* read and write */
363#define OEXEC 3 /* execute, == read but check execute permission */
364#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
365#define OCEXEC 32 /* or'ed in, close on exec */
366#define ORCLOSE 64 /* or'ed in, remove on close */
367#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
368
369#define AEXIST 0 /* accessible: exists */
370#define AEXEC 1 /* execute access */
371#define AWRITE 2 /* write access */
372#define AREAD 4 /* read access */
373
374/* bits in Qid.type */
375#define QTDIR 0x80 /* type bit for directories */
376#define QTAPPEND 0x40 /* type bit for append only files */
377#define QTEXCL 0x20 /* type bit for exclusive use files */
378#define QTMOUNT 0x10 /* type bit for mounted channel */
379#define QTAUTH 0x08 /* type bit for authentication file */
380#define QTFILE 0x00 /* plain file */
381
382/* bits in Dir.mode */
383#define DMDIR 0x80000000 /* mode bit for directories */
384#define DMAPPEND 0x40000000 /* mode bit for append only files */
385#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
386#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
387#define DMAUTH 0x08000000 /* mode bit for authentication file */
388#define DMREAD 0x4 /* mode bit for read permission */
389#define DMWRITE 0x2 /* mode bit for write permission */
390#define DMEXEC 0x1 /* mode bit for execute permission */
391
392typedef
393struct Qid
394{
395 uvlong path;
396 ulong vers;
397 uchar type;
398} Qid;
399
400typedef
401struct Dir {
402 /* system-modified data */
403 ushort type; /* server type */
404 uint dev; /* server subtype */
405 /* file data */
406 Qid qid; /* unique id from server */
407 ulong mode; /* permissions */
408 ulong atime; /* last read time */
409 ulong mtime; /* last write time */
410 vlong length; /* file length */
411 char *name; /* last element of path */
412 char *uid; /* owner name */
413 char *gid; /* group name */
414 char *muid; /* last modifier name */
415} Dir;
416
417extern Dir* dirstat(char*);
418extern Dir* dirfstat(int);
419extern int dirwstat(char*, Dir*);
420extern int dirfwstat(int, Dir*);
421extern long dirread(int, Dir**);
422extern void nulldir(Dir*);
423extern long dirreadall(int, Dir**);
424
425typedef
426struct Waitmsg
427{
428 int pid; /* of loved one */
429 ulong time[3]; /* of loved one & descendants */
430 char *msg;
431} Waitmsg;
432
433extern void _exits(char*);
434
435extern void exits(char*);
436extern int create(char*, int, int);
437extern int errstr(char*, uint);
438
439extern void perror(const char*);
440extern long readn(int, void*, long);
441extern int remove(const char*);
442extern void rerrstr(char*, uint);
443extern vlong seek(int, vlong, int);
444extern int segflush(void*, ulong);
445extern void werrstr(char*, ...);
446
447extern char *argv0;
448#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
449 argv[0] && argv[0][0]=='-' && argv[0][1];\
450 argc--, argv++) {\
451 char *_args, *_argt;\
452 Rune _argc;\
453 _args = &argv[0][1];\
454 if(_args[0]=='-' && _args[1]==0){\
455 argc--; argv++; break;\
456 }\
457 _argc = 0;\
458 while(*_args && (_args += chartorune(&_argc, _args)))\
459 switch(_argc)
460#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
461#define ARGF() (_argt=_args, _args="",\
462 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
463#define EARGF(x) (_argt=_args, _args="",\
464 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
465
466#define ARGC() _argc
467
468/*
469 * Extensions for Inferno to basic libc.h
470 */
471
472#define setbinmode()
473
Hp/s800/include/emu.h+21−0
@@ -0,0 +1,21 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc* getup();
8#define up (getup())
9
10/*
11 * This structure must agree with FPsave and FPrestore asm routines
12 */
13typedef struct FPU FPU;
14struct FPU
15{
16 fp_control fsr;
17};
18
19typedef sigjmp_buf osjmpbuf;
20#define ossetjmp(buf) sigsetjmp(buf, 1)
21
INSTALL+86−0
@@ -0,0 +1,86 @@
1Installing hosted Inferno from source
2
3Overview
4
5 Like the native kernels emu relies on several auxil-
6iary libraries (the source of which it often shares with the
7native kernels). Emu itself is built by the mkfile in the
8emu subdirectory containing the platform-specific source for
9the host platform. Each library has its own mkfile; the
10various components are made in the right order by the
11mkfile at the root of the Inferno tree. The mkfile for
12each platform will also invoke mk recursively to make the
13appropriate libraries for a given configuration.
14
15 The Unix emu variant generally is covered by `POSIX'
16(with common extensions) but each Unix port has one file
17that differs considerably for each port, namely
18emu/platform/os.c, the differences corresponding to the dif-
19ferent ways under Unix of implementing kernel-scheduled
20threads efficiently.
21
22 There are working emu versions for FreeBSD/386,
23Irix/mips, Linux/386, NetBSD/386, MacOSX/386, MacOSX/power,
24Plan 9, Solaris/sparc, and Windows (NT, 2000 and Explorer
25plug-in). Each platform typically uses mechanisms specific
26to the host operating system to implement Inferno's internal
27thread/process structure. POSIX threads have often been
28found to be insufficient (poorly implemented) on some plat-
29forms, and if so are avoided. See kproc in emu/*/os.c.
30
31 Source is included for ports to HP/UX (S800 architec-
32ture), Solaris/386, and Unixware, in case someone wishes to
33take them up now, but we have not determined their fitness.
34
35 The Plan 9 hosted implementation is unusual in that it
36supports several processor types: 386, mips, power (Power
37PC) and sparc. Furthermore, all versions of emu can be
38built on any processor type, in the usual way for Plan 9.
39
40 Otherwise, as distributed, emu for a platform can only
41be built when running on that platform.
42
43 One unusual variant makes the whole of Inferno a plug-
44in for Microsoft's Internet Explorer, giving the same envi-
45ronment for Inferno applications running in an HTML page as
46is provided by hosted or native Inferno. That is, there is
47not a distinct `applet' environment with special programming
48interfaces. The source for the various plug-in components
49is found in /tools/plugin and /usr/internet within the
50Inferno tree; they use the version of emu defined by the
51configuration file /emu/Nt/ie.
52
53Build steps
54
55 All the libraries and executables can be built in a
56tree containing only the source code. To do that for a sup-
57ported variant of hosted Inferno, on Unix or Plan 9, do the
58following in the root of the Inferno tree:
59
601 Edit mkconfig to reflect your host environment,
61 specifically ROOT (which must be an absolute path
62 name), SYSHOST and OBJTYPE. The comments in the file
63 should help you choose.
64
652 Run makemk.sh to rebuild the mk command, which is
66 used to build everything else.
67
683 Set PATH (or path on Plan 9) to include the bin
69 directory for the platform, which will now contain the
70 mk binary just built. On Unix, export PATH.
71
724 Then mk nuke to remove any extraneous object files.
73
745 Finally, mk install to create and install the
75 libraries, limbo compiler, emu for hosted Inferno,
76 and auxiliary commands. The rules do that in an order
77 that ensures that the commands or libraries needed by a
78 later stage are built and installed first. (Note that
79 a plain mk will not suffice, because it does not put
80 the results in the search path.)
81
82Doing something similar on Windows or Plan 9 currently
83requires the executable for mk to be available in the
84search path, since there is no equivalent of makemk.sh.
85Otherwise the procedure is the same. On Plan 9, of course,
86the host system's normal version of mk should be adequate.
Inferno/386/include/lib9.h+8−0
@@ -0,0 +1,8 @@
1#include <u.h>
2#include <kern.h>
3
4/*
5 * Extensions for Inferno to basic libc.h
6 */
7
8#define __LITTLE_ENDIAN /* math/dtoa.c only */
Inferno/386/include/u.h+64−0
@@ -0,0 +1,64 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<5)
24#define FPUNFL ((1<<4)|(1<<1))
25#define FPOVFL (1<<3)
26#define FPZDIV (1<<2)
27#define FPINVAL (1<<0)
28#define FPRNR (0<<10)
29#define FPRZ (3<<10)
30#define FPRPINF (2<<10)
31#define FPRNINF (1<<10)
32#define FPRMASK (3<<10)
33#define FPPEXT (3<<8)
34#define FPPSGL (0<<8)
35#define FPPDBL (2<<8)
36#define FPPMASK (3<<8)
37/* FSR */
38#define FPAINEX FPINEX
39#define FPAOVFL FPOVFL
40#define FPAUNFL FPUNFL
41#define FPAZDIV FPZDIV
42#define FPAINVAL FPINVAL
43union FPdbleword
44{
45 double x;
46 struct { /* little endian */
47 ulong lo;
48 ulong hi;
49 };
50};
51
52typedef char* va_list;
53#define va_start(list, start) list =\
54 (sizeof(start) < 4?\
55 (char*)((int*)&(start)+1):\
56 (char*)(&(start)+1))
57#define va_end(list)\
58 USED(list)
59#define va_arg(list, mode)\
60 ((sizeof(mode) == 1)?\
61 ((mode*)(list += 4))[-4]:\
62 (sizeof(mode) == 2)?\
63 ((mode*)(list += 4))[-2]:\
64 ((mode*)(list += sizeof(mode)))[-1])
Inferno/386/include/ureg.h+25−0
@@ -0,0 +1,25 @@
1struct Ureg
2{
3 ulong di; /* general registers */
4 ulong si; /* ... */
5 ulong bp; /* ... */
6 ulong nsp;
7 ulong bx; /* ... */
8 ulong dx; /* ... */
9 ulong cx; /* ... */
10 ulong ax; /* ... */
11 ulong gs; /* data segments */
12 ulong fs; /* ... */
13 ulong es; /* ... */
14 ulong ds; /* ... */
15 ulong trap; /* trap type */
16 ulong ecode; /* error code (or zero) */
17 ulong pc; /* pc */
18 ulong cs; /* old context */
19 ulong flags; /* old flags */
20 union {
21 ulong usp;
22 ulong sp;
23 };
24 ulong ss; /* old stack segment */
25};
Inferno/arm/include/lib9.h+8−0
@@ -0,0 +1,8 @@
1#include <u.h>
2#include <kern.h>
3
4/*
5 * Extensions for Inferno to basic libc.h
6 */
7
8#define __LITTLE_ENDIAN /* math/dtoa.c; longs in ARM doubles are big-endian */
Inferno/arm/include/u.h+65−0
@@ -0,0 +1,65 @@
1#define nil ((void*)0)
2
3typedef unsigned short ushort;
4typedef unsigned char uchar;
5typedef unsigned long ulong;
6typedef unsigned int uint;
7typedef signed char schar;
8typedef long long vlong;
9typedef unsigned long long uvlong;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21typedef unsigned long uintptr;
22
23/* FCR */
24#define FPINEX (1<<20)
25#define FPUNFL (1<<19)
26#define FPOVFL (1<<18)
27#define FPZDIV (1<<17)
28#define FPINVAL (1<<16)
29#define FPRNR (0<<0)
30#define FPRZ (1<<0)
31#define FPRPINF (2<<0)
32#define FPRNINF (3<<0)
33#define FPRMASK (3<<0)
34#define FPPEXT 0
35#define FPPSGL 0
36#define FPPDBL 0
37#define FPPMASK 0
38/* FSR */
39#define FPAINEX (1<<4)
40#define FPAUNFL (1<<3)
41#define FPAOVFL (1<<2)
42#define FPAZDIV (1<<1)
43#define FPAINVAL (1<<0)
44union FPdbleword
45{
46 double x;
47 struct { /* little endian (on VFP and now in software) */
48 ulong lo;
49 ulong hi;
50 };
51};
52
53typedef char* va_list;
54#define va_start(list, start) list =\
55 (sizeof(start) < 4?\
56 (char*)((int*)&(start)+1):\
57 (char*)(&(start)+1))
58#define va_end(list)\
59 USED(list)
60#define va_arg(list, mode)\
61 ((sizeof(mode) == 1)?\
62 ((mode*)(list += 4))[-4]:\
63 (sizeof(mode) == 2)?\
64 ((mode*)(list += 4))[-2]:\
65 ((mode*)(list += sizeof(mode)))[-1])
Inferno/arm/include/ureg.h+24−0
@@ -0,0 +1,24 @@
1typedef struct Ureg {
2 uint r0;
3 uint r1;
4 uint r2;
5 uint r3;
6 uint r4;
7 uint r5;
8 uint r6;
9 uint r7;
10 uint r8;
11 uint r9;
12 uint r10;
13 uint r11;
14 uint r12;
15 union {
16 uint r13;
17 uint sp;
18 };
19 uint r14;
20 uint link;
21 uint type;
22 uint psr;
23 uint pc;
24} Ureg;
Inferno/mips/include/lib9.h+8−0
@@ -0,0 +1,8 @@
1#include <u.h>
2#include <kern.h>
3
4/*
5 * Extensions for Inferno to basic libc.h
6 */
7
8#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in MIPS doubles are big-endian */
Inferno/mips/include/u.h+65−0
@@ -0,0 +1,65 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<7)
24#define FPUNFL (1<<8)
25#define FPOVFL (1<<9)
26#define FPZDIV (1<<10)
27#define FPINVAL (1<<11)
28#define FPRNR (0<<0)
29#define FPRZ (1<<0)
30#define FPRPINF (2<<0)
31#define FPRNINF (3<<0)
32#define FPRMASK (3<<0)
33#define FPPEXT 0
34#define FPPSGL 0
35#define FPPDBL 0
36#define FPPMASK 0
37/* FSR */
38#define FPAINEX (1<<2)
39#define FPAOVFL (1<<4)
40#define FPAUNFL (1<<3)
41#define FPAZDIV (1<<5)
42#define FPAINVAL (1<<6)
43union FPdbleword
44{
45 double x;
46 struct { /* big endian */
47 ulong hi;
48 ulong lo;
49 };
50};
51
52/* stdarg */
53typedef char* va_list;
54#define va_start(list, start) list =\
55 (sizeof(start) < 4?\
56 (char*)((int*)&(start)+1):\
57 (char*)(&(start)+1))
58#define va_end(list)\
59 USED(list)
60#define va_arg(list, mode)\
61 ((sizeof(mode) == 1)?\
62 ((mode*)(list += 4))[-1]:\
63 (sizeof(mode) == 2)?\
64 ((mode*)(list += 4))[-1]:\
65 ((mode*)(list += sizeof(mode)))[-1])
Inferno/power/include/lib9.h+4−0
@@ -0,0 +1,4 @@
1#include <u.h>
2#include <kern.h>
3
4#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in PowerPC doubles are big-endian */
Inferno/power/include/u.h+84−0
@@ -0,0 +1,84 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FPSCR */
23#define FPSFX (1<<31) /* exception summary (sticky) */
24#define FPSEX (1<<30) /* enabled exception summary */
25#define FPSVX (1<<29) /* invalid operation exception summary */
26#define FPSOX (1<<28) /* overflow exception OX (sticky) */
27#define FPSUX (1<<27) /* underflow exception UX (sticky) */
28#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
29#define FPSXX (1<<25) /* inexact exception XX (sticky) */
30#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
31#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
32#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
33#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
34#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
35#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
36#define FPSFR (1<<18) /* fraction rounded */
37#define FPSFI (1<<17) /* fraction inexact */
38#define FPSFPRF (1<<16) /* floating point result class */
39#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
40#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
41#define FPVE (1<<7) /* invalid operation exception enable */
42#define FPOVFL (1<<6) /* enable overflow exceptions */
43#define FPUNFL (1<<5) /* enable underflow */
44#define FPZDIV (1<<4) /* enable zero divide */
45#define FPINEX (1<<3) /* enable inexact exceptions */
46#define FPRMASK (3<<0) /* rounding mode */
47#define FPRNR (0<<0)
48#define FPRZ (1<<0)
49#define FPRPINF (2<<0)
50#define FPRNINF (3<<0)
51#define FPPEXT 0
52#define FPPSGL 0
53#define FPPDBL 0
54#define FPPMASK 0
55#define FPINVAL FPVE
56
57#define FPAOVFL FPSOX
58#define FPAINEX FPSXX
59#define FPAUNFL FPSUX
60#define FPAZDIV FPSZX
61#define FPAINVAL FPSVX
62
63union FPdbleword
64{
65 double x;
66 struct { /* big endian */
67 ulong hi;
68 ulong lo;
69 };
70};
71
72typedef char* va_list;
73#define va_start(list, start) list =\
74 (sizeof(start) < 4?\
75 (char*)((int*)&(start)+1):\
76 (char*)(&(start)+1))
77#define va_end(list)\
78 USED(list)
79#define va_arg(list, mode)\
80 ((sizeof(mode) == 1)?\
81 ((mode*)(list += 4))[-1]:\
82 (sizeof(mode) == 2)?\
83 ((mode*)(list += 4))[-1]:\
84 ((mode*)(list += sizeof(mode)))[-1])
Inferno/power/include/ureg.h+43−0
@@ -0,0 +1,43 @@
1struct Ureg
2{
3 ulong cause;
4 union { ulong srr1; ulong status;};
5 ulong pc; /* SRR0 */
6 ulong pad;
7 ulong lr;
8 ulong cr;
9 ulong xer;
10 ulong ctr;
11 ulong r0;
12 union{ ulong r1; ulong sp; ulong usp; };
13 ulong r2;
14 ulong r3;
15 ulong r4;
16 ulong r5;
17 ulong r6;
18 ulong r7;
19 ulong r8;
20 ulong r9;
21 ulong r10;
22 ulong r11;
23 ulong r12;
24 ulong r13;
25 ulong r14;
26 ulong r15;
27 ulong r16;
28 ulong r17;
29 ulong r18;
30 ulong r19;
31 ulong r20;
32 ulong r21;
33 ulong r22;
34 ulong r23;
35 ulong r24;
36 ulong r25;
37 ulong r26;
38 ulong r27;
39 ulong r28;
40 ulong r29;
41 ulong r30;
42 ulong r31;
43};
Inferno/sparc/include/lib9.h+9−0
@@ -0,0 +1,9 @@
1#include <u.h>
2#include <kern.h>
3
4
5/*
6 * Extensions for Inferno to basic libc.h
7 */
8
9#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in SPARC doubles are big-endian */
Inferno/sparc/include/u.h+64−0
@@ -0,0 +1,64 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC (-8)
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<23)
24#define FPOVFL (1<<26)
25#define FPUNFL (1<<25)
26#define FPZDIV (1<<24)
27#define FPRNR (0<<30)
28#define FPRZ (1<<30)
29#define FPINVAL (1<<27)
30#define FPRPINF (2<<30)
31#define FPRNINF (3<<30)
32#define FPRMASK (3<<30)
33#define FPPEXT 0
34#define FPPSGL 0
35#define FPPDBL 0
36#define FPPMASK 0
37/* FSR */
38#define FPAINEX (1<<5)
39#define FPAZDIV (1<<6)
40#define FPAUNFL (1<<7)
41#define FPAOVFL (1<<8)
42#define FPAINVAL (1<<9)
43union FPdbleword
44{
45 double x;
46 struct { /* big endian */
47 ulong hi;
48 ulong lo;
49 };
50};
51
52typedef char* va_list;
53#define va_start(list, start) list =\
54 (sizeof(start) < 4?\
55 (char*)((int*)&(start)+1):\
56 (char*)(&(start)+1))
57#define va_end(list)\
58 USED(list)
59#define va_arg(list, mode)\
60 ((sizeof(mode) == 1)?\
61 ((mode*)(list += 4))[-1]:\
62 (sizeof(mode) == 2)?\
63 ((mode*)(list += 4))[-1]:\
64 ((mode*)(list += sizeof(mode)))[-1])
Inferno/sparc/include/ureg.h+45−0
@@ -0,0 +1,45 @@
1struct Ureg
2{
3 ulong r0; /* unnecessary; just for symmetry */
4 union{
5 ulong sp; /* r1 */
6 ulong usp; /* r1 */
7 ulong r1;
8 };
9 ulong r2;
10 ulong r3;
11 ulong r4;
12 ulong r5;
13 ulong r6;
14 ulong r7;
15 ulong r8;
16 ulong r9;
17 ulong r10;
18 ulong r11;
19 ulong r12;
20 ulong r13;
21 ulong r14;
22 ulong r15;
23 ulong r16;
24 ulong r17;
25 ulong r18;
26 ulong r19;
27 ulong r20;
28 ulong r21;
29 ulong r22;
30 ulong r23;
31 ulong r24;
32 ulong r25;
33 ulong r26;
34 ulong r27;
35 ulong r28;
36 ulong r29;
37 ulong r30;
38 ulong r31;
39 ulong y;
40 ulong tbr;
41 ulong psr;
42 ulong npc;
43 ulong pc;
44 ulong pad; /* so structure is double word aligned */
45};
Inferno/spim/include/lib9.h+8−0
@@ -0,0 +1,8 @@
1#include <u.h>
2#include <kern.h>
3
4/*
5 * Extensions for Inferno to basic libc.h
6 */
7
8#define __LITTLE_ENDIAN /* math/dtoa.c; longs in MIPS doubles are little-endian in LE mode */
Inferno/spim/include/u.h+56−0
@@ -0,0 +1,56 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef ushort Rune;
10typedef union FPdbleword FPdbleword;
11typedef long jmp_buf[2];
12#define JMPBUFSP 0
13#define JMPBUFPC 1
14#define JMPBUFDPC 0
15typedef unsigned int mpdigit; /* for /sys/include/mp.h */
16typedef unsigned int u32int; /* for /sys/include/libsec.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned long uintptr;
20
21/* FCR */
22#define FPINEX (1<<7)
23#define FPUNFL (1<<8)
24#define FPOVFL (1<<9)
25#define FPZDIV (1<<10)
26#define FPINVAL (1<<11)
27#define FPRNR (0<<0)
28#define FPRZ (1<<0)
29#define FPRPINF (2<<0)
30#define FPRNINF (3<<0)
31#define FPRMASK (3<<0)
32#define FPPEXT 0
33#define FPPSGL 0
34#define FPPDBL 0
35#define FPPMASK 0
36/* FSR */
37#define FPAINEX (1<<2)
38#define FPAOVFL (1<<4)
39#define FPAUNFL (1<<3)
40#define FPAZDIV (1<<5)
41#define FPAINVAL (1<<6)
42union FPdbleword
43{
44 double x;
45 struct { /* little endian */
46 ulong lo;
47 ulong hi;
48 };
49};
50
51/* stdarg */
52typedef char *va_list;
53#define va_start(list, start) list = (sizeof(start)<4 ? (char *)((int *)&(start)+1) : \
54(char *)(&(start)+1))
55#define va_arg(list, mode) ((mode*)(list += sizeof(mode)))[-1]
56#define va_end(list)
Inferno/thumb/include/lib9.h+8−0
@@ -0,0 +1,8 @@
1#include <u.h>
2#include <kern.h>
3
4/*
5 * Extensions for Inferno to basic libc.h
6 */
7
8#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in ARM doubles are big-endian */
Inferno/thumb/include/u.h+65−0
@@ -0,0 +1,65 @@
1#define nil ((void*)0)
2
3typedef unsigned short ushort;
4typedef unsigned char uchar;
5typedef unsigned long ulong;
6typedef unsigned int uint;
7typedef signed char schar;
8typedef long long vlong;
9typedef unsigned long long uvlong;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21typedef unsigned long uintptr;
22
23/* FCR */
24#define FPINEX (1<<20)
25#define FPUNFL (1<<19)
26#define FPOVFL (1<<18)
27#define FPZDIV (1<<17)
28#define FPINVAL (1<<16)
29#define FPRNR (0<<0)
30#define FPRZ (1<<0)
31#define FPRPINF (2<<0)
32#define FPRNINF (3<<0)
33#define FPRMASK (3<<0)
34#define FPPEXT 0
35#define FPPSGL 0
36#define FPPDBL 0
37#define FPPMASK 0
38/* FSR */
39#define FPAINEX (1<<4)
40#define FPAUNFL (1<<3)
41#define FPAOVFL (1<<2)
42#define FPAZDIV (1<<1)
43#define FPAINVAL (1<<0)
44union FPdbleword
45{
46 double x;
47 struct { /* big endian (on 7500) */
48 ulong hi;
49 ulong lo;
50 };
51};
52
53typedef char* va_list;
54#define va_start(list, start) list =\
55 (sizeof(start) < 4?\
56 (char*)((int*)&(start)+1):\
57 (char*)(&(start)+1))
58#define va_end(list)\
59 USED(list)
60#define va_arg(list, mode)\
61 ((sizeof(mode) == 1)?\
62 ((mode*)(list += 4))[-4]:\
63 (sizeof(mode) == 2)?\
64 ((mode*)(list += 4))[-2]:\
65 ((mode*)(list += sizeof(mode)))[-1])
Inferno/thumb/include/ureg.h+24−0
@@ -0,0 +1,24 @@
1typedef struct Ureg {
2 uint r0;
3 uint r1;
4 uint r2;
5 uint r3;
6 uint r4;
7 uint r5;
8 uint r6;
9 uint r7;
10 uint r8;
11 uint r9;
12 uint r10;
13 uint r11;
14 uint r12;
15 union {
16 uint r13;
17 uint sp;
18 };
19 uint r14;
20 uint link;
21 uint type;
22 uint psr;
23 uint pc;
24} Ureg;
Irix/mips/bin/awk+0−0

Binary file not shown.

Irix/mips/bin/data2c+0−0

Binary file not shown.

Irix/mips/bin/iyacc+0−0

Binary file not shown.

Irix/mips/bin/mk+0−0

Binary file not shown.

Irix/mips/bin/mkext+0−0

Binary file not shown.

Irix/mips/include/emu.h+22−0
@@ -0,0 +1,22 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12/*
13 * This structure must agree with FPsave and FPrestore asm routines
14 */
15struct FPU
16{
17 ulong fcr31;
18};
19
20typedef sigjmp_buf osjmpbuf;
21#define ossetjmp(buf) sigsetjmp(buf, 1)
22
Irix/mips/include/lib9.h+454−0
@@ -0,0 +1,454 @@
1#define _LARGEFILE64_SOURCE 1
2#define _FILE_OFFSET_BITS 64
3#include <sys/types.h>
4#include <sys/stat.h>
5#define _POSIX_SOURCE
6#include <stdlib.h>
7#include <stdarg.h>
8#include <unistd.h>
9#include <errno.h>
10#include <string.h>
11#include "math.h"
12#include <fcntl.h>
13#include <setjmp.h>
14#include <float.h>
15#include <sys/bsd_types.h>
16#include <time.h>
17
18#define getwd infgetwd
19
20#ifndef EMU
21typedef struct Proc Proc;
22#endif
23
24#define nil ((void*)0)
25
26typedef unsigned char uchar;
27typedef signed char schar;
28typedef unsigned short Rune;
29typedef long long int vlong;
30typedef unsigned long long int uvlong;
31typedef unsigned int u32int;
32typedef uvlong u64int;
33
34typedef unsigned int mpdigit; /* for /sys/include/mp.h */
35typedef unsigned short u16int;
36typedef unsigned char u8int;
37typedef unsigned long uintptr;
38
39typedef signed char int8;
40typedef unsigned char uint8;
41typedef short int16;
42typedef unsigned short uint16;
43typedef int int32;
44typedef unsigned int uint32;
45typedef long long int64;
46typedef unsigned long long uint64;
47
48#define USED(x) if(x){}else{}
49#define SET(x)
50
51#undef nelem
52#define nelem(x) (sizeof(x)/sizeof((x)[0]))
53#undef offsetof
54#define offsetof(s, m) (ulong)(&(((s*)0)->m))
55#undef assert
56#define assert(x) if(x){}else _assert("x")
57
58/*
59 * most mem and string routines are declared by ANSI/POSIX files above
60 */
61
62extern char* strecpy(char*, char*, char*);
63extern char* strdup(const char*);
64extern int cistrncmp(char*, char*, int);
65extern int cistrcmp(char*, char*);
66extern char* cistrstr(char*, char*);
67extern int tokenize(char*, char**, int);
68
69enum
70{
71 UTFmax = 3, /* maximum bytes per rune */
72 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
73 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
74 Runeerror = 0x80 /* decoding error in UTF */
75};
76
77/*
78 * rune routines
79 */
80extern int runetochar(char*, Rune*);
81extern int chartorune(Rune*, char*);
82extern int runelen(long);
83extern int runenlen(Rune*, int);
84extern int fullrune(char*, int);
85extern int utflen(char*);
86extern int utfnlen(char*, long);
87extern char* utfrune(char*, long);
88extern char* utfrrune(char*, long);
89extern char* utfutf(char*, char*);
90extern char* utfecpy(char*, char*, char*);
91
92extern Rune* runestrcat(Rune*, Rune*);
93extern Rune* runestrchr(Rune*, Rune);
94extern int runestrcmp(Rune*, Rune*);
95extern Rune* runestrcpy(Rune*, Rune*);
96extern Rune* runestrncpy(Rune*, Rune*, long);
97extern Rune* runestrecpy(Rune*, Rune*, Rune*);
98extern Rune* runestrdup(Rune*);
99extern Rune* runestrncat(Rune*, Rune*, long);
100extern int runestrncmp(Rune*, Rune*, long);
101extern Rune* runestrrchr(Rune*, Rune);
102extern long runestrlen(Rune*);
103extern Rune* runestrstr(Rune*, Rune*);
104
105extern Rune tolowerrune(Rune);
106extern Rune totitlerune(Rune);
107extern Rune toupperrune(Rune);
108extern int isalpharune(Rune);
109extern int islowerrune(Rune);
110extern int isspacerune(Rune);
111extern int istitlerune(Rune);
112extern int isupperrune(Rune);
113
114/*
115 * malloc
116 */
117extern void* malloc(size_t);
118extern void* mallocz(ulong, int);
119extern void free(void*);
120extern ulong msize(void*);
121extern void* calloc(size_t, size_t);
122extern void* realloc(void*, size_t);
123extern void setmalloctag(void*, ulong);
124extern void setrealloctag(void*, ulong);
125extern ulong getmalloctag(void*);
126extern ulong getrealloctag(void*);
127extern void* malloctopoolblock(void*);
128
129/*
130 * print routines
131 */
132typedef struct Fmt Fmt;
133struct Fmt{
134 uchar runes; /* output buffer is runes or chars? */
135 void *start; /* of buffer */
136 void *to; /* current place in the buffer */
137 void *stop; /* end of the buffer; overwritten if flush fails */
138 int (*flush)(Fmt *); /* called when to == stop */
139 void *farg; /* to make flush a closure */
140 int nfmt; /* num chars formatted so far */
141 va_list args; /* args passed to dofmt */
142 int r; /* % format Rune */
143 int width;
144 int prec;
145 ulong flags;
146};
147extern vlong osnsec(void);
148#define nsec osnsec
149
150enum{
151 FmtWidth = 1,
152 FmtLeft = FmtWidth << 1,
153 FmtPrec = FmtLeft << 1,
154 FmtSharp = FmtPrec << 1,
155 FmtSpace = FmtSharp << 1,
156 FmtSign = FmtSpace << 1,
157 FmtZero = FmtSign << 1,
158 FmtUnsigned = FmtZero << 1,
159 FmtShort = FmtUnsigned << 1,
160 FmtLong = FmtShort << 1,
161 FmtVLong = FmtLong << 1,
162 FmtComma = FmtVLong << 1,
163 FmtByte = FmtComma << 1,
164
165 FmtFlag = FmtByte << 1
166};
167
168extern int print(char*, ...);
169extern char* seprint(char*, char*, char*, ...);
170extern char* vseprint(char*, char*, char*, va_list);
171extern int snprint(char*, int, char*, ...);
172extern int vsnprint(char*, int, char*, va_list);
173extern char* smprint(char*, ...);
174extern char* vsmprint(char*, va_list);
175extern int sprint(char*, char*, ...);
176extern int fprint(int, char*, ...);
177extern int vfprint(int, char*, va_list);
178
179extern int runesprint(Rune*, char*, ...);
180extern int runesnprint(Rune*, int, char*, ...);
181extern int runevsnprint(Rune*, int, char*, va_list);
182extern Rune* runeseprint(Rune*, Rune*, char*, ...);
183extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
184extern Rune* runesmprint(char*, ...);
185extern Rune* runevsmprint(char*, va_list);
186
187extern int fmtfdinit(Fmt*, int, char*, int);
188extern int fmtfdflush(Fmt*);
189extern int fmtstrinit(Fmt*);
190extern char* fmtstrflush(Fmt*);
191extern int runefmtstrinit(Fmt*);
192extern Rune* runefmtstrflush(Fmt*);
193
194extern int fmtinstall(int, int (*)(Fmt*));
195extern int dofmt(Fmt*, char*);
196extern int dorfmt(Fmt*, Rune*);
197extern int fmtprint(Fmt*, char*, ...);
198extern int fmtvprint(Fmt*, char*, va_list);
199extern int fmtrune(Fmt*, int);
200extern int fmtstrcpy(Fmt*, char*);
201extern int fmtrunestrcpy(Fmt*, Rune*);
202/*
203 * error string for %r
204 * supplied on per os basis, not part of fmt library
205 */
206extern int errfmt(Fmt *f);
207
208/*
209 * quoted strings
210 */
211extern char *unquotestrdup(char*);
212extern Rune *unquoterunestrdup(Rune*);
213extern char *quotestrdup(char*);
214extern Rune *quoterunestrdup(Rune*);
215extern int quotestrfmt(Fmt*);
216extern int quoterunestrfmt(Fmt*);
217extern void quotefmtinstall(void);
218extern int (*doquote)(int);
219
220/*
221 * random number
222 */
223extern ulong truerand(void);
224extern ulong ntruerand(ulong);
225
226/*
227 * math
228 */
229extern int isNaN(double);
230extern int isInf(double, int);
231
232/*
233 * Time-of-day
234 */
235
236typedef struct Tm Tm;
237struct Tm {
238 int sec;
239 int min;
240 int hour;
241 int mday;
242 int mon;
243 int year;
244 int wday;
245 int yday;
246 char zone[4];
247 int tzoff;
248};
249
250/*
251 * one-of-a-kind
252 */
253extern void _assert(char*);
254extern double charstod(int(*)(void*), void*);
255extern char* cleanname(char*);
256extern uintptr getcallerpc(void*);
257extern int getfields(char*, char**, int, int, char*);
258extern char* getuser(void);
259extern char* getwd(char*, int);
260extern double ipow10(int);
261#define pow10 infpow10
262extern double pow10(int);
263extern vlong strtoll(const char*, char**, int);
264#define qsort infqsort
265extern void qsort(void*, long, long, int (*)(void*, void*));
266extern uvlong strtoull(const char*, char**, int);
267extern void sysfatal(char*, ...);
268extern int dec64(uchar*, int, char*, int);
269extern int enc64(char*, int, uchar*, int);
270extern int dec32(uchar*, int, char*, int);
271extern int enc32(char*, int, uchar*, int);
272extern int dec16(uchar*, int, char*, int);
273extern int enc16(char*, int, uchar*, int);
274extern int encodefmt(Fmt*);
275
276/*
277 * synchronization
278 */
279typedef
280struct Lock {
281 int val;
282 int pid;
283} Lock;
284
285extern int _tas(int*);
286
287extern void lock(Lock*);
288extern void unlock(Lock*);
289extern int canlock(Lock*);
290
291typedef struct QLock QLock;
292struct QLock
293{
294 Lock use; /* to access Qlock structure */
295 Proc *head; /* next process waiting for object */
296 Proc *tail; /* last process waiting for object */
297 int locked; /* flag */
298};
299
300extern void qlock(QLock*);
301extern void qunlock(QLock*);
302extern int canqlock(QLock*);
303extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
304
305typedef
306struct RWLock
307{
308 Lock l; /* Lock modify lock */
309 QLock x; /* Mutual exclusion lock */
310 QLock k; /* Lock for waiting writers */
311 int readers; /* Count of readers in lock */
312} RWLock;
313
314extern int canrlock(RWLock*);
315extern int canwlock(RWLock*);
316extern void rlock(RWLock*);
317extern void runlock(RWLock*);
318extern void wlock(RWLock*);
319extern void wunlock(RWLock*);
320
321/*
322 * network dialing
323 */
324#define NETPATHLEN 40
325
326/*
327 * system calls
328 *
329 */
330#define STATMAX 65535U /* max length of machine-independent stat structure */
331#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
332#define ERRMAX 128 /* max length of error string */
333
334#define MORDER 0x0003 /* mask for bits defining order of mounting */
335#define MREPL 0x0000 /* mount replaces object */
336#define MBEFORE 0x0001 /* mount goes before others in union directory */
337#define MAFTER 0x0002 /* mount goes after others in union directory */
338#define MCREATE 0x0004 /* permit creation in mounted directory */
339#define MCACHE 0x0010 /* cache some data */
340#define MMASK 0x0017 /* all bits on */
341
342#define OREAD 0 /* open for read */
343#define OWRITE 1 /* write */
344#define ORDWR 2 /* read and write */
345#define OEXEC 3 /* execute, == read but check execute permission */
346#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
347#define OCEXEC 32 /* or'ed in, close on exec */
348#define ORCLOSE 64 /* or'ed in, remove on close */
349#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
350
351#define AEXIST 0 /* accessible: exists */
352#define AEXEC 1 /* execute access */
353#define AWRITE 2 /* write access */
354#define AREAD 4 /* read access */
355
356/* bits in Qid.type */
357#define QTDIR 0x80 /* type bit for directories */
358#define QTAPPEND 0x40 /* type bit for append only files */
359#define QTEXCL 0x20 /* type bit for exclusive use files */
360#define QTMOUNT 0x10 /* type bit for mounted channel */
361#define QTAUTH 0x08 /* type bit for authentication file */
362#define QTFILE 0x00 /* plain file */
363
364/* bits in Dir.mode */
365#define DMDIR 0x80000000 /* mode bit for directories */
366#define DMAPPEND 0x40000000 /* mode bit for append only files */
367#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
368#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
369#define DMAUTH 0x08000000 /* mode bit for authentication file */
370#define DMREAD 0x4 /* mode bit for read permission */
371#define DMWRITE 0x2 /* mode bit for write permission */
372#define DMEXEC 0x1 /* mode bit for execute permission */
373
374typedef
375struct Qid
376{
377 uvlong path;
378 ulong vers;
379 uchar type;
380} Qid;
381
382typedef
383struct Dir {
384 /* system-modified data */
385 ushort type; /* server type */
386 uint dev; /* server subtype */
387 /* file data */
388 Qid qid; /* unique id from server */
389 ulong mode; /* permissions */
390 ulong atime; /* last read time */
391 ulong mtime; /* last write time */
392 vlong length; /* file length */
393 char *name; /* last element of path */
394 char *uid; /* owner name */
395 char *gid; /* group name */
396 char *muid; /* last modifier name */
397} Dir;
398
399extern Dir* dirstat(char*);
400extern Dir* dirfstat(int);
401extern int dirwstat(char*, Dir*);
402extern int dirfwstat(int, Dir*);
403extern long dirread(int, Dir**);
404extern void nulldir(Dir*);
405extern long dirreadall(int, Dir**);
406
407typedef
408struct Waitmsg
409{
410 int pid; /* of loved one */
411 ulong time[3]; /* of loved one & descendants */
412 char *msg;
413} Waitmsg;
414
415extern void _exits(char*);
416
417extern void exits(char*);
418extern int create(char*, int, int);
419extern int errstr(char*, uint);
420
421extern void perror(const char*);
422extern long readn(int, void*, long);
423extern int remove(const char*);
424extern void rerrstr(char*, uint);
425extern vlong seek(int, vlong, int);
426extern void werrstr(char*, ...);
427
428extern char *argv0;
429#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
430 argv[0] && argv[0][0]=='-' && argv[0][1];\
431 argc--, argv++) {\
432 char *_args, *_argt;\
433 Rune _argc;\
434 _args = &argv[0][1];\
435 if(_args[0]=='-' && _args[1]==0){\
436 argc--; argv++; break;\
437 }\
438 _argc = 0;\
439 while(*_args && (_args += chartorune(&_argc, _args)))\
440 switch(_argc)
441#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
442#define ARGF() (_argt=_args, _args="",\
443 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
444#define EARGF(x) (_argt=_args, _args="",\
445 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
446
447#define ARGC() _argc
448
449/*
450 * Extensions for Inferno to basic libc.h
451 */
452
453#define setbinmode()
454
Linux/386/bin/data2c+0−0

Binary file not shown.

Linux/386/bin/iyacc+0−0

Binary file not shown.

Linux/386/bin/mk+0−0

Binary file not shown.

Linux/386/bin/mkext+0−0

Binary file not shown.

Linux/386/include/emu.h+33−0
@@ -0,0 +1,33 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16#define KSTACK (32 * 1024)
17
18#ifndef USE_PTHREADS
19static __inline Proc *getup(void) {
20 Proc *p;
21 __asm__( "movl %%esp, %%eax\n\t"
22 : "=a" (p)
23 );
24 return *(Proc **)((uintptr)p & ~(KSTACK - 1));
25}
26#else
27extern Proc* getup(void);
28#endif
29
30#define up (getup())
31
32typedef sigjmp_buf osjmpbuf;
33#define ossetjmp(buf) sigsetjmp(buf, 1)
Linux/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * Linux 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
Linux/386/include/lib9.h+462−0
@@ -0,0 +1,462 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#define USE_PTHREADS
3#ifndef _BSD_SOURCE
4#define _BSD_SOURCE
5#endif
6#define _XOPEN_SOURCE 500
7#define _LARGEFILE_SOURCE 1
8#define _LARGEFILE64_SOURCE 1
9#define _FILE_OFFSET_BITS 64
10#ifdef USE_PTHREADS
11#define _REENTRANT 1
12#endif
13#include <features.h>
14#include <sys/types.h>
15#include <stdlib.h>
16#include <stdarg.h>
17#define sync __os_sync
18#include <unistd.h>
19#undef sync
20#include <errno.h>
21#define __NO_STRING_INLINES
22#include <string.h>
23#include "math.h"
24#include <fcntl.h>
25#include <setjmp.h>
26#include <float.h>
27#include <endian.h>
28
29#define getwd infgetwd
30
31#ifndef EMU
32typedef struct Proc Proc;
33#endif
34
35/*
36 * math module dtoa
37 * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
38 */
39
40#define nil ((void*)0)
41
42typedef unsigned char uchar;
43typedef signed char schar;
44typedef unsigned short Rune;
45typedef long long int vlong;
46typedef unsigned long long int uvlong;
47typedef unsigned int u32int;
48typedef uvlong u64int;
49
50typedef unsigned int mpdigit; /* for /sys/include/mp.h */
51typedef unsigned short u16int;
52typedef unsigned char u8int;
53typedef unsigned long uintptr;
54
55#define USED(x) if(x){}else{}
56#define SET(x)
57
58#undef nelem
59#define nelem(x) (sizeof(x)/sizeof((x)[0]))
60#undef offsetof
61#define offsetof(s, m) (ulong)(&(((s*)0)->m))
62#undef assert
63#define assert(x) if(x){}else _assert("x")
64
65/*
66 * most mem and string routines are declared by ANSI/POSIX files above
67 */
68
69extern char* strecpy(char*, char*, char*);
70extern char* strdup(const char*);
71extern int cistrncmp(char*, char*, int);
72extern int cistrcmp(char*, char*);
73extern char* cistrstr(char*, char*);
74extern int tokenize(char*, char**, int);
75
76enum
77{
78 UTFmax = 3, /* maximum bytes per rune */
79 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
80 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
81 Runeerror = 0x80 /* decoding error in UTF */
82};
83
84/*
85 * rune routines
86 */
87extern int runetochar(char*, Rune*);
88extern int chartorune(Rune*, char*);
89extern int runelen(long);
90extern int runenlen(Rune*, int);
91extern int fullrune(char*, int);
92extern int utflen(char*);
93extern int utfnlen(char*, long);
94extern char* utfrune(char*, long);
95extern char* utfrrune(char*, long);
96extern char* utfutf(char*, char*);
97extern char* utfecpy(char*, char*, char*);
98
99extern Rune* runestrcat(Rune*, Rune*);
100extern Rune* runestrchr(Rune*, Rune);
101extern int runestrcmp(Rune*, Rune*);
102extern Rune* runestrcpy(Rune*, Rune*);
103extern Rune* runestrncpy(Rune*, Rune*, long);
104extern Rune* runestrecpy(Rune*, Rune*, Rune*);
105extern Rune* runestrdup(Rune*);
106extern Rune* runestrncat(Rune*, Rune*, long);
107extern int runestrncmp(Rune*, Rune*, long);
108extern Rune* runestrrchr(Rune*, Rune);
109extern long runestrlen(Rune*);
110extern Rune* runestrstr(Rune*, Rune*);
111
112extern Rune tolowerrune(Rune);
113extern Rune totitlerune(Rune);
114extern Rune toupperrune(Rune);
115extern int isalpharune(Rune);
116extern int islowerrune(Rune);
117extern int isspacerune(Rune);
118extern int istitlerune(Rune);
119extern int isupperrune(Rune);
120
121/*
122 * malloc
123 */
124extern void* malloc(size_t);
125extern void* mallocz(ulong, int);
126extern void free(void*);
127extern ulong msize(void*);
128extern void* calloc(size_t, size_t);
129extern void* realloc(void*, size_t);
130extern void setmalloctag(void*, ulong);
131extern void setrealloctag(void*, ulong);
132extern ulong getmalloctag(void*);
133extern ulong getrealloctag(void*);
134extern void* malloctopoolblock(void*);
135
136/*
137 * print routines
138 */
139typedef struct Fmt Fmt;
140struct Fmt{
141 uchar runes; /* output buffer is runes or chars? */
142 void *start; /* of buffer */
143 void *to; /* current place in the buffer */
144 void *stop; /* end of the buffer; overwritten if flush fails */
145 int (*flush)(Fmt *); /* called when to == stop */
146 void *farg; /* to make flush a closure */
147 int nfmt; /* num chars formatted so far */
148 va_list args; /* args passed to dofmt */
149 int r; /* % format Rune */
150 int width;
151 int prec;
152 ulong flags;
153};
154
155enum{
156 FmtWidth = 1,
157 FmtLeft = FmtWidth << 1,
158 FmtPrec = FmtLeft << 1,
159 FmtSharp = FmtPrec << 1,
160 FmtSpace = FmtSharp << 1,
161 FmtSign = FmtSpace << 1,
162 FmtZero = FmtSign << 1,
163 FmtUnsigned = FmtZero << 1,
164 FmtShort = FmtUnsigned << 1,
165 FmtLong = FmtShort << 1,
166 FmtVLong = FmtLong << 1,
167 FmtComma = FmtVLong << 1,
168 FmtByte = FmtComma << 1,
169
170 FmtFlag = FmtByte << 1
171};
172
173extern int print(char*, ...);
174extern char* seprint(char*, char*, char*, ...);
175extern char* vseprint(char*, char*, char*, va_list);
176extern int snprint(char*, int, char*, ...);
177extern int vsnprint(char*, int, char*, va_list);
178extern char* smprint(char*, ...);
179extern char* vsmprint(char*, va_list);
180extern int sprint(char*, char*, ...);
181extern int fprint(int, char*, ...);
182extern int vfprint(int, char*, va_list);
183
184extern int runesprint(Rune*, char*, ...);
185extern int runesnprint(Rune*, int, char*, ...);
186extern int runevsnprint(Rune*, int, char*, va_list);
187extern Rune* runeseprint(Rune*, Rune*, char*, ...);
188extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
189extern Rune* runesmprint(char*, ...);
190extern Rune* runevsmprint(char*, va_list);
191
192extern int fmtfdinit(Fmt*, int, char*, int);
193extern int fmtfdflush(Fmt*);
194extern int fmtstrinit(Fmt*);
195extern char* fmtstrflush(Fmt*);
196extern int runefmtstrinit(Fmt*);
197extern Rune* runefmtstrflush(Fmt*);
198
199extern int fmtinstall(int, int (*)(Fmt*));
200extern int dofmt(Fmt*, char*);
201extern int dorfmt(Fmt*, Rune*);
202extern int fmtprint(Fmt*, char*, ...);
203extern int fmtvprint(Fmt*, char*, va_list);
204extern int fmtrune(Fmt*, int);
205extern int fmtstrcpy(Fmt*, char*);
206extern int fmtrunestrcpy(Fmt*, Rune*);
207/*
208 * error string for %r
209 * supplied on per os basis, not part of fmt library
210 */
211extern int errfmt(Fmt *f);
212
213/*
214 * quoted strings
215 */
216extern char *unquotestrdup(char*);
217extern Rune *unquoterunestrdup(Rune*);
218extern char *quotestrdup(char*);
219extern Rune *quoterunestrdup(Rune*);
220extern int quotestrfmt(Fmt*);
221extern int quoterunestrfmt(Fmt*);
222extern void quotefmtinstall(void);
223extern int (*doquote)(int);
224
225/*
226 * random number
227 */
228extern ulong truerand(void);
229extern ulong ntruerand(ulong);
230
231/*
232 * math
233 */
234extern int isNaN(double);
235extern int isInf(double, int);
236
237/*
238 * Time-of-day
239 */
240
241typedef struct Tm Tm;
242struct Tm {
243 int sec;
244 int min;
245 int hour;
246 int mday;
247 int mon;
248 int year;
249 int wday;
250 int yday;
251 char zone[4];
252 int tzoff;
253};
254extern vlong osnsec(void);
255#define nsec osnsec
256
257/*
258 * one-of-a-kind
259 */
260extern void _assert(char*);
261extern double charstod(int(*)(void*), void*);
262extern char* cleanname(char*);
263extern uintptr getcallerpc(void*);
264extern int getfields(char*, char**, int, int, char*);
265extern char* getuser(void);
266extern char* getwd(char*, int);
267extern double ipow10(int);
268#define pow10 infpow10
269extern double pow10(int);
270extern vlong strtoll(const char*, char**, int);
271#define qsort infqsort
272extern void qsort(void*, long, long, int (*)(void*, void*));
273extern uvlong strtoull(const char*, char**, int);
274extern void sysfatal(char*, ...);
275extern int dec64(uchar*, int, char*, int);
276extern int enc64(char*, int, uchar*, int);
277extern int dec32(uchar*, int, char*, int);
278extern int enc32(char*, int, uchar*, int);
279extern int dec16(uchar*, int, char*, int);
280extern int enc16(char*, int, uchar*, int);
281extern int encodefmt(Fmt*);
282
283/*
284 * synchronization
285 */
286typedef
287struct Lock {
288 int val;
289 int pid;
290} Lock;
291
292extern int _tas(int*);
293
294extern void lock(Lock*);
295extern void unlock(Lock*);
296extern int canlock(Lock*);
297
298typedef struct QLock QLock;
299struct QLock
300{
301 Lock use; /* to access Qlock structure */
302 Proc *head; /* next process waiting for object */
303 Proc *tail; /* last process waiting for object */
304 int locked; /* flag */
305};
306
307extern void qlock(QLock*);
308extern void qunlock(QLock*);
309extern int canqlock(QLock*);
310extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
311
312typedef
313struct RWLock
314{
315 Lock l; /* Lock modify lock */
316 QLock x; /* Mutual exclusion lock */
317 QLock k; /* Lock for waiting writers */
318 int readers; /* Count of readers in lock */
319} RWLock;
320
321extern int canrlock(RWLock*);
322extern int canwlock(RWLock*);
323extern void rlock(RWLock*);
324extern void runlock(RWLock*);
325extern void wlock(RWLock*);
326extern void wunlock(RWLock*);
327
328/*
329 * network dialing
330 */
331#define NETPATHLEN 40
332
333/*
334 * system calls
335 *
336 */
337#define STATMAX 65535U /* max length of machine-independent stat structure */
338#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
339#define ERRMAX 128 /* max length of error string */
340
341#define MORDER 0x0003 /* mask for bits defining order of mounting */
342#define MREPL 0x0000 /* mount replaces object */
343#define MBEFORE 0x0001 /* mount goes before others in union directory */
344#define MAFTER 0x0002 /* mount goes after others in union directory */
345#define MCREATE 0x0004 /* permit creation in mounted directory */
346#define MCACHE 0x0010 /* cache some data */
347#define MMASK 0x0017 /* all bits on */
348
349#define OREAD 0 /* open for read */
350#define OWRITE 1 /* write */
351#define ORDWR 2 /* read and write */
352#define OEXEC 3 /* execute, == read but check execute permission */
353#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
354#define OCEXEC 32 /* or'ed in, close on exec */
355#define ORCLOSE 64 /* or'ed in, remove on close */
356#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
357
358#define AEXIST 0 /* accessible: exists */
359#define AEXEC 1 /* execute access */
360#define AWRITE 2 /* write access */
361#define AREAD 4 /* read access */
362
363/* bits in Qid.type */
364#define QTDIR 0x80 /* type bit for directories */
365#define QTAPPEND 0x40 /* type bit for append only files */
366#define QTEXCL 0x20 /* type bit for exclusive use files */
367#define QTMOUNT 0x10 /* type bit for mounted channel */
368#define QTAUTH 0x08 /* type bit for authentication file */
369#define QTFILE 0x00 /* plain file */
370
371/* bits in Dir.mode */
372#define DMDIR 0x80000000 /* mode bit for directories */
373#define DMAPPEND 0x40000000 /* mode bit for append only files */
374#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
375#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
376#define DMAUTH 0x08000000 /* mode bit for authentication file */
377#define DMREAD 0x4 /* mode bit for read permission */
378#define DMWRITE 0x2 /* mode bit for write permission */
379#define DMEXEC 0x1 /* mode bit for execute permission */
380
381typedef
382struct Qid
383{
384 uvlong path;
385 ulong vers;
386 uchar type;
387} Qid;
388
389typedef
390struct Dir {
391 /* system-modified data */
392 ushort type; /* server type */
393 uint dev; /* server subtype */
394 /* file data */
395 Qid qid; /* unique id from server */
396 ulong mode; /* permissions */
397 ulong atime; /* last read time */
398 ulong mtime; /* last write time */
399 vlong length; /* file length */
400 char *name; /* last element of path */
401 char *uid; /* owner name */
402 char *gid; /* group name */
403 char *muid; /* last modifier name */
404} Dir;
405
406extern Dir* dirstat(char*);
407extern Dir* dirfstat(int);
408extern int dirwstat(char*, Dir*);
409extern int dirfwstat(int, Dir*);
410extern long dirread(int, Dir**);
411extern void nulldir(Dir*);
412extern long dirreadall(int, Dir**);
413
414typedef
415struct Waitmsg
416{
417 int pid; /* of loved one */
418 ulong time[3]; /* of loved one & descendants */
419 char *msg;
420} Waitmsg;
421
422extern void _exits(char*);
423
424extern void exits(char*);
425extern int create(char*, int, int);
426extern int errstr(char*, uint);
427
428extern void perror(const char*);
429extern long readn(int, void*, long);
430extern int remove(const char*);
431extern void rerrstr(char*, uint);
432extern vlong seek(int, vlong, int);
433extern int segflush(void*, ulong);
434extern void werrstr(char*, ...);
435
436extern char *argv0;
437#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
438 argv[0] && argv[0][0]=='-' && argv[0][1];\
439 argc--, argv++) {\
440 char *_args, *_argt;\
441 Rune _argc;\
442 _args = &argv[0][1];\
443 if(_args[0]=='-' && _args[1]==0){\
444 argc--; argv++; break;\
445 }\
446 _argc = 0;\
447 while(*_args && (_args += chartorune(&_argc, _args)))\
448 switch(_argc)
449#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
450#define ARGF() (_argt=_args, _args="",\
451 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
452#define EARGF(x) (_argt=_args, _args="",\
453 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
454
455#define ARGC() _argc
456
457/*
458 * Extensions for Inferno to basic libc.h
459 */
460
461#define setbinmode()
462
Linux/arm/include/emu.h+34−0
@@ -0,0 +1,34 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16
17#ifndef USE_PTHREADS
18#define KSTACK (16 * 1024) /* must be power of two */
19static __inline Proc *getup(void) {
20 Proc *p;
21 __asm__( "mov %0, %%sp;"
22 : "=r" (p)
23 );
24 return *(Proc **)((uintptr)p & ~(KSTACK - 1));
25}
26#else
27#define KSTACK (32 * 1024) /* need not be power of two */
28extern Proc* getup(void);
29#endif
30
31#define up (getup())
32
33typedef sigjmp_buf osjmpbuf;
34#define ossetjmp(buf) sigsetjmp(buf, 1)
Linux/arm/include/fpuctl.h+52−0
@@ -0,0 +1,52 @@
1/*
2 * Linux arm fpu support
3 * Mimic Plan9 floating point support
4 */
5
6#include <fenv.h>
7
8static void
9setfcr(ulong fcr)
10{
11}
12
13static ulong
14getfcr(void)
15{
16 ulong fcr = 0;
17 return fcr;
18}
19
20static ulong
21getfsr(void)
22{
23 ulong fsr = -1;
24 return fsr;
25}
26
27static void
28setfsr(ulong fsr)
29{
30}
31
32/* FCR */
33#define FPINEX (1<<5)
34#define FPUNFL ((1<<4)|(1<<1))
35#define FPOVFL (1<<3)
36#define FPZDIV (1<<2)
37#define FPINVAL (1<<0)
38#define FPRNR (0<<10)
39#define FPRZ (3<<10)
40#define FPRPINF (2<<10)
41#define FPRNINF (1<<10)
42#define FPRMASK (3<<10)
43#define FPPEXT (3<<8)
44#define FPPSGL (0<<8)
45#define FPPDBL (2<<8)
46#define FPPMASK (3<<8)
47/* FSR */
48#define FPAINEX FPINEX
49#define FPAOVFL FPOVFL
50#define FPAUNFL FPUNFL
51#define FPAZDIV FPZDIV
52#define FPAINVAL FPINVAL
Linux/arm/include/lib9.h+470−0
@@ -0,0 +1,470 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#define USE_PTHREADS
3#ifndef _BSD_SOURCE
4#define _BSD_SOURCE
5#endif
6#define _XOPEN_SOURCE 500
7#define _LARGEFILE_SOURCE 1
8#define _LARGEFILE64_SOURCE 1
9#define _FILE_OFFSET_BITS 64
10#ifdef USE_PTHREADS
11#define _REENTRANT 1
12#endif
13#include <features.h>
14#include <sys/types.h>
15#include <stdlib.h>
16#include <stdarg.h>
17#define sync __os_sync
18#include <unistd.h>
19#undef sync
20#include <errno.h>
21#define __NO_STRING_INLINES
22#include <string.h>
23#include "math.h"
24#include <fcntl.h>
25#include <setjmp.h>
26#include <float.h>
27#include <endian.h>
28
29#define getwd infgetwd
30
31#ifndef EMU
32typedef struct Proc Proc;
33#endif
34
35/*
36 * math module dtoa
37 * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
38 */
39
40#define nil ((void*)0)
41
42typedef unsigned char uchar;
43typedef signed char schar;
44typedef unsigned short Rune;
45typedef long long int vlong;
46typedef unsigned long long int uvlong;
47typedef unsigned int u32int;
48typedef uvlong u64int;
49
50typedef unsigned int mpdigit; /* for /sys/include/mp.h */
51typedef unsigned short u16int;
52typedef unsigned char u8int;
53typedef unsigned long uintptr;
54
55#define USED(x) if(x){}else{}
56#define SET(x)
57
58#undef nelem
59#define nelem(x) (sizeof(x)/sizeof((x)[0]))
60#undef offsetof
61#define offsetof(s, m) (ulong)(&(((s*)0)->m))
62#undef assert
63#define assert(x) if(x){}else _assert("x")
64
65/*
66 * most mem and string routines are declared by ANSI/POSIX files above
67 */
68
69extern char* strecpy(char*, char*, char*);
70extern char* strdup(const char*);
71extern int cistrncmp(char*, char*, int);
72extern int cistrcmp(char*, char*);
73extern char* cistrstr(char*, char*);
74extern int tokenize(char*, char**, int);
75
76enum
77{
78 UTFmax = 3, /* maximum bytes per rune */
79 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
80 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
81 Runeerror = 0x80 /* decoding error in UTF */
82};
83
84/*
85 * rune routines
86 */
87extern int runetochar(char*, Rune*);
88extern int chartorune(Rune*, char*);
89extern int runelen(long);
90extern int runenlen(Rune*, int);
91extern int fullrune(char*, int);
92extern int utflen(char*);
93extern int utfnlen(char*, long);
94extern char* utfrune(char*, long);
95extern char* utfrrune(char*, long);
96extern char* utfutf(char*, char*);
97extern char* utfecpy(char*, char*, char*);
98
99extern Rune* runestrcat(Rune*, Rune*);
100extern Rune* runestrchr(Rune*, Rune);
101extern int runestrcmp(Rune*, Rune*);
102extern Rune* runestrcpy(Rune*, Rune*);
103extern Rune* runestrncpy(Rune*, Rune*, long);
104extern Rune* runestrecpy(Rune*, Rune*, Rune*);
105extern Rune* runestrdup(Rune*);
106extern Rune* runestrncat(Rune*, Rune*, long);
107extern int runestrncmp(Rune*, Rune*, long);
108extern Rune* runestrrchr(Rune*, Rune);
109extern long runestrlen(Rune*);
110extern Rune* runestrstr(Rune*, Rune*);
111
112extern Rune tolowerrune(Rune);
113extern Rune totitlerune(Rune);
114extern Rune toupperrune(Rune);
115extern int isalpharune(Rune);
116extern int islowerrune(Rune);
117extern int isspacerune(Rune);
118extern int istitlerune(Rune);
119extern int isupperrune(Rune);
120
121/*
122 * malloc
123 */
124extern void* malloc(size_t);
125extern void* mallocz(ulong, int);
126extern void free(void*);
127extern ulong msize(void*);
128extern void* calloc(size_t, size_t);
129extern void* realloc(void*, size_t);
130extern void setmalloctag(void*, ulong);
131extern void setrealloctag(void*, ulong);
132extern ulong getmalloctag(void*);
133extern ulong getrealloctag(void*);
134extern void* malloctopoolblock(void*);
135
136/*
137 * print routines
138 */
139typedef struct Fmt Fmt;
140struct Fmt{
141 uchar runes; /* output buffer is runes or chars? */
142 void *start; /* of buffer */
143 void *to; /* current place in the buffer */
144 void *stop; /* end of the buffer; overwritten if flush fails */
145 int (*flush)(Fmt *); /* called when to == stop */
146 void *farg; /* to make flush a closure */
147 int nfmt; /* num chars formatted so far */
148 va_list args; /* args passed to dofmt */
149 int r; /* % format Rune */
150 int width;
151 int prec;
152 ulong flags;
153};
154
155enum{
156 FmtWidth = 1,
157 FmtLeft = FmtWidth << 1,
158 FmtPrec = FmtLeft << 1,
159 FmtSharp = FmtPrec << 1,
160 FmtSpace = FmtSharp << 1,
161 FmtSign = FmtSpace << 1,
162 FmtZero = FmtSign << 1,
163 FmtUnsigned = FmtZero << 1,
164 FmtShort = FmtUnsigned << 1,
165 FmtLong = FmtShort << 1,
166 FmtVLong = FmtLong << 1,
167 FmtComma = FmtVLong << 1,
168 FmtByte = FmtComma << 1,
169
170 FmtFlag = FmtByte << 1
171};
172
173extern int print(char*, ...);
174extern char* seprint(char*, char*, char*, ...);
175extern char* vseprint(char*, char*, char*, va_list);
176extern int snprint(char*, int, char*, ...);
177extern int vsnprint(char*, int, char*, va_list);
178extern char* smprint(char*, ...);
179extern char* vsmprint(char*, va_list);
180extern int sprint(char*, char*, ...);
181extern int fprint(int, char*, ...);
182extern int vfprint(int, char*, va_list);
183
184extern int runesprint(Rune*, char*, ...);
185extern int runesnprint(Rune*, int, char*, ...);
186extern int runevsnprint(Rune*, int, char*, va_list);
187extern Rune* runeseprint(Rune*, Rune*, char*, ...);
188extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
189extern Rune* runesmprint(char*, ...);
190extern Rune* runevsmprint(char*, va_list);
191
192extern int fmtfdinit(Fmt*, int, char*, int);
193extern int fmtfdflush(Fmt*);
194extern int fmtstrinit(Fmt*);
195extern char* fmtstrflush(Fmt*);
196extern int runefmtstrinit(Fmt*);
197extern Rune* runefmtstrflush(Fmt*);
198
199extern int fmtinstall(int, int (*)(Fmt*));
200extern int dofmt(Fmt*, char*);
201extern int dorfmt(Fmt*, Rune*);
202extern int fmtprint(Fmt*, char*, ...);
203extern int fmtvprint(Fmt*, char*, va_list);
204extern int fmtrune(Fmt*, int);
205extern int fmtstrcpy(Fmt*, char*);
206extern int fmtrunestrcpy(Fmt*, Rune*);
207/*
208 * error string for %r
209 * supplied on per os basis, not part of fmt library
210 */
211extern int errfmt(Fmt *f);
212
213/*
214 * quoted strings
215 */
216extern char *unquotestrdup(char*);
217extern Rune *unquoterunestrdup(Rune*);
218extern char *quotestrdup(char*);
219extern Rune *quoterunestrdup(Rune*);
220extern int quotestrfmt(Fmt*);
221extern int quoterunestrfmt(Fmt*);
222extern void quotefmtinstall(void);
223extern int (*doquote)(int);
224
225/*
226 * random number
227 */
228extern ulong truerand(void);
229extern ulong ntruerand(ulong);
230
231/*
232 * math
233 */
234extern int isNaN(double);
235extern int isInf(double, int);
236
237/*
238 * Time-of-day
239 */
240
241typedef struct Tm Tm;
242struct Tm {
243 int sec;
244 int min;
245 int hour;
246 int mday;
247 int mon;
248 int year;
249 int wday;
250 int yday;
251 char zone[4];
252 int tzoff;
253};
254extern vlong osnsec(void);
255#define nsec osnsec
256
257/*
258 * one-of-a-kind
259 */
260extern void _assert(char*);
261extern double charstod(int(*)(void*), void*);
262extern char* cleanname(char*);
263//extern uintptr getcallerpc(void*);
264extern int getfields(char*, char**, int, int, char*);
265extern char* getuser(void);
266extern char* getwd(char*, int);
267extern double ipow10(int);
268#define pow10 infpow10
269extern double pow10(int);
270extern vlong strtoll(const char*, char**, int);
271#define qsort infqsort
272extern void qsort(void*, long, long, int (*)(void*, void*));
273extern uvlong strtoull(const char*, char**, int);
274extern void sysfatal(char*, ...);
275extern int dec64(uchar*, int, char*, int);
276extern int enc64(char*, int, uchar*, int);
277extern int dec32(uchar*, int, char*, int);
278extern int enc32(char*, int, uchar*, int);
279extern int dec16(uchar*, int, char*, int);
280extern int enc16(char*, int, uchar*, int);
281extern int encodefmt(Fmt*);
282
283/*
284 * synchronization
285 */
286typedef
287struct Lock {
288 int val;
289 int pid;
290} Lock;
291
292extern int _tas(int*);
293
294extern void lock(Lock*);
295extern void unlock(Lock*);
296extern int canlock(Lock*);
297
298typedef struct QLock QLock;
299struct QLock
300{
301 Lock use; /* to access Qlock structure */
302 Proc *head; /* next process waiting for object */
303 Proc *tail; /* last process waiting for object */
304 int locked; /* flag */
305};
306
307extern void qlock(QLock*);
308extern void qunlock(QLock*);
309extern int canqlock(QLock*);
310extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
311
312typedef
313struct RWLock
314{
315 Lock l; /* Lock modify lock */
316 QLock x; /* Mutual exclusion lock */
317 QLock k; /* Lock for waiting writers */
318 int readers; /* Count of readers in lock */
319} RWLock;
320
321extern int canrlock(RWLock*);
322extern int canwlock(RWLock*);
323extern void rlock(RWLock*);
324extern void runlock(RWLock*);
325extern void wlock(RWLock*);
326extern void wunlock(RWLock*);
327
328/*
329 * network dialing
330 */
331#define NETPATHLEN 40
332
333/*
334 * system calls
335 *
336 */
337#define STATMAX 65535U /* max length of machine-independent stat structure */
338#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
339#define ERRMAX 128 /* max length of error string */
340
341#define MORDER 0x0003 /* mask for bits defining order of mounting */
342#define MREPL 0x0000 /* mount replaces object */
343#define MBEFORE 0x0001 /* mount goes before others in union directory */
344#define MAFTER 0x0002 /* mount goes after others in union directory */
345#define MCREATE 0x0004 /* permit creation in mounted directory */
346#define MCACHE 0x0010 /* cache some data */
347#define MMASK 0x0017 /* all bits on */
348
349#define OREAD 0 /* open for read */
350#define OWRITE 1 /* write */
351#define ORDWR 2 /* read and write */
352#define OEXEC 3 /* execute, == read but check execute permission */
353#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
354#define OCEXEC 32 /* or'ed in, close on exec */
355#define ORCLOSE 64 /* or'ed in, remove on close */
356#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
357
358#define AEXIST 0 /* accessible: exists */
359#define AEXEC 1 /* execute access */
360#define AWRITE 2 /* write access */
361#define AREAD 4 /* read access */
362
363/* bits in Qid.type */
364#define QTDIR 0x80 /* type bit for directories */
365#define QTAPPEND 0x40 /* type bit for append only files */
366#define QTEXCL 0x20 /* type bit for exclusive use files */
367#define QTMOUNT 0x10 /* type bit for mounted channel */
368#define QTAUTH 0x08 /* type bit for authentication file */
369#define QTFILE 0x00 /* plain file */
370
371/* bits in Dir.mode */
372#define DMDIR 0x80000000 /* mode bit for directories */
373#define DMAPPEND 0x40000000 /* mode bit for append only files */
374#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
375#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
376#define DMAUTH 0x08000000 /* mode bit for authentication file */
377#define DMREAD 0x4 /* mode bit for read permission */
378#define DMWRITE 0x2 /* mode bit for write permission */
379#define DMEXEC 0x1 /* mode bit for execute permission */
380
381typedef
382struct Qid
383{
384 uvlong path;
385 ulong vers;
386 uchar type;
387} Qid;
388
389typedef
390struct Dir {
391 /* system-modified data */
392 ushort type; /* server type */
393 uint dev; /* server subtype */
394 /* file data */
395 Qid qid; /* unique id from server */
396 ulong mode; /* permissions */
397 ulong atime; /* last read time */
398 ulong mtime; /* last write time */
399 vlong length; /* file length */
400 char *name; /* last element of path */
401 char *uid; /* owner name */
402 char *gid; /* group name */
403 char *muid; /* last modifier name */
404} Dir;
405
406extern Dir* dirstat(char*);
407extern Dir* dirfstat(int);
408extern int dirwstat(char*, Dir*);
409extern int dirfwstat(int, Dir*);
410extern long dirread(int, Dir**);
411extern void nulldir(Dir*);
412extern long dirreadall(int, Dir**);
413
414typedef
415struct Waitmsg
416{
417 int pid; /* of loved one */
418 ulong time[3]; /* of loved one & descendants */
419 char *msg;
420} Waitmsg;
421
422extern void _exits(char*);
423
424extern void exits(char*);
425extern int create(char*, int, int);
426extern int errstr(char*, uint);
427
428extern void perror(const char*);
429extern long readn(int, void*, long);
430extern int remove(const char*);
431extern void rerrstr(char*, uint);
432extern vlong seek(int, vlong, int);
433extern int segflush(void*, ulong);
434extern void werrstr(char*, ...);
435
436extern char *argv0;
437#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
438 argv[0] && argv[0][0]=='-' && argv[0][1];\
439 argc--, argv++) {\
440 char *_args, *_argt;\
441 Rune _argc;\
442 _args = &argv[0][1];\
443 if(_args[0]=='-' && _args[1]==0){\
444 argc--; argv++; break;\
445 }\
446 _argc = 0;\
447 while(*_args && (_args += chartorune(&_argc, _args)))\
448 switch(_argc)
449#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
450#define ARGF() (_argt=_args, _args="",\
451 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
452#define EARGF(x) (_argt=_args, _args="",\
453 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
454
455#define ARGC() _argc
456
457/*
458 * Extensions for Inferno to basic libc.h
459 */
460
461#define setbinmode()
462
463/* need the inline because the link register is not saved in a known location */
464static __inline uintptr getcallerpc(void* dummy) {
465 ulong lr;
466 __asm__( "mov %0, %%lr;"
467 : "=r" (lr)
468 );
469 return lr;
470}
Linux/power/bin/data2c+0−0

Binary file not shown.

Linux/power/bin/iyacc+0−0

Binary file not shown.

Linux/power/bin/limbo+0−0

Binary file not shown.

Linux/power/bin/mk+0−0

Binary file not shown.

Linux/power/bin/mkext+0−0

Binary file not shown.

Linux/power/include/emu.h+37−0
@@ -0,0 +1,37 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[18*8];
14};
15
16/*
17 * Later versions of Linux seemed to need large stack for gethostbyname()
18 * so we had this at 128k, which is excessive. More recently, we've
19 * reduced it again after testing stack usage by gethostbyname.
20 */
21#define KSTACK (16 * 1024)
22
23#ifndef USE_PTHREADS
24static __inline Proc *getup(void) {
25 Proc *p;
26 __asm__( "mr %0, 1" : "=r" (p));
27 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
28}
29#else
30extern Proc* getup(void);
31#endif
32
33#define up (getup())
34
35typedef sigjmp_buf osjmpbuf;
36#define ossetjmp(buf) sigsetjmp(buf, 1)
37
Linux/power/include/fpuctl.h+83−0
@@ -0,0 +1,83 @@
1/*
2 * Linux PPC
3 * Mimic Plan9 floating point support
4 */
5
6static __inline__ ulong
7getfcr(void)
8{
9 float fpscr;
10
11 __asm__ __volatile__ ("mffs %0" : "=&f" (fpscr):);
12
13 return (ulong)fpscr;
14}
15
16static __inline__ ulong
17getfsr(void)
18{
19 float fpscr;
20
21 __asm__ __volatile__ ("mffs %0" : "=&f" (fpscr):);
22
23 return (ulong) fpscr;
24}
25
26static __inline__ void
27setfsr(ulong fsr)
28{
29 float t = (float) fsr;
30
31 __asm__ __volatile__("mtfsf 0xff, %0" : : "f" (t) );
32}
33
34static __inline__ void
35setfcr(ulong fcr)
36{
37 float t = (float) fcr;
38
39 __asm__ __volatile__("mtfsf 0xff, %0" : : "f" (t) );
40}
41
42/* FPSCR */
43#define FPSFX (1<<31) /* exception summary (sticky) */
44#define FPSEX (1<<30) /* enabled exception summary */
45#define FPSVX (1<<29) /* invalid operation exception summary */
46#define FPSOX (1<<28) /* overflow exception OX (sticky) */
47#define FPSUX (1<<27) /* underflow exception UX (sticky) */
48#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
49#define FPSXX (1<<25) /* inexact exception XX (sticky) */
50#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
51#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
52#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
53#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
54#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
55#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
56#define FPSFR (1<<18) /* fraction rounded */
57#define FPSFI (1<<17) /* fraction inexact */
58#define FPSFPRF (1<<16) /* floating point result class */
59#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
60#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
61
62/* FCR */
63#define FPVE (1<<7) /* invalid operation exception enable */
64#define FPOVFL (1<<6) /* enable overflow exceptions */
65#define FPUNFL (1<<5) /* enable underflow */
66#define FPZDIV (1<<4) /* enable zero divide */
67#define FPINEX (1<<3) /* enable inexact exceptions */
68#define FPRMASK (3<<0) /* rounding mode */
69#define FPRNR (0<<0)
70#define FPRZ (1<<0)
71#define FPRPINF (2<<0)
72#define FPRNINF (3<<0)
73#define FPPEXT 0
74#define FPPSGL 0
75#define FPPDBL 0
76#define FPPMASK 0
77#define FPINVAL FPVE
78/* FSR */
79#define FPAOVFL FPSOX
80#define FPAINEX FPSXX
81#define FPAUNFL FPSUX
82#define FPAZDIV FPSZX
83#define FPAINVAL FPSVX
Linux/power/include/lib9.h+463−0
@@ -0,0 +1,463 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#define USE_PTHREADS
3#ifndef _BSD_SOURCE
4#define _BSD_SOURCE
5#endif
6#define _XOPEN_SOURCE 500
7#define _LARGEFILE_SOURCE 1
8#define _LARGEFILE64_SOURCE 1
9#define _FILE_OFFSET_BITS 64
10#ifdef USE_PTHREADS
11#define _REENTRANT 1
12#endif
13#include <features.h>
14#include <sys/types.h>
15#include <stdlib.h>
16#include <stdarg.h>
17#define sync __os_sync
18#include <unistd.h>
19#undef sync
20#include <errno.h>
21#define __NO_STRING_INLINES
22#include <string.h>
23#include "math.h"
24#include <fcntl.h>
25#include <setjmp.h>
26#include <float.h>
27#include <endian.h>
28
29#define getwd infgetwd
30
31#ifndef EMU
32typedef struct Proc Proc;
33#endif
34
35/*
36 * math module dtoa
37 * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
38 */
39#undef __LITTLE_ENDIAN
40
41#define nil ((void*)0)
42
43typedef unsigned char uchar;
44typedef signed char schar;
45typedef unsigned short Rune;
46typedef long long int vlong;
47typedef unsigned long long int uvlong;
48typedef unsigned int u32int;
49typedef uvlong u64int;
50
51typedef unsigned int mpdigit; /* for /sys/include/mp.h */
52typedef unsigned short u16int;
53typedef unsigned char u8int;
54typedef unsigned long uintptr;
55
56#define USED(x) if(x){}else{}
57#define SET(x)
58
59#undef nelem
60#define nelem(x) (sizeof(x)/sizeof((x)[0]))
61#undef offsetof
62#define offsetof(s, m) (ulong)(&(((s*)0)->m))
63#undef assert
64#define assert(x) if(x){}else _assert("x")
65
66/*
67 * most mem and string routines are declared by ANSI/POSIX files above
68 */
69
70extern char* strecpy(char*, char*, char*);
71extern char* strdup(const char*);
72extern int cistrncmp(char*, char*, int);
73extern int cistrcmp(char*, char*);
74extern char* cistrstr(char*, char*);
75extern int tokenize(char*, char**, int);
76
77enum
78{
79 UTFmax = 3, /* maximum bytes per rune */
80 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
81 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
82 Runeerror = 0x80 /* decoding error in UTF */
83};
84
85/*
86 * rune routines
87 */
88extern int runetochar(char*, Rune*);
89extern int chartorune(Rune*, char*);
90extern int runelen(long);
91extern int runenlen(Rune*, int);
92extern int fullrune(char*, int);
93extern int utflen(char*);
94extern int utfnlen(char*, long);
95extern char* utfrune(char*, long);
96extern char* utfrrune(char*, long);
97extern char* utfutf(char*, char*);
98extern char* utfecpy(char*, char*, char*);
99
100extern Rune* runestrcat(Rune*, Rune*);
101extern Rune* runestrchr(Rune*, Rune);
102extern int runestrcmp(Rune*, Rune*);
103extern Rune* runestrcpy(Rune*, Rune*);
104extern Rune* runestrncpy(Rune*, Rune*, long);
105extern Rune* runestrecpy(Rune*, Rune*, Rune*);
106extern Rune* runestrdup(Rune*);
107extern Rune* runestrncat(Rune*, Rune*, long);
108extern int runestrncmp(Rune*, Rune*, long);
109extern Rune* runestrrchr(Rune*, Rune);
110extern long runestrlen(Rune*);
111extern Rune* runestrstr(Rune*, Rune*);
112
113extern Rune tolowerrune(Rune);
114extern Rune totitlerune(Rune);
115extern Rune toupperrune(Rune);
116extern int isalpharune(Rune);
117extern int islowerrune(Rune);
118extern int isspacerune(Rune);
119extern int istitlerune(Rune);
120extern int isupperrune(Rune);
121
122/*
123 * malloc
124 */
125extern void* malloc(size_t);
126extern void* mallocz(ulong, int);
127extern void free(void*);
128extern ulong msize(void*);
129extern void* calloc(size_t, size_t);
130extern void* realloc(void*, size_t);
131extern void setmalloctag(void*, ulong);
132extern void setrealloctag(void*, ulong);
133extern ulong getmalloctag(void*);
134extern ulong getrealloctag(void*);
135extern void* malloctopoolblock(void*);
136
137/*
138 * print routines
139 */
140typedef struct Fmt Fmt;
141struct Fmt{
142 uchar runes; /* output buffer is runes or chars? */
143 void *start; /* of buffer */
144 void *to; /* current place in the buffer */
145 void *stop; /* end of the buffer; overwritten if flush fails */
146 int (*flush)(Fmt *); /* called when to == stop */
147 void *farg; /* to make flush a closure */
148 int nfmt; /* num chars formatted so far */
149 va_list args; /* args passed to dofmt */
150 int r; /* % format Rune */
151 int width;
152 int prec;
153 ulong flags;
154};
155
156enum{
157 FmtWidth = 1,
158 FmtLeft = FmtWidth << 1,
159 FmtPrec = FmtLeft << 1,
160 FmtSharp = FmtPrec << 1,
161 FmtSpace = FmtSharp << 1,
162 FmtSign = FmtSpace << 1,
163 FmtZero = FmtSign << 1,
164 FmtUnsigned = FmtZero << 1,
165 FmtShort = FmtUnsigned << 1,
166 FmtLong = FmtShort << 1,
167 FmtVLong = FmtLong << 1,
168 FmtComma = FmtVLong << 1,
169 FmtByte = FmtComma << 1,
170
171 FmtFlag = FmtByte << 1
172};
173
174extern int print(char*, ...);
175extern char* seprint(char*, char*, char*, ...);
176extern char* vseprint(char*, char*, char*, va_list);
177extern int snprint(char*, int, char*, ...);
178extern int vsnprint(char*, int, char*, va_list);
179extern char* smprint(char*, ...);
180extern char* vsmprint(char*, va_list);
181extern int sprint(char*, char*, ...);
182extern int fprint(int, char*, ...);
183extern int vfprint(int, char*, va_list);
184
185extern int runesprint(Rune*, char*, ...);
186extern int runesnprint(Rune*, int, char*, ...);
187extern int runevsnprint(Rune*, int, char*, va_list);
188extern Rune* runeseprint(Rune*, Rune*, char*, ...);
189extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
190extern Rune* runesmprint(char*, ...);
191extern Rune* runevsmprint(char*, va_list);
192
193extern int fmtfdinit(Fmt*, int, char*, int);
194extern int fmtfdflush(Fmt*);
195extern int fmtstrinit(Fmt*);
196extern char* fmtstrflush(Fmt*);
197extern int runefmtstrinit(Fmt*);
198extern Rune* runefmtstrflush(Fmt*);
199
200extern int fmtinstall(int, int (*)(Fmt*));
201extern int dofmt(Fmt*, char*);
202extern int dorfmt(Fmt*, Rune*);
203extern int fmtprint(Fmt*, char*, ...);
204extern int fmtvprint(Fmt*, char*, va_list);
205extern int fmtrune(Fmt*, int);
206extern int fmtstrcpy(Fmt*, char*);
207extern int fmtrunestrcpy(Fmt*, Rune*);
208/*
209 * error string for %r
210 * supplied on per os basis, not part of fmt library
211 */
212extern int errfmt(Fmt *f);
213
214/*
215 * quoted strings
216 */
217extern char *unquotestrdup(char*);
218extern Rune *unquoterunestrdup(Rune*);
219extern char *quotestrdup(char*);
220extern Rune *quoterunestrdup(Rune*);
221extern int quotestrfmt(Fmt*);
222extern int quoterunestrfmt(Fmt*);
223extern void quotefmtinstall(void);
224extern int (*doquote)(int);
225
226/*
227 * random number
228 */
229extern ulong truerand(void);
230extern ulong ntruerand(ulong);
231
232/*
233 * math
234 */
235extern int isNaN(double);
236extern int isInf(double, int);
237
238/*
239 * Time-of-day
240 */
241
242typedef struct Tm Tm;
243struct Tm {
244 int sec;
245 int min;
246 int hour;
247 int mday;
248 int mon;
249 int year;
250 int wday;
251 int yday;
252 char zone[4];
253 int tzoff;
254};
255extern vlong osnsec(void);
256#define nsec osnsec
257
258/*
259 * one-of-a-kind
260 */
261extern void _assert(char*);
262extern double charstod(int(*)(void*), void*);
263extern char* cleanname(char*);
264extern uintptr getcallerpc(void*);
265extern int getfields(char*, char**, int, int, char*);
266extern char* getuser(void);
267extern char* getwd(char*, int);
268extern double ipow10(int);
269#define pow10 infpow10
270extern double pow10(int);
271extern vlong strtoll(const char*, char**, int);
272#define qsort infqsort
273extern void qsort(void*, long, long, int (*)(void*, void*));
274extern uvlong strtoull(const char*, char**, int);
275extern void sysfatal(char*, ...);
276extern int dec64(uchar*, int, char*, int);
277extern int enc64(char*, int, uchar*, int);
278extern int dec32(uchar*, int, char*, int);
279extern int enc32(char*, int, uchar*, int);
280extern int dec16(uchar*, int, char*, int);
281extern int enc16(char*, int, uchar*, int);
282extern int encodefmt(Fmt*);
283
284/*
285 * synchronization
286 */
287typedef
288struct Lock {
289 int val;
290 int pid;
291} Lock;
292
293extern int _tas(int*);
294
295extern void lock(Lock*);
296extern void unlock(Lock*);
297extern int canlock(Lock*);
298
299typedef struct QLock QLock;
300struct QLock
301{
302 Lock use; /* to access Qlock structure */
303 Proc *head; /* next process waiting for object */
304 Proc *tail; /* last process waiting for object */
305 int locked; /* flag */
306};
307
308extern void qlock(QLock*);
309extern void qunlock(QLock*);
310extern int canqlock(QLock*);
311extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
312
313typedef
314struct RWLock
315{
316 Lock l; /* Lock modify lock */
317 QLock x; /* Mutual exclusion lock */
318 QLock k; /* Lock for waiting writers */
319 int readers; /* Count of readers in lock */
320} RWLock;
321
322extern int canrlock(RWLock*);
323extern int canwlock(RWLock*);
324extern void rlock(RWLock*);
325extern void runlock(RWLock*);
326extern void wlock(RWLock*);
327extern void wunlock(RWLock*);
328
329/*
330 * network dialing
331 */
332#define NETPATHLEN 40
333
334/*
335 * system calls
336 *
337 */
338#define STATMAX 65535U /* max length of machine-independent stat structure */
339#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
340#define ERRMAX 128 /* max length of error string */
341
342#define MORDER 0x0003 /* mask for bits defining order of mounting */
343#define MREPL 0x0000 /* mount replaces object */
344#define MBEFORE 0x0001 /* mount goes before others in union directory */
345#define MAFTER 0x0002 /* mount goes after others in union directory */
346#define MCREATE 0x0004 /* permit creation in mounted directory */
347#define MCACHE 0x0010 /* cache some data */
348#define MMASK 0x0017 /* all bits on */
349
350#define OREAD 0 /* open for read */
351#define OWRITE 1 /* write */
352#define ORDWR 2 /* read and write */
353#define OEXEC 3 /* execute, == read but check execute permission */
354#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
355#define OCEXEC 32 /* or'ed in, close on exec */
356#define ORCLOSE 64 /* or'ed in, remove on close */
357#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
358
359#define AEXIST 0 /* accessible: exists */
360#define AEXEC 1 /* execute access */
361#define AWRITE 2 /* write access */
362#define AREAD 4 /* read access */
363
364/* bits in Qid.type */
365#define QTDIR 0x80 /* type bit for directories */
366#define QTAPPEND 0x40 /* type bit for append only files */
367#define QTEXCL 0x20 /* type bit for exclusive use files */
368#define QTMOUNT 0x10 /* type bit for mounted channel */
369#define QTAUTH 0x08 /* type bit for authentication file */
370#define QTFILE 0x00 /* plain file */
371
372/* bits in Dir.mode */
373#define DMDIR 0x80000000 /* mode bit for directories */
374#define DMAPPEND 0x40000000 /* mode bit for append only files */
375#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
376#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
377#define DMAUTH 0x08000000 /* mode bit for authentication file */
378#define DMREAD 0x4 /* mode bit for read permission */
379#define DMWRITE 0x2 /* mode bit for write permission */
380#define DMEXEC 0x1 /* mode bit for execute permission */
381
382typedef
383struct Qid
384{
385 uvlong path;
386 ulong vers;
387 uchar type;
388} Qid;
389
390typedef
391struct Dir {
392 /* system-modified data */
393 ushort type; /* server type */
394 uint dev; /* server subtype */
395 /* file data */
396 Qid qid; /* unique id from server */
397 ulong mode; /* permissions */
398 ulong atime; /* last read time */
399 ulong mtime; /* last write time */
400 vlong length; /* file length */
401 char *name; /* last element of path */
402 char *uid; /* owner name */
403 char *gid; /* group name */
404 char *muid; /* last modifier name */
405} Dir;
406
407extern Dir* dirstat(char*);
408extern Dir* dirfstat(int);
409extern int dirwstat(char*, Dir*);
410extern int dirfwstat(int, Dir*);
411extern long dirread(int, Dir**);
412extern void nulldir(Dir*);
413extern long dirreadall(int, Dir**);
414
415typedef
416struct Waitmsg
417{
418 int pid; /* of loved one */
419 ulong time[3]; /* of loved one & descendants */
420 char *msg;
421} Waitmsg;
422
423extern void _exits(char*);
424
425extern void exits(char*);
426extern int create(char*, int, int);
427extern int errstr(char*, uint);
428
429extern void perror(const char*);
430extern long readn(int, void*, long);
431extern int remove(const char*);
432extern void rerrstr(char*, uint);
433extern vlong seek(int, vlong, int);
434extern int segflush(void*, ulong);
435extern void werrstr(char*, ...);
436
437extern char *argv0;
438#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
439 argv[0] && argv[0][0]=='-' && argv[0][1];\
440 argc--, argv++) {\
441 char *_args, *_argt;\
442 Rune _argc;\
443 _args = &argv[0][1];\
444 if(_args[0]=='-' && _args[1]==0){\
445 argc--; argv++; break;\
446 }\
447 _argc = 0;\
448 while(*_args && (_args += chartorune(&_argc, _args)))\
449 switch(_argc)
450#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
451#define ARGF() (_argt=_args, _args="",\
452 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
453#define EARGF(x) (_argt=_args, _args="",\
454 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
455
456#define ARGC() _argc
457
458/*
459 * Extensions for Inferno to basic libc.h
460 */
461
462#define setbinmode()
463
Linux/spim/include/emu.h+39−0
@@ -0,0 +1,39 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16/*
17 * Later versions of Linux seemed to need large stack for gethostbyname()
18 * so we had this at 128k, which is excessive. More recently, we've
19 * reduced it again after testing stack usage by gethostbyname.
20 */
21#define KSTACK (16 * 1024)
22
23#ifndef USE_PTHREADS
24static __inline Proc *getup(void) {
25 Proc *p;
26 __asm__( "move %0, $29\n\t"
27 : "=r" (p)
28 );
29 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
30}
31#else
32extern Proc* getup(void);
33#endif
34
35#define up (getup())
36
37typedef sigjmp_buf osjmpbuf;
38#define ossetjmp(buf) sigsetjmp(buf, 1)
39
Linux/spim/include/fpuctl.h+65−0
@@ -0,0 +1,65 @@
1/* FCR */
2#define FCRBITS 0x00000F83
3#define FPINEX (1<<7)
4#define FPUNFL (1<<8)
5#define FPOVFL (1<<9)
6#define FPZDIV (1<<10)
7#define FPINVAL (1<<11)
8#define FPRNR (0<<0)
9#define FPRZ (1<<0)
10#define FPRPINF (2<<0)
11#define FPRNINF (3<<0)
12#define FPRMASK (3<<0)
13#define FPPEXT 0
14#define FPPSGL 0
15#define FPPDBL 0
16#define FPPMASK 0
17/* FSR */
18#define FSRBITS 0x0003F07C
19#define FPAINEX (1<<2)
20#define FPAOVFL (1<<4)
21#define FPAUNFL (1<<3)
22#define FPAZDIV (1<<5)
23#define FPAINVAL (1<<6)
24
25/*
26 * Linux mips fpu support
27 * Mimic Plan9 floating point support
28 */
29
30static void
31setfcr(ulong fcr)
32{
33 __asm__("ctc1 %0,$31\n"
34 : :"r" (fcr)
35 );
36}
37
38static ulong
39getfcr(void)
40{
41 ulong fcr = 0;
42 __asm__("cfc1 %0,$31\n"
43 : "=r" (fcr)
44 );
45 fcr &= FCRBITS;
46 return fcr;
47}
48
49static ulong
50getfsr(void)
51{
52 ulong fsr = 0;
53 __asm__("cfc1 %0,$31\n"
54 : "=r" (fsr)
55 );
56 fsr &= FSRBITS;
57 return fsr;
58}
59
60static void
61setfsr(ulong fsr)
62{
63 fsr |= getfcr();
64 setfcr(getfcr()|fsr);
65}
Linux/spim/include/lib9.h+464−0
@@ -0,0 +1,464 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#define USE_PTHREADS
3#ifndef _BSD_SOURCE
4#define _BSD_SOURCE
5#endif
6#define _LARGEFILE_SOURCE 1
7#define _LARGEFILE64_SOURCE 1
8#define _FILE_OFFSET_BITS 64
9#include <features.h>
10#include <sys/types.h>
11#include <stdlib.h>
12#include <stdarg.h>
13#define sync __os_sync
14#include <unistd.h>
15#undef sync
16#include <errno.h>
17#define __NO_STRING_INLINES
18#include <string.h>
19#include "math.h"
20#include <fcntl.h>
21#include <setjmp.h>
22#include <float.h>
23#include <endian.h>
24
25#define getwd infgetwd
26
27#ifndef EMU
28typedef struct Proc Proc;
29#endif
30
31/*
32 * math module dtoa
33 * #define __LITTLE_ENDIAN according to target under linux
34 */
35
36#ifdef __MIPSEB__
37#undef __LITTLE_ENDIAN
38#else
39#define __LITTLE_ENDIAN 1234
40#endif
41
42#define nil ((void*)0)
43
44typedef unsigned char uchar;
45typedef signed char schar;
46typedef unsigned short Rune;
47typedef long long int vlong;
48typedef unsigned long long int uvlong;
49typedef unsigned int u32int;
50typedef uvlong u64int;
51
52typedef unsigned int mpdigit; /* for /sys/include/mp.h */
53typedef unsigned short u16int;
54typedef unsigned char u8int;
55typedef unsigned long uintptr;
56
57#define USED(x) if(x){}else{}
58#define SET(x)
59
60#undef nelem
61#define nelem(x) (sizeof(x)/sizeof((x)[0]))
62#undef offsetof
63#define offsetof(s, m) (ulong)(&(((s*)0)->m))
64#undef assert
65#define assert(x) if(x){}else _assert("x")
66
67/*
68 * most mem and string routines are declared by ANSI/POSIX files above
69 */
70
71extern char* strecpy(char*, char*, char*);
72extern char* strdup(const char*);
73extern int cistrncmp(char*, char*, int);
74extern int cistrcmp(char*, char*);
75extern char* cistrstr(char*, char*);
76extern int tokenize(char*, char**, int);
77
78enum
79{
80 UTFmax = 3, /* maximum bytes per rune */
81 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
82 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
83 Runeerror = 0x80 /* decoding error in UTF */
84};
85
86/*
87 * rune routines
88 */
89extern int runetochar(char*, Rune*);
90extern int chartorune(Rune*, char*);
91extern int runelen(long);
92extern int runenlen(Rune*, int);
93extern int fullrune(char*, int);
94extern int utflen(char*);
95extern int utfnlen(char*, long);
96extern char* utfrune(char*, long);
97extern char* utfrrune(char*, long);
98extern char* utfutf(char*, char*);
99extern char* utfecpy(char*, char*, char*);
100
101extern Rune* runestrcat(Rune*, Rune*);
102extern Rune* runestrchr(Rune*, Rune);
103extern int runestrcmp(Rune*, Rune*);
104extern Rune* runestrcpy(Rune*, Rune*);
105extern Rune* runestrncpy(Rune*, Rune*, long);
106extern Rune* runestrecpy(Rune*, Rune*, Rune*);
107extern Rune* runestrdup(Rune*);
108extern Rune* runestrncat(Rune*, Rune*, long);
109extern int runestrncmp(Rune*, Rune*, long);
110extern Rune* runestrrchr(Rune*, Rune);
111extern long runestrlen(Rune*);
112extern Rune* runestrstr(Rune*, Rune*);
113
114extern Rune tolowerrune(Rune);
115extern Rune totitlerune(Rune);
116extern Rune toupperrune(Rune);
117extern int isalpharune(Rune);
118extern int islowerrune(Rune);
119extern int isspacerune(Rune);
120extern int istitlerune(Rune);
121extern int isupperrune(Rune);
122
123/*
124 * malloc
125 */
126extern void* malloc(size_t);
127extern void* mallocz(ulong, int);
128extern void free(void*);
129extern ulong msize(void*);
130extern void* calloc(size_t, size_t);
131extern void* realloc(void*, size_t);
132extern void setmalloctag(void*, ulong);
133extern void setrealloctag(void*, ulong);
134extern ulong getmalloctag(void*);
135extern ulong getrealloctag(void*);
136extern void* malloctopoolblock(void*);
137
138/*
139 * print routines
140 */
141typedef struct Fmt Fmt;
142struct Fmt{
143 uchar runes; /* output buffer is runes or chars? */
144 void *start; /* of buffer */
145 void *to; /* current place in the buffer */
146 void *stop; /* end of the buffer; overwritten if flush fails */
147 int (*flush)(Fmt *); /* called when to == stop */
148 void *farg; /* to make flush a closure */
149 int nfmt; /* num chars formatted so far */
150 va_list args; /* args passed to dofmt */
151 int r; /* % format Rune */
152 int width;
153 int prec;
154 ulong flags;
155};
156
157enum{
158 FmtWidth = 1,
159 FmtLeft = FmtWidth << 1,
160 FmtPrec = FmtLeft << 1,
161 FmtSharp = FmtPrec << 1,
162 FmtSpace = FmtSharp << 1,
163 FmtSign = FmtSpace << 1,
164 FmtZero = FmtSign << 1,
165 FmtUnsigned = FmtZero << 1,
166 FmtShort = FmtUnsigned << 1,
167 FmtLong = FmtShort << 1,
168 FmtVLong = FmtLong << 1,
169 FmtComma = FmtVLong << 1,
170 FmtByte = FmtComma << 1,
171
172 FmtFlag = FmtByte << 1
173};
174
175extern int print(char*, ...);
176extern char* seprint(char*, char*, char*, ...);
177extern char* vseprint(char*, char*, char*, va_list);
178extern int snprint(char*, int, char*, ...);
179extern int vsnprint(char*, int, char*, va_list);
180extern char* smprint(char*, ...);
181extern char* vsmprint(char*, va_list);
182extern int sprint(char*, char*, ...);
183extern int fprint(int, char*, ...);
184extern int vfprint(int, char*, va_list);
185
186extern int runesprint(Rune*, char*, ...);
187extern int runesnprint(Rune*, int, char*, ...);
188extern int runevsnprint(Rune*, int, char*, va_list);
189extern Rune* runeseprint(Rune*, Rune*, char*, ...);
190extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
191extern Rune* runesmprint(char*, ...);
192extern Rune* runevsmprint(char*, va_list);
193
194extern int fmtfdinit(Fmt*, int, char*, int);
195extern int fmtfdflush(Fmt*);
196extern int fmtstrinit(Fmt*);
197extern char* fmtstrflush(Fmt*);
198extern int runefmtstrinit(Fmt*);
199extern Rune* runefmtstrflush(Fmt*);
200
201extern int fmtinstall(int, int (*)(Fmt*));
202extern int dofmt(Fmt*, char*);
203extern int dorfmt(Fmt*, Rune*);
204extern int fmtprint(Fmt*, char*, ...);
205extern int fmtvprint(Fmt*, char*, va_list);
206extern int fmtrune(Fmt*, int);
207extern int fmtstrcpy(Fmt*, char*);
208extern int fmtrunestrcpy(Fmt*, Rune*);
209/*
210 * error string for %r
211 * supplied on per os basis, not part of fmt library
212 */
213extern int errfmt(Fmt *f);
214
215/*
216 * quoted strings
217 */
218extern char *unquotestrdup(char*);
219extern Rune *unquoterunestrdup(Rune*);
220extern char *quotestrdup(char*);
221extern Rune *quoterunestrdup(Rune*);
222extern int quotestrfmt(Fmt*);
223extern int quoterunestrfmt(Fmt*);
224extern void quotefmtinstall(void);
225extern int (*doquote)(int);
226
227/*
228 * random number
229 */
230extern ulong truerand(void);
231extern ulong ntruerand(ulong);
232
233/*
234 * math
235 */
236extern int isNaN(double);
237extern int isInf(double, int);
238
239/*
240 * Time-of-day
241 */
242
243typedef struct Tm Tm;
244struct Tm {
245 int sec;
246 int min;
247 int hour;
248 int mday;
249 int mon;
250 int year;
251 int wday;
252 int yday;
253 char zone[4];
254 int tzoff;
255};
256extern vlong osnsec(void);
257#define nsec osnsec
258
259/*
260 * one-of-a-kind
261 */
262extern void _assert(char*);
263extern double charstod(int(*)(void*), void*);
264extern char* cleanname(char*);
265extern uintptr getcallerpc(void*);
266extern int getfields(char*, char**, int, int, char*);
267extern char* getuser(void);
268extern char* getwd(char*, int);
269extern double ipow10(int);
270#define pow10 infpow10
271extern double pow10(int);
272extern vlong strtoll(const char*, char**, int);
273#define qsort infqsort
274extern void qsort(void*, long, long, int (*)(void*, void*));
275extern uvlong strtoull(const char*, char**, int);
276extern void sysfatal(char*, ...);
277extern int dec64(uchar*, int, char*, int);
278extern int enc64(char*, int, uchar*, int);
279extern int dec32(uchar*, int, char*, int);
280extern int enc32(char*, int, uchar*, int);
281extern int dec16(uchar*, int, char*, int);
282extern int enc16(char*, int, uchar*, int);
283extern int encodefmt(Fmt*);
284
285/*
286 * synchronization
287 */
288typedef
289struct Lock {
290 ulong val;
291 int pid;
292} Lock;
293
294extern ulong _tas(ulong*);
295
296extern void lock(Lock*);
297extern void unlock(Lock*);
298extern int canlock(Lock*);
299
300typedef struct QLock QLock;
301struct QLock
302{
303 Lock use; /* to access Qlock structure */
304 Proc *head; /* next process waiting for object */
305 Proc *tail; /* last process waiting for object */
306 int locked; /* flag */
307};
308
309extern void qlock(QLock*);
310extern void qunlock(QLock*);
311extern int canqlock(QLock*);
312extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
313
314typedef
315struct RWLock
316{
317 Lock l; /* Lock modify lock */
318 QLock x; /* Mutual exclusion lock */
319 QLock k; /* Lock for waiting writers */
320 int readers; /* Count of readers in lock */
321} RWLock;
322
323extern int canrlock(RWLock*);
324extern int canwlock(RWLock*);
325extern void rlock(RWLock*);
326extern void runlock(RWLock*);
327extern void wlock(RWLock*);
328extern void wunlock(RWLock*);
329
330/*
331 * network dialing
332 */
333#define NETPATHLEN 40
334
335/*
336 * system calls
337 *
338 */
339#define STATMAX 65535U /* max length of machine-independent stat structure */
340#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
341#define ERRMAX 128 /* max length of error string */
342
343#define MORDER 0x0003 /* mask for bits defining order of mounting */
344#define MREPL 0x0000 /* mount replaces object */
345#define MBEFORE 0x0001 /* mount goes before others in union directory */
346#define MAFTER 0x0002 /* mount goes after others in union directory */
347#define MCREATE 0x0004 /* permit creation in mounted directory */
348#define MCACHE 0x0010 /* cache some data */
349#define MMASK 0x0017 /* all bits on */
350
351#define OREAD 0 /* open for read */
352#define OWRITE 1 /* write */
353#define ORDWR 2 /* read and write */
354#define OEXEC 3 /* execute, == read but check execute permission */
355#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
356#define OCEXEC 32 /* or'ed in, close on exec */
357#define ORCLOSE 64 /* or'ed in, remove on close */
358#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
359
360#define AEXIST 0 /* accessible: exists */
361#define AEXEC 1 /* execute access */
362#define AWRITE 2 /* write access */
363#define AREAD 4 /* read access */
364
365/* bits in Qid.type */
366#define QTDIR 0x80 /* type bit for directories */
367#define QTAPPEND 0x40 /* type bit for append only files */
368#define QTEXCL 0x20 /* type bit for exclusive use files */
369#define QTMOUNT 0x10 /* type bit for mounted channel */
370#define QTAUTH 0x08 /* type bit for authentication file */
371#define QTFILE 0x00 /* plain file */
372
373/* bits in Dir.mode */
374#define DMDIR 0x80000000 /* mode bit for directories */
375#define DMAPPEND 0x40000000 /* mode bit for append only files */
376#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
377#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
378#define DMAUTH 0x08000000 /* mode bit for authentication file */
379#define DMREAD 0x4 /* mode bit for read permission */
380#define DMWRITE 0x2 /* mode bit for write permission */
381#define DMEXEC 0x1 /* mode bit for execute permission */
382
383typedef
384struct Qid
385{
386 uvlong path;
387 ulong vers;
388 uchar type;
389} Qid;
390
391typedef
392struct Dir {
393 /* system-modified data */
394 ushort type; /* server type */
395 uint dev; /* server subtype */
396 /* file data */
397 Qid qid; /* unique id from server */
398 ulong mode; /* permissions */
399 ulong atime; /* last read time */
400 ulong mtime; /* last write time */
401 vlong length; /* file length */
402 char *name; /* last element of path */
403 char *uid; /* owner name */
404 char *gid; /* group name */
405 char *muid; /* last modifier name */
406} Dir;
407
408extern Dir* dirstat(char*);
409extern Dir* dirfstat(int);
410extern int dirwstat(char*, Dir*);
411extern int dirfwstat(int, Dir*);
412extern long dirread(int, Dir**);
413extern void nulldir(Dir*);
414extern long dirreadall(int, Dir**);
415
416typedef
417struct Waitmsg
418{
419 int pid; /* of loved one */
420 ulong time[3]; /* of loved one & descendants */
421 char *msg;
422} Waitmsg;
423
424extern void _exits(char*);
425
426extern void exits(char*);
427extern int create(char*, int, int);
428extern int errstr(char*, uint);
429
430extern void perror(const char*);
431extern long readn(int, void*, long);
432extern int remove(const char*);
433extern void rerrstr(char*, uint);
434extern vlong seek(int, vlong, int);
435extern int segflush(void*, ulong);
436extern void werrstr(char*, ...);
437
438extern char *argv0;
439#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
440 argv[0] && argv[0][0]=='-' && argv[0][1];\
441 argc--, argv++) {\
442 char *_args, *_argt;\
443 Rune _argc;\
444 _args = &argv[0][1];\
445 if(_args[0]=='-' && _args[1]==0){\
446 argc--; argv++; break;\
447 }\
448 _argc = 0;\
449 while(*_args && (_args += chartorune(&_argc, _args)))\
450 switch(_argc)
451#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
452#define ARGF() (_argt=_args, _args="",\
453 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
454#define EARGF(x) (_argt=_args, _args="",\
455 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
456
457#define ARGC() _argc
458
459/*
460 * Extensions for Inferno to basic libc.h
461 */
462
463#define setbinmode()
464
MacOSX/386/bin/data2c+0−0

Binary file not shown.

MacOSX/386/bin/iyacc+0−0

Binary file not shown.

MacOSX/386/bin/mk+0−0

Binary file not shown.

MacOSX/386/bin/mkext+0−0

Binary file not shown.

MacOSX/386/include/emu.h+34−0
@@ -0,0 +1,34 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc *getup(void);
8#define up (getup())
9
10/*
11 * This structure must agree with FPsave and FPrestore asm routines
12 */
13
14// something is at odds between i386/fpu.h and some of the thread headers
15#define fp_control inffp_control
16#define fp_control_t inffp_control_t
17#define fp_status inffp_status
18#define fp_status_t inffp_status_t
19
20#include <architecture/i386/fpu.h>
21
22typedef struct FPU FPU;
23struct FPU
24{
25 fp_state_t env;
26};
27
28#undef fp_control
29#undef fp_control_t
30#undef fp_status
31#undef fp_status_t
32
33typedef sigjmp_buf osjmpbuf;
34#define ossetjmp(buf) sigsetjmp(buf, 1)
MacOSX/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * Linux 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
MacOSX/386/include/lib9.h+487−0
@@ -0,0 +1,487 @@
1/*
2 * Based on FreeBSD lib9.h
3 * Copyright © 1998, 1999 Lucent Technologies Inc. All rights reserved.
4 * Revisions Copyright © 1999, 2002 Vita Nuova Limited. All rights reserved.
5 * Revisions Copyright © 2002, 2003 Corpus Callosum Corporation. All rights reserved.
6 */
7
8/* define _BSD_SOURCE to use ISO C, POSIX, and 4.4BSD things. */
9#ifndef _BSD_SOURCE
10#define _BSD_SOURCE
11#endif
12#define _LARGEFILE64_SOURCE 1
13#define _FILE_OFFSET_BITS 64
14
15#include <sys/types.h>
16#include <sys/stat.h>
17#include <stdlib.h>
18#include <stdarg.h>
19#include <unistd.h>
20#include <errno.h>
21#include <string.h>
22// #include "math.h"
23#include <fcntl.h>
24#include <setjmp.h>
25#include <float.h>
26#include <time.h>
27
28#define nil ((void*)0)
29
30// typedef unsigned short ushort;
31typedef unsigned char uchar;
32typedef unsigned long ulong;
33// typedef unsigned int uint;
34typedef signed char schar;
35typedef long long vlong;
36typedef unsigned long long uvlong;
37typedef ushort Rune;
38typedef unsigned int u32int;
39typedef uvlong u64int;
40
41typedef unsigned int mpdigit; /* for /sys/include/mp.h */
42typedef unsigned short u16int;
43typedef unsigned char u8int;
44typedef unsigned long uintptr;
45
46typedef signed char int8;
47typedef unsigned char uint8;
48typedef short int16;
49typedef unsigned short uint16;
50typedef int int32;
51typedef unsigned int uint32;
52typedef long long int64;
53typedef unsigned long long uint64;
54
55/* handle conflicts with host os libs */
56#define getwd infgetwd
57#define scalb infscalb
58#define div infdiv
59#define panic infpanic
60#define rint infrint
61#define rcmd infrcmd
62#define pow10 infpow10
63
64#ifndef EMU
65typedef struct Proc Proc;
66#endif
67
68/*
69 * math module dtoa
70 */
71#include <machine/endian.h>
72#define __LITTLE_ENDIAN
73
74#define USED(x) if(x){}else{}
75#define SET(x)
76
77#define nelem(x) (sizeof(x)/sizeof((x)[0]))
78#undef offsetof
79#undef assert
80#define offsetof(s, m) (ulong)(&(((s*)0)->m))
81#define assert(x) if(x){}else _assert("x")
82
83/*
84 * mem and string routines are declared by ANSI/POSIX files above
85 */
86
87extern char* strecpy(char*, char*, char*);
88extern char* strdup(const char*);
89extern int cistrncmp(char*, char*, int);
90extern int cistrcmp(char*, char*);
91extern char* cistrstr(char*, char*);
92extern int tokenize(char*, char**, int);
93extern vlong strtoll(const char*, char**, int);
94#define qsort infqsort
95extern void qsort(void*, long, long, int (*)(void*, void*));
96
97enum
98{
99 UTFmax = 3, /* maximum bytes per rune */
100 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
101 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
102 Runeerror = 0x80 /* decoding error in UTF */
103};
104
105/*
106 * rune routines
107 */
108extern int runetochar(char*, Rune*);
109extern int chartorune(Rune*, char*);
110extern int runelen(long);
111extern int runenlen(Rune*, int);
112extern int fullrune(char*, int);
113extern int utflen(char*);
114extern int utfnlen(char*, long);
115extern char* utfrune(char*, long);
116extern char* utfrrune(char*, long);
117extern char* utfutf(char*, char*);
118extern char* utfecpy(char*, char*, char*);
119
120extern Rune* runestrcat(Rune*, Rune*);
121extern Rune* runestrchr(Rune*, Rune);
122extern int runestrcmp(Rune*, Rune*);
123extern Rune* runestrcpy(Rune*, Rune*);
124extern Rune* runestrncpy(Rune*, Rune*, long);
125extern Rune* runestrecpy(Rune*, Rune*, Rune*);
126extern Rune* runestrdup(Rune*);
127extern Rune* runestrncat(Rune*, Rune*, long);
128extern int runestrncmp(Rune*, Rune*, long);
129extern Rune* runestrrchr(Rune*, Rune);
130extern long runestrlen(Rune*);
131extern Rune* runestrstr(Rune*, Rune*);
132
133extern Rune tolowerrune(Rune);
134extern Rune totitlerune(Rune);
135extern Rune toupperrune(Rune);
136extern int isalpharune(Rune);
137extern int islowerrune(Rune);
138extern int isspacerune(Rune);
139extern int istitlerune(Rune);
140extern int isupperrune(Rune);
141
142/*
143 * malloc
144 */
145extern void* malloc(size_t);
146extern void* mallocz(ulong, int);
147extern void free(void*);
148extern ulong msize(void*);
149extern void* calloc(size_t, size_t);
150extern void* realloc(void*, size_t);
151extern void setmalloctag(void*, ulong);
152extern void setrealloctag(void*, ulong);
153extern ulong getmalloctag(void*);
154extern ulong getrealloctag(void*);
155extern void* malloctopoolblock(void*);
156
157/*
158 * print routines
159 */
160typedef struct Fmt Fmt;
161struct Fmt{
162 uchar runes; /* output buffer is runes or chars? */
163 void *start; /* of buffer */
164 void *to; /* current place in the buffer */
165 void *stop; /* end of the buffer; overwritten if flush fails */
166 int (*flush)(Fmt *); /* called when to == stop */
167 void *farg; /* to make flush a closure */
168 int nfmt; /* num chars formatted so far */
169 va_list args; /* args passed to dofmt */
170 int r; /* % format Rune */
171 int width;
172 int prec;
173 ulong flags;
174};
175
176enum{
177 FmtWidth = 1,
178 FmtLeft = FmtWidth << 1,
179 FmtPrec = FmtLeft << 1,
180 FmtSharp = FmtPrec << 1,
181 FmtSpace = FmtSharp << 1,
182 FmtSign = FmtSpace << 1,
183 FmtZero = FmtSign << 1,
184 FmtUnsigned = FmtZero << 1,
185 FmtShort = FmtUnsigned << 1,
186 FmtLong = FmtShort << 1,
187 FmtVLong = FmtLong << 1,
188 FmtComma = FmtVLong << 1,
189 FmtByte = FmtComma << 1,
190
191 FmtFlag = FmtByte << 1
192};
193
194extern int print(char*, ...);
195extern char* seprint(char*, char*, char*, ...);
196extern char* vseprint(char*, char*, char*, va_list);
197extern int snprint(char*, int, char*, ...);
198extern int vsnprint(char*, int, char*, va_list);
199extern char* smprint(char*, ...);
200extern char* vsmprint(char*, va_list);
201extern int sprint(char*, char*, ...);
202extern int fprint(int, char*, ...);
203extern int vfprint(int, char*, va_list);
204
205extern int runesprint(Rune*, char*, ...);
206extern int runesnprint(Rune*, int, char*, ...);
207extern int runevsnprint(Rune*, int, char*, va_list);
208extern Rune* runeseprint(Rune*, Rune*, char*, ...);
209extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
210extern Rune* runesmprint(char*, ...);
211extern Rune* runevsmprint(char*, va_list);
212
213extern int fmtfdinit(Fmt*, int, char*, int);
214extern int fmtfdflush(Fmt*);
215extern int fmtstrinit(Fmt*);
216extern char* fmtstrflush(Fmt*);
217extern int runefmtstrinit(Fmt*);
218extern Rune* runefmtstrflush(Fmt*);
219
220extern int fmtinstall(int, int (*)(Fmt*));
221extern int dofmt(Fmt*, char*);
222extern int dorfmt(Fmt*, Rune*);
223extern int fmtprint(Fmt*, char*, ...);
224extern int fmtvprint(Fmt*, char*, va_list);
225extern int fmtrune(Fmt*, int);
226extern int fmtstrcpy(Fmt*, char*);
227extern int fmtrunestrcpy(Fmt*, Rune*);
228/*
229 * error string for %r
230 * supplied on per os basis, not part of fmt library
231 */
232extern int errfmt(Fmt *f);
233
234/*
235 * quoted strings
236 */
237extern char *unquotestrdup(char*);
238extern Rune *unquoterunestrdup(Rune*);
239extern char *quotestrdup(char*);
240extern Rune *quoterunestrdup(Rune*);
241extern int quotestrfmt(Fmt*);
242extern int quoterunestrfmt(Fmt*);
243extern void quotefmtinstall(void);
244extern int (*doquote)(int);
245
246/*
247 * random number
248 */
249
250extern int nrand(int);
251extern ulong truerand(void);
252extern ulong ntruerand(ulong);
253
254/*
255 * math
256 */
257extern int isNaN(double);
258extern int isInf(double, int);
259extern double pow(double, double);
260
261/*
262 * Time-of-day
263 */
264
265typedef struct Tm Tm;
266struct Tm {
267 int sec;
268 int min;
269 int hour;
270 int mday;
271 int mon;
272 int year;
273 int wday;
274 int yday;
275 char zone[4];
276 int tzoff;
277};
278extern vlong osnsec(void);
279#define nsec osnsec
280
281/*
282 * one-of-a-kind
283 */
284extern void _assert(char*);
285extern double charstod(int(*)(void*), void*);
286extern char* cleanname(char*);
287extern double frexp(double, int*);
288extern uintptr getcallerpc(void*);
289extern int getfields(char*, char**, int, int, char*);
290extern char* getuser(void);
291extern char* getwd(char*, int);
292extern double ipow10(int);
293extern double ldexp(double, int);
294extern double modf(double, double*);
295extern void perror(const char*);
296extern double pow10(int);
297extern uvlong strtoull(const char*, char**, int);
298extern void sysfatal(char*, ...);
299extern int dec64(uchar*, int, char*, int);
300extern int enc64(char*, int, uchar*, int);
301extern int dec32(uchar*, int, char*, int);
302extern int enc32(char*, int, uchar*, int);
303extern int dec16(uchar*, int, char*, int);
304extern int enc16(char*, int, uchar*, int);
305extern int encodefmt(Fmt*);
306
307/*
308 * synchronization
309 */
310typedef
311struct Lock {
312 int val;
313 int pid;
314} Lock;
315
316extern int _tas(int*);
317
318extern void lock(Lock*);
319extern void unlock(Lock*);
320extern int canlock(Lock*);
321
322typedef struct QLock QLock;
323struct QLock
324{
325 Lock use; /* to access Qlock structure */
326 Proc *head; /* next process waiting for object */
327 Proc *tail; /* last process waiting for object */
328 int locked; /* flag */
329};
330
331extern void qlock(QLock*);
332extern void qunlock(QLock*);
333extern int canqlock(QLock*);
334extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
335
336typedef
337struct RWLock
338{
339 Lock l; /* Lock modify lock */
340 QLock x; /* Mutual exclusion lock */
341 QLock k; /* Lock for waiting writers */
342 int readers; /* Count of readers in lock */
343} RWLock;
344
345extern int canrlock(RWLock*);
346extern int canwlock(RWLock*);
347extern void rlock(RWLock*);
348extern void runlock(RWLock*);
349extern void wlock(RWLock*);
350extern void wunlock(RWLock*);
351
352/*
353 * network dialing
354 */
355#define NETPATHLEN 40
356
357/*
358 * system calls
359 *
360 */
361
362#define STATMAX 65535U /* max length of machine-independent stat structure */
363#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
364#define ERRMAX 128 /* max length of error string */
365
366#define MORDER 0x0003 /* mask for bits defining order of mounting */
367#define MREPL 0x0000 /* mount replaces object */
368#define MBEFORE 0x0001 /* mount goes before others in union directory */
369#define MAFTER 0x0002 /* mount goes after others in union directory */
370#define MCREATE 0x0004 /* permit creation in mounted directory */
371#define MCACHE 0x0010 /* cache some data */
372#define MMASK 0x0017 /* all bits on */
373
374#define OREAD 0 /* open for read */
375#define OWRITE 1 /* write */
376#define ORDWR 2 /* read and write */
377#define OEXEC 3 /* execute, == read but check execute permission */
378#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
379#define OCEXEC 32 /* or'ed in, close on exec */
380#define ORCLOSE 64 /* or'ed in, remove on close */
381#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
382
383#define AEXIST 0 /* accessible: exists */
384#define AEXEC 1 /* execute access */
385#define AWRITE 2 /* write access */
386#define AREAD 4 /* read access */
387
388/* bits in Qid.type */
389#define QTDIR 0x80 /* type bit for directories */
390#define QTAPPEND 0x40 /* type bit for append only files */
391#define QTEXCL 0x20 /* type bit for exclusive use files */
392#define QTMOUNT 0x10 /* type bit for mounted channel */
393#define QTAUTH 0x08 /* type bit for authentication file */
394#define QTFILE 0x00 /* plain file */
395
396/* bits in Dir.mode */
397#define DMDIR 0x80000000 /* mode bit for directories */
398#define DMAPPEND 0x40000000 /* mode bit for append only files */
399#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
400#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
401#define DMAUTH 0x08000000 /* mode bit for authentication file */
402#define DMREAD 0x4 /* mode bit for read permission */
403#define DMWRITE 0x2 /* mode bit for write permission */
404#define DMEXEC 0x1 /* mode bit for execute permission */
405
406typedef
407struct Qid
408{
409 uvlong path;
410 ulong vers;
411 uchar type;
412} Qid;
413
414typedef
415struct Dir {
416 /* system-modified data */
417 ushort type; /* server type */
418 uint dev; /* server subtype */
419 /* file data */
420 Qid qid; /* unique id from server */
421 ulong mode; /* permissions */
422 ulong atime; /* last read time */
423 ulong mtime; /* last write time */
424 vlong length; /* file length */
425 char *name; /* last element of path */
426 char *uid; /* owner name */
427 char *gid; /* group name */
428 char *muid; /* last modifier name */
429} Dir;
430
431extern Dir* dirstat(char*);
432extern Dir* dirfstat(int);
433extern int dirwstat(char*, Dir*);
434extern int dirfwstat(int, Dir*);
435extern long dirread(int, Dir**);
436extern void nulldir(Dir*);
437extern long dirreadall(int, Dir**);
438
439typedef
440struct Waitmsg
441{
442 int pid; /* of loved one */
443 ulong time[3]; /* of loved one & descendants */
444 char *msg;
445} Waitmsg;
446
447extern void _exits(char*);
448
449extern void exits(char*);
450extern int create(char*, int, int);
451extern int errstr(char*, uint);
452
453extern void perror(const char*);
454extern long readn(int, void*, long);
455extern int remove(const char*);
456extern void rerrstr(char*, uint);
457extern vlong seek(int, vlong, int);
458extern int segflush(void*, ulong);
459extern void werrstr(char*, ...);
460
461extern char *argv0;
462#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
463 argv[0] && argv[0][0]=='-' && argv[0][1];\
464 argc--, argv++) {\
465 char *_args, *_argt;\
466 Rune _argc;\
467 _args = &argv[0][1];\
468 if(_args[0]=='-' && _args[1]==0){\
469 argc--; argv++; break;\
470 }\
471 _argc = 0;\
472 while(*_args && (_args += chartorune(&_argc, _args)))\
473 switch(_argc)
474#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
475#define ARGF() (_argt=_args, _args="",\
476 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
477#define EARGF(x) (_argt=_args, _args="",\
478 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
479
480#define ARGC() _argc
481
482/*
483 * Extensions for Inferno to basic libc.h
484 */
485
486#define setbinmode()
487
MacOSX/README+72−0
@@ -0,0 +1,72 @@
1This file is of historical interest only, but serves to note that
2much of the work of the MacOSX ports was originally done by Corpus Callosum.
3Bugs to support@vitanuova.com, though.
4
5March 2006: initial MacOSX 10.4/x86 port
6
712-Dec-2003
8Emu can use wm with Apple's X11R6 again.
9
1008-Dec-2003
11Inferno Services (6660, 6666-6676, 2202)
12
1326-Aug-2003
14In order to run and use Inferno services appropriately on OSX, you need to ensure that the Sharing System Preferences include an entry in the Firewall section that is turned on and looks like the following line:
15
16Inferno services (6660, 6666-6674)
17
18
1905-Jul-2003
20In order to support 1.4, the build will now use the default 'mk' provided with the Inferno distribution. You can also copy tcshrc to the Inferno ROOT and source the file from that directory before running or building emu. Modified mkfiles and sources are now available in the srcMacOSX archive. You may also want to change 'mkconfig' with the following diff
21
22% cvs diff -r 1.1 mkconfig
23Index: mkconfig
24===================================================================
25RCS file: /usr/local/Repository/cvs/vitanuova/inferno_v14/mkconfig,v
26retrieving revision 1.1
27retrieving revision 1.3
28diff -r1.1 -r1.3
297c7
30< ROOT=/usr/inferno
31---
32> ROOT=$ROOT
3317c17
34< SYSHOST=Plan9 # build system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
35---
36> SYSHOST=MacOSX # build system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
3725c25
38< OBJTYPE=$objtype
39---
40> OBJTYPE=power
41
42
43
4416-May-2003
45
46The build now uses the open sourced 'mk' from http://www.pdos.lcs.mit.edu/~rsc/software/
47
48There is a file .tcshrc at the root of this tree (..) that can be used to set up the environment required to build emu.
49
50
51
5228-Feb-2001
53
54The initial port has been provided by Corpus Callosum Corporation.
55
56This port of Inferno for Darwin, Mac OS X, and Mac OS X Server hosted environments currently provides base 'emu' support. Wm, audio, and other services are not currently ported. It has only been tested on UFS partitions and will require further testing for HFS+ support.
57
58Emu -c1 currently errors out as "Illegal instruction"
59
60Various malloc/free (from libc/System on Mac OS X/Darwin) warnings should be removed in the following version.
61
62eia devices will recognize /dev/ttyd.irda and /dev/ttyd.modem though both are completely untested (need to get updates to the RCX interface to test irda).
63
64The following modification was added to various 'mkfile' to support required redefinition of varios core functions.
65
66 <$ROOT/mkfiles/mkalloc-$SYSHOST-$OBJTYPE
67
68Some of the base libraries and utils will have *.pbproj files which were used to bootstrap the initial build system on Mac OS X (Public Beta).
69
70
71
72"Mac OS X" and "Mac OS X Server" are trade marks of Apple Computer, Inc.
MacOSX/power/bin/data2c+0−0

Binary file not shown.

MacOSX/power/bin/iyacc+0−0

Binary file not shown.

MacOSX/power/bin/mk+0−0

Binary file not shown.

MacOSX/power/bin/mkext+0−0

Binary file not shown.

MacOSX/power/include/emu.h+22−0
@@ -0,0 +1,22 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc *getup(void);
8#define up (getup())
9
10/*
11 * This structure must agree with FPsave and FPrestore asm routines
12 */
13
14#include <architecture/ppc/fp_regs.h>
15
16typedef union {
17 double __dbl;
18 ppc_fp_scr_t __src;
19} FPU;
20
21typedef sigjmp_buf osjmpbuf;
22#define ossetjmp(buf) sigsetjmp(buf, 1)
MacOSX/power/include/fpuctl.h+81−0
@@ -0,0 +1,81 @@
1/*
2 * MacOSX/Darwin ppc fpu support
3 * Mimic Plan9 floating point support
4 */
5
6#include <architecture/ppc/fp_regs.h>
7
8static __inline__ ulong
9getfcr(void)
10{
11 ppc_fp_scr_t fpscr = get_fp_scr();
12 return ((ulong *)&fpscr)[1];
13}
14
15ulong
16getfsr(void)
17{
18 ppc_fp_scr_t fpscr = get_fp_scr();
19 return ((ulong *)&fpscr)[1];
20}
21
22void
23setfsr(ulong fsr)
24{
25 ppc_fp_scr_t fpscr;
26 // fpscr = get_fp_scr();
27 (((ulong *)&fpscr)[1]) = fsr;
28 set_fp_scr(fpscr);
29}
30
31void
32setfcr(ulong fcr)
33{
34 ppc_fp_scr_t fpscr;
35 // fpscr = get_fp_scr();
36 (((ulong *)&fpscr)[1]) = fcr;
37 set_fp_scr(fpscr);
38}
39
40/* FPSCR */
41#define FPSFX (1<<31) /* exception summary (sticky) */
42#define FPSEX (1<<30) /* enabled exception summary */
43#define FPSVX (1<<29) /* invalid operation exception summary */
44#define FPSOX (1<<28) /* overflow exception OX (sticky) */
45#define FPSUX (1<<27) /* underflow exception UX (sticky) */
46#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
47#define FPSXX (1<<25) /* inexact exception XX (sticky) */
48#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
49#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
50#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
51#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
52#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
53#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
54#define FPSFR (1<<18) /* fraction rounded */
55#define FPSFI (1<<17) /* fraction inexact */
56#define FPSFPRF (1<<16) /* floating point result class */
57#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
58#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
59
60/* FCR */
61#define FPVE (1<<7) /* invalid operation exception enable */
62#define FPOVFL (1<<6) /* enable overflow exceptions */
63#define FPUNFL (1<<5) /* enable underflow */
64#define FPZDIV (1<<4) /* enable zero divide */
65#define FPINEX (1<<3) /* enable inexact exceptions */
66#define FPRMASK (3<<0) /* rounding mode */
67#define FPRNR (0<<0)
68#define FPRZ (1<<0)
69#define FPRPINF (2<<0)
70#define FPRNINF (3<<0)
71#define FPPEXT 0
72#define FPPSGL 0
73#define FPPDBL 0
74#define FPPMASK 0
75#define FPINVAL FPVE
76/* FSR */
77#define FPAOVFL FPSOX
78#define FPAINEX FPSXX
79#define FPAUNFL FPSUX
80#define FPAZDIV FPSZX
81#define FPAINVAL FPSVX
MacOSX/power/include/lib9.h+487−0
@@ -0,0 +1,487 @@
1/*
2 * Based on FreeBSD lib9.h
3 * Copyright © 1998, 1999 Lucent Technologies Inc. All rights reserved.
4 * Revisions Copyright © 1999, 2002 Vita Nuova Limited. All rights reserved.
5 * Revisions Copyright © 2002, 2003 Corpus Callosum Corporation. All rights reserved.
6 */
7
8/* define _BSD_SOURCE to use ISO C, POSIX, and 4.4BSD things. */
9#ifndef _BSD_SOURCE
10#define _BSD_SOURCE
11#endif
12#define _LARGEFILE64_SOURCE 1
13#define _FILE_OFFSET_BITS 64
14
15#include <sys/types.h>
16#include <sys/stat.h>
17#include <stdlib.h>
18#include <stdarg.h>
19#include <unistd.h>
20#include <errno.h>
21#include <string.h>
22// #include "math.h"
23#include <fcntl.h>
24#include <setjmp.h>
25#include <float.h>
26#include <time.h>
27
28#define nil ((void*)0)
29
30// typedef unsigned short ushort;
31typedef unsigned char uchar;
32typedef unsigned long ulong;
33// typedef unsigned int uint;
34typedef signed char schar;
35typedef long long vlong;
36typedef unsigned long long uvlong;
37typedef ushort Rune;
38typedef unsigned int u32int;
39typedef uvlong u64int;
40
41typedef unsigned int mpdigit; /* for /sys/include/mp.h */
42typedef unsigned short u16int;
43typedef unsigned char u8int;
44typedef unsigned long uintptr;
45
46typedef signed char int8;
47typedef unsigned char uint8;
48typedef short int16;
49typedef unsigned short uint16;
50typedef int int32;
51typedef unsigned int uint32;
52typedef long long int64;
53typedef unsigned long long uint64;
54
55/* handle conflicts with host os libs */
56#define getwd infgetwd
57#define scalb infscalb
58#define div infdiv
59#define panic infpanic
60#define rint infrint
61#define rcmd infrcmd
62#define pow10 infpow10
63
64#ifndef EMU
65typedef struct Proc Proc;
66#endif
67
68/*
69 * math module dtoa
70 */
71#include <machine/endian.h>
72#define __BIG_ENDIAN
73
74#define USED(x) if(x){}else{}
75#define SET(x)
76
77#define nelem(x) (sizeof(x)/sizeof((x)[0]))
78#undef offsetof
79#undef assert
80#define offsetof(s, m) (ulong)(&(((s*)0)->m))
81#define assert(x) if(x){}else _assert("x")
82
83/*
84 * mem and string routines are declared by ANSI/POSIX files above
85 */
86
87extern char* strecpy(char*, char*, char*);
88extern char* strdup(const char*);
89extern int cistrncmp(char*, char*, int);
90extern int cistrcmp(char*, char*);
91extern char* cistrstr(char*, char*);
92extern int tokenize(char*, char**, int);
93extern vlong strtoll(const char*, char**, int);
94#define qsort infqsort
95extern void qsort(void*, long, long, int (*)(void*, void*));
96
97enum
98{
99 UTFmax = 3, /* maximum bytes per rune */
100 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
101 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
102 Runeerror = 0x80 /* decoding error in UTF */
103};
104
105/*
106 * rune routines
107 */
108extern int runetochar(char*, Rune*);
109extern int chartorune(Rune*, char*);
110extern int runelen(long);
111extern int runenlen(Rune*, int);
112extern int fullrune(char*, int);
113extern int utflen(char*);
114extern int utfnlen(char*, long);
115extern char* utfrune(char*, long);
116extern char* utfrrune(char*, long);
117extern char* utfutf(char*, char*);
118extern char* utfecpy(char*, char*, char*);
119
120extern Rune* runestrcat(Rune*, Rune*);
121extern Rune* runestrchr(Rune*, Rune);
122extern int runestrcmp(Rune*, Rune*);
123extern Rune* runestrcpy(Rune*, Rune*);
124extern Rune* runestrncpy(Rune*, Rune*, long);
125extern Rune* runestrecpy(Rune*, Rune*, Rune*);
126extern Rune* runestrdup(Rune*);
127extern Rune* runestrncat(Rune*, Rune*, long);
128extern int runestrncmp(Rune*, Rune*, long);
129extern Rune* runestrrchr(Rune*, Rune);
130extern long runestrlen(Rune*);
131extern Rune* runestrstr(Rune*, Rune*);
132
133extern Rune tolowerrune(Rune);
134extern Rune totitlerune(Rune);
135extern Rune toupperrune(Rune);
136extern int isalpharune(Rune);
137extern int islowerrune(Rune);
138extern int isspacerune(Rune);
139extern int istitlerune(Rune);
140extern int isupperrune(Rune);
141
142/*
143 * malloc
144 */
145extern void* malloc(size_t);
146extern void* mallocz(ulong, int);
147extern void free(void*);
148extern ulong msize(void*);
149extern void* calloc(size_t, size_t);
150extern void* realloc(void*, size_t);
151extern void setmalloctag(void*, ulong);
152extern void setrealloctag(void*, ulong);
153extern ulong getmalloctag(void*);
154extern ulong getrealloctag(void*);
155extern void* malloctopoolblock(void*);
156
157/*
158 * print routines
159 */
160typedef struct Fmt Fmt;
161struct Fmt{
162 uchar runes; /* output buffer is runes or chars? */
163 void *start; /* of buffer */
164 void *to; /* current place in the buffer */
165 void *stop; /* end of the buffer; overwritten if flush fails */
166 int (*flush)(Fmt *); /* called when to == stop */
167 void *farg; /* to make flush a closure */
168 int nfmt; /* num chars formatted so far */
169 va_list args; /* args passed to dofmt */
170 int r; /* % format Rune */
171 int width;
172 int prec;
173 ulong flags;
174};
175
176enum{
177 FmtWidth = 1,
178 FmtLeft = FmtWidth << 1,
179 FmtPrec = FmtLeft << 1,
180 FmtSharp = FmtPrec << 1,
181 FmtSpace = FmtSharp << 1,
182 FmtSign = FmtSpace << 1,
183 FmtZero = FmtSign << 1,
184 FmtUnsigned = FmtZero << 1,
185 FmtShort = FmtUnsigned << 1,
186 FmtLong = FmtShort << 1,
187 FmtVLong = FmtLong << 1,
188 FmtComma = FmtVLong << 1,
189 FmtByte = FmtComma << 1,
190
191 FmtFlag = FmtByte << 1
192};
193
194extern int print(char*, ...);
195extern char* seprint(char*, char*, char*, ...);
196extern char* vseprint(char*, char*, char*, va_list);
197extern int snprint(char*, int, char*, ...);
198extern int vsnprint(char*, int, char*, va_list);
199extern char* smprint(char*, ...);
200extern char* vsmprint(char*, va_list);
201extern int sprint(char*, char*, ...);
202extern int fprint(int, char*, ...);
203extern int vfprint(int, char*, va_list);
204
205extern int runesprint(Rune*, char*, ...);
206extern int runesnprint(Rune*, int, char*, ...);
207extern int runevsnprint(Rune*, int, char*, va_list);
208extern Rune* runeseprint(Rune*, Rune*, char*, ...);
209extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
210extern Rune* runesmprint(char*, ...);
211extern Rune* runevsmprint(char*, va_list);
212
213extern int fmtfdinit(Fmt*, int, char*, int);
214extern int fmtfdflush(Fmt*);
215extern int fmtstrinit(Fmt*);
216extern char* fmtstrflush(Fmt*);
217extern int runefmtstrinit(Fmt*);
218extern Rune* runefmtstrflush(Fmt*);
219
220extern int fmtinstall(int, int (*)(Fmt*));
221extern int dofmt(Fmt*, char*);
222extern int dorfmt(Fmt*, Rune*);
223extern int fmtprint(Fmt*, char*, ...);
224extern int fmtvprint(Fmt*, char*, va_list);
225extern int fmtrune(Fmt*, int);
226extern int fmtstrcpy(Fmt*, char*);
227extern int fmtrunestrcpy(Fmt*, Rune*);
228/*
229 * error string for %r
230 * supplied on per os basis, not part of fmt library
231 */
232extern int errfmt(Fmt *f);
233
234/*
235 * quoted strings
236 */
237extern char *unquotestrdup(char*);
238extern Rune *unquoterunestrdup(Rune*);
239extern char *quotestrdup(char*);
240extern Rune *quoterunestrdup(Rune*);
241extern int quotestrfmt(Fmt*);
242extern int quoterunestrfmt(Fmt*);
243extern void quotefmtinstall(void);
244extern int (*doquote)(int);
245
246/*
247 * random number
248 */
249
250extern int nrand(int);
251extern ulong truerand(void);
252extern ulong ntruerand(ulong);
253
254/*
255 * math
256 */
257extern int isNaN(double);
258extern int isInf(double, int);
259extern double pow(double, double);
260
261/*
262 * Time-of-day
263 */
264
265typedef struct Tm Tm;
266struct Tm {
267 int sec;
268 int min;
269 int hour;
270 int mday;
271 int mon;
272 int year;
273 int wday;
274 int yday;
275 char zone[4];
276 int tzoff;
277};
278extern vlong osnsec(void);
279#define nsec osnsec
280
281/*
282 * one-of-a-kind
283 */
284extern void _assert(char*);
285extern double charstod(int(*)(void*), void*);
286extern char* cleanname(char*);
287extern double frexp(double, int*);
288extern uintptr getcallerpc(void*);
289extern int getfields(char*, char**, int, int, char*);
290extern char* getuser(void);
291extern char* getwd(char*, int);
292extern double ipow10(int);
293extern double ldexp(double, int);
294extern double modf(double, double*);
295extern void perror(const char*);
296extern double pow10(int);
297extern uvlong strtoull(const char*, char**, int);
298extern void sysfatal(char*, ...);
299extern int dec64(uchar*, int, char*, int);
300extern int enc64(char*, int, uchar*, int);
301extern int dec32(uchar*, int, char*, int);
302extern int enc32(char*, int, uchar*, int);
303extern int dec16(uchar*, int, char*, int);
304extern int enc16(char*, int, uchar*, int);
305extern int encodefmt(Fmt*);
306
307/*
308 * synchronization
309 */
310typedef
311struct Lock {
312 int val;
313 int pid;
314} Lock;
315
316extern int _tas(int*);
317
318extern void lock(Lock*);
319extern void unlock(Lock*);
320extern int canlock(Lock*);
321
322typedef struct QLock QLock;
323struct QLock
324{
325 Lock use; /* to access Qlock structure */
326 Proc *head; /* next process waiting for object */
327 Proc *tail; /* last process waiting for object */
328 int locked; /* flag */
329};
330
331extern void qlock(QLock*);
332extern void qunlock(QLock*);
333extern int canqlock(QLock*);
334extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
335
336typedef
337struct RWLock
338{
339 Lock l; /* Lock modify lock */
340 QLock x; /* Mutual exclusion lock */
341 QLock k; /* Lock for waiting writers */
342 int readers; /* Count of readers in lock */
343} RWLock;
344
345extern int canrlock(RWLock*);
346extern int canwlock(RWLock*);
347extern void rlock(RWLock*);
348extern void runlock(RWLock*);
349extern void wlock(RWLock*);
350extern void wunlock(RWLock*);
351
352/*
353 * network dialing
354 */
355#define NETPATHLEN 40
356
357/*
358 * system calls
359 *
360 */
361
362#define STATMAX 65535U /* max length of machine-independent stat structure */
363#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
364#define ERRMAX 128 /* max length of error string */
365
366#define MORDER 0x0003 /* mask for bits defining order of mounting */
367#define MREPL 0x0000 /* mount replaces object */
368#define MBEFORE 0x0001 /* mount goes before others in union directory */
369#define MAFTER 0x0002 /* mount goes after others in union directory */
370#define MCREATE 0x0004 /* permit creation in mounted directory */
371#define MCACHE 0x0010 /* cache some data */
372#define MMASK 0x0017 /* all bits on */
373
374#define OREAD 0 /* open for read */
375#define OWRITE 1 /* write */
376#define ORDWR 2 /* read and write */
377#define OEXEC 3 /* execute, == read but check execute permission */
378#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
379#define OCEXEC 32 /* or'ed in, close on exec */
380#define ORCLOSE 64 /* or'ed in, remove on close */
381#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
382
383#define AEXIST 0 /* accessible: exists */
384#define AEXEC 1 /* execute access */
385#define AWRITE 2 /* write access */
386#define AREAD 4 /* read access */
387
388/* bits in Qid.type */
389#define QTDIR 0x80 /* type bit for directories */
390#define QTAPPEND 0x40 /* type bit for append only files */
391#define QTEXCL 0x20 /* type bit for exclusive use files */
392#define QTMOUNT 0x10 /* type bit for mounted channel */
393#define QTAUTH 0x08 /* type bit for authentication file */
394#define QTFILE 0x00 /* plain file */
395
396/* bits in Dir.mode */
397#define DMDIR 0x80000000 /* mode bit for directories */
398#define DMAPPEND 0x40000000 /* mode bit for append only files */
399#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
400#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
401#define DMAUTH 0x08000000 /* mode bit for authentication file */
402#define DMREAD 0x4 /* mode bit for read permission */
403#define DMWRITE 0x2 /* mode bit for write permission */
404#define DMEXEC 0x1 /* mode bit for execute permission */
405
406typedef
407struct Qid
408{
409 uvlong path;
410 ulong vers;
411 uchar type;
412} Qid;
413
414typedef
415struct Dir {
416 /* system-modified data */
417 ushort type; /* server type */
418 uint dev; /* server subtype */
419 /* file data */
420 Qid qid; /* unique id from server */
421 ulong mode; /* permissions */
422 ulong atime; /* last read time */
423 ulong mtime; /* last write time */
424 vlong length; /* file length */
425 char *name; /* last element of path */
426 char *uid; /* owner name */
427 char *gid; /* group name */
428 char *muid; /* last modifier name */
429} Dir;
430
431extern Dir* dirstat(char*);
432extern Dir* dirfstat(int);
433extern int dirwstat(char*, Dir*);
434extern int dirfwstat(int, Dir*);
435extern long dirread(int, Dir**);
436extern void nulldir(Dir*);
437extern long dirreadall(int, Dir**);
438
439typedef
440struct Waitmsg
441{
442 int pid; /* of loved one */
443 ulong time[3]; /* of loved one & descendants */
444 char *msg;
445} Waitmsg;
446
447extern void _exits(char*);
448
449extern void exits(char*);
450extern int create(char*, int, int);
451extern int errstr(char*, uint);
452
453extern void perror(const char*);
454extern long readn(int, void*, long);
455extern int remove(const char*);
456extern void rerrstr(char*, uint);
457extern vlong seek(int, vlong, int);
458extern int segflush(void*, ulong);
459extern void werrstr(char*, ...);
460
461extern char *argv0;
462#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
463 argv[0] && argv[0][0]=='-' && argv[0][1];\
464 argc--, argv++) {\
465 char *_args, *_argt;\
466 Rune _argc;\
467 _args = &argv[0][1];\
468 if(_args[0]=='-' && _args[1]==0){\
469 argc--; argv++; break;\
470 }\
471 _argc = 0;\
472 while(*_args && (_args += chartorune(&_argc, _args)))\
473 switch(_argc)
474#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
475#define ARGF() (_argt=_args, _args="",\
476 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
477#define EARGF(x) (_argt=_args, _args="",\
478 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
479
480#define ARGC() _argc
481
482/*
483 * Extensions for Inferno to basic libc.h
484 */
485
486#define setbinmode()
487
MacOSX/tcshrc+12−0
@@ -0,0 +1,12 @@
1#
2# needed for the build process
3#
4set path=( $path `pwd`/MacOSX/power/bin )
5
6setenv EMU "-r`pwd` -g1024x768"
7
8setenv ROOT `pwd`
9setenv SYSHOST MacOSX
10setenv OBJTYPE power
11setenv ACIDLIB $ROOT/lib/acid
12
NOTICE+32−0
@@ -0,0 +1,32 @@
1This Inferno® distribution includes software from various sources and
2different portions are therefore subject to different licence terms.
3The most stringent is the GNU Public License (version 2), which governs the collection.
4Individual components might have their own NOTICE and licence files (LICENCE
5or COPYING) that cover their content. All of them allow modification and redistribution.
6They are all compatible with the GPLv2.
7
8The following copyright notice covers the contents of this
9distribution unless otherwise specified by a given file, directory, or
10directory tree:
11
12Inferno® Copyright © 1996-1999 Lucent Technologies Inc. All rights reserved.
13Inferno revisions Copyright © 1997-1999 Vita Nuova Limited. All rights reserved.
14Inferno revisions Copyright © 2000-2007 Vita Nuova Holdings Limited. All rights reserved.
15Inferno new material Copyright © 2000-2007 Vita Nuova Holdings Limited. All rights reserved.
16
17Inferno, Styx, Dis and Limbo are registered trademarks of Vita Nuova Holdings Limited in the USA and other countries.
18Plan 9 is a registered trademark of Lucent Technologies Inc.
19
20This program is free software; you can redistribute it and/or modify
21it under the terms of the GNU General Public License (`GPL') as published by
22the Free Software Foundation; either version 2 of the License, or
23(at your option) any later version.
24
25This program is distributed in the hope that it will be useful,
26but WITHOUT ANY WARRANTY; without even the implied warranty of
27MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28GNU General Public License for more details.
29
30You should have received a copy of the GNU General Public License
31along with this program; if not, write to the Free Software
32Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
NetBSD/386/bin/data2c+0−0

Binary file not shown.

NetBSD/386/bin/mk+0−0

Binary file not shown.

NetBSD/386/bin/mkext+0−0

Binary file not shown.

NetBSD/386/bin/yacc+0−0

Binary file not shown.

NetBSD/386/include/emu.h+30−0
@@ -0,0 +1,30 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16#define KSTACK (32 * 1024)
17
18static __inline Proc *getup(void) {
19 Proc *p;
20 __asm__( "movl %%esp, %%eax\n\t"
21 : "=a" (p)
22 );
23 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
24};
25
26#define up (getup())
27
28typedef sigjmp_buf osjmpbuf;
29#define ossetjmp(buf) sigsetjmp(buf, 1)
30
NetBSD/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * Linux 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
NetBSD/386/include/lib9.h+476−0
@@ -0,0 +1,476 @@
1#include <sys/types.h>
2#include <sys/endian.h>
3#include <sys/stat.h>
4#include <stdint.h>
5#include <stdlib.h>
6#include <stdarg.h>
7#include <unistd.h>
8#include <errno.h>
9#include <string.h>
10#include <math.h>
11#include <fcntl.h>
12#include <setjmp.h>
13#include <float.h>
14#include <time.h>
15
16#define getwd infgetwd
17
18#define round infround
19#define fmax inffmax
20#define log2 inflog2
21
22#ifndef EMU
23typedef struct Proc Proc;
24#endif
25
26/*
27 * math module dtoa
28 */
29#if _BYTE_ORDER == _LITTLE_ENDIAN
30#define __LITTLE_ENDIAN
31#endif
32
33#define nil ((void*)0)
34
35typedef unsigned char uchar;
36typedef signed char schar;
37#if 0 /* XXX: uwe: already defined in <sys/types.h> */
38typedef unsigned long ulong;
39#endif
40
41typedef int64_t vlong;
42typedef uint64_t uvlong;
43
44typedef uint8_t u8int;
45typedef uint16_t u16int;
46typedef uint32_t u32int;
47typedef uvlong u64int;
48
49typedef uintptr_t uintptr;
50
51typedef signed char int8;
52typedef unsigned char uint8;
53typedef short int16;
54typedef unsigned short uint16;
55typedef int int32;
56typedef unsigned int uint32;
57typedef long long int64;
58typedef unsigned long long uint64;
59
60typedef unsigned short Rune;
61typedef unsigned int mpdigit; /* for /sys/include/mp.h */
62
63
64#define USED(x) if(x){}else{}
65#define SET(x)
66
67#undef nelem
68#define nelem(x) (sizeof(x)/sizeof((x)[0]))
69#undef offsetof
70#define offsetof(s, m) (ulong)(&(((s*)0)->m))
71#undef assert
72#define assert(x) if(x){}else _assert(#x)
73
74/*
75 * most mem and string routines are declared by ANSI/POSIX files above
76 */
77
78extern char* strecpy(char*, char*, char*);
79extern char* strdup(const char*);
80extern int cistrncmp(char*, char*, int);
81extern int cistrcmp(char*, char*);
82extern char* cistrstr(char*, char*);
83extern int tokenize(char*, char**, int);
84
85enum
86{
87 UTFmax = 3, /* maximum bytes per rune */
88 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
89 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
90 Runeerror = 0x80 /* decoding error in UTF */
91};
92
93/*
94 * rune routines
95 */
96extern int runetochar(char*, Rune*);
97extern int chartorune(Rune*, char*);
98extern int runelen(long);
99extern int runenlen(Rune*, int);
100extern int fullrune(char*, int);
101extern int utflen(char*);
102extern int utfnlen(char*, long);
103extern char* utfrune(char*, long);
104extern char* utfrrune(char*, long);
105extern char* utfutf(char*, char*);
106extern char* utfecpy(char*, char*, char*);
107
108extern Rune* runestrcat(Rune*, Rune*);
109extern Rune* runestrchr(Rune*, Rune);
110extern int runestrcmp(Rune*, Rune*);
111extern Rune* runestrcpy(Rune*, Rune*);
112extern Rune* runestrncpy(Rune*, Rune*, long);
113extern Rune* runestrecpy(Rune*, Rune*, Rune*);
114extern Rune* runestrdup(Rune*);
115extern Rune* runestrncat(Rune*, Rune*, long);
116extern int runestrncmp(Rune*, Rune*, long);
117extern Rune* runestrrchr(Rune*, Rune);
118extern long runestrlen(Rune*);
119extern Rune* runestrstr(Rune*, Rune*);
120
121extern Rune tolowerrune(Rune);
122extern Rune totitlerune(Rune);
123extern Rune toupperrune(Rune);
124extern int isalpharune(Rune);
125extern int islowerrune(Rune);
126extern int isspacerune(Rune);
127extern int istitlerune(Rune);
128extern int isupperrune(Rune);
129
130/*
131 * malloc
132 */
133extern void* malloc(size_t);
134extern void* mallocz(ulong, int);
135extern void free(void*);
136extern ulong msize(void*);
137extern void* calloc(size_t, size_t);
138extern void* realloc(void*, size_t);
139extern void setmalloctag(void*, ulong);
140extern void setrealloctag(void*, ulong);
141extern ulong getmalloctag(void*);
142extern ulong getrealloctag(void*);
143extern void* malloctopoolblock(void*);
144
145/*
146 * print routines
147 */
148typedef struct Fmt Fmt;
149struct Fmt{
150 uchar runes; /* output buffer is runes or chars? */
151 void *start; /* of buffer */
152 void *to; /* current place in the buffer */
153 void *stop; /* end of the buffer; overwritten if flush fails */
154 int (*flush)(Fmt *); /* called when to == stop */
155 void *farg; /* to make flush a closure */
156 int nfmt; /* num chars formatted so far */
157 va_list args; /* args passed to dofmt */
158 int r; /* % format Rune */
159 int width;
160 int prec;
161 ulong flags;
162};
163
164enum{
165 FmtWidth = 1,
166 FmtLeft = FmtWidth << 1,
167 FmtPrec = FmtLeft << 1,
168 FmtSharp = FmtPrec << 1,
169 FmtSpace = FmtSharp << 1,
170 FmtSign = FmtSpace << 1,
171 FmtZero = FmtSign << 1,
172 FmtUnsigned = FmtZero << 1,
173 FmtShort = FmtUnsigned << 1,
174 FmtLong = FmtShort << 1,
175 FmtVLong = FmtLong << 1,
176 FmtComma = FmtVLong << 1,
177 FmtByte = FmtComma << 1,
178
179 FmtFlag = FmtByte << 1
180};
181
182extern int print(char*, ...);
183extern char* seprint(char*, char*, char*, ...);
184extern char* vseprint(char*, char*, char*, va_list);
185extern int snprint(char*, int, char*, ...);
186extern int vsnprint(char*, int, char*, va_list);
187extern char* smprint(char*, ...);
188extern char* vsmprint(char*, va_list);
189extern int sprint(char*, char*, ...);
190extern int fprint(int, char*, ...);
191extern int vfprint(int, char*, va_list);
192
193extern int runesprint(Rune*, char*, ...);
194extern int runesnprint(Rune*, int, char*, ...);
195extern int runevsnprint(Rune*, int, char*, va_list);
196extern Rune* runeseprint(Rune*, Rune*, char*, ...);
197extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
198extern Rune* runesmprint(char*, ...);
199extern Rune* runevsmprint(char*, va_list);
200
201extern int fmtfdinit(Fmt*, int, char*, int);
202extern int fmtfdflush(Fmt*);
203extern int fmtstrinit(Fmt*);
204extern char* fmtstrflush(Fmt*);
205extern int runefmtstrinit(Fmt*);
206extern Rune* runefmtstrflush(Fmt*);
207
208extern int fmtinstall(int, int (*)(Fmt*));
209extern int dofmt(Fmt*, char*);
210extern int dorfmt(Fmt*, Rune*);
211extern int fmtprint(Fmt*, char*, ...);
212extern int fmtvprint(Fmt*, char*, va_list);
213extern int fmtrune(Fmt*, int);
214extern int fmtstrcpy(Fmt*, char*);
215extern int fmtrunestrcpy(Fmt*, Rune*);
216/*
217 * error string for %r
218 * supplied on per os basis, not part of fmt library
219 */
220extern int errfmt(Fmt *f);
221
222/*
223 * quoted strings
224 */
225extern char *unquotestrdup(char*);
226extern Rune *unquoterunestrdup(Rune*);
227extern char *quotestrdup(char*);
228extern Rune *quoterunestrdup(Rune*);
229extern int quotestrfmt(Fmt*);
230extern int quoterunestrfmt(Fmt*);
231extern void quotefmtinstall(void);
232extern int (*doquote)(int);
233
234/*
235 * random number
236 */
237extern int nrand(int);
238extern ulong truerand(void);
239extern ulong ntruerand(ulong);
240
241/*
242 * math
243 */
244extern int isNaN(double);
245extern int isInf(double, int);
246extern double pow(double, double);
247
248/*
249 * Time-of-day
250 */
251
252typedef struct Tm Tm;
253struct Tm {
254 int sec;
255 int min;
256 int hour;
257 int mday;
258 int mon;
259 int year;
260 int wday;
261 int yday;
262 char zone[4];
263 int tzoff;
264};
265extern vlong osnsec(void);
266#define nsec osnsec
267
268/*
269 * one-of-a-kind
270 */
271extern void _assert(char*);
272extern double charstod(int(*)(void*), void*);
273extern char* cleanname(char*);
274extern double frexp(double, int*);
275extern uintptr getcallerpc(void*);
276extern int getfields(char*, char**, int, int, char*);
277extern char* getuser(void);
278extern char* getwd(char*, int);
279extern double ipow10(int);
280extern double ldexp(double, int);
281extern double modf(double, double*);
282#define pow10 infpow10
283extern double pow10(int);
284extern vlong strtoll(const char*, char**, int);
285#define qsort infqsort
286extern void qsort(void*, long, long, int (*)(void*, void*));
287extern uvlong strtoull(const char*, char**, int);
288extern void sysfatal(char*, ...);
289extern int dec64(uchar*, int, char*, int);
290extern int enc64(char*, int, uchar*, int);
291extern int dec32(uchar*, int, char*, int);
292extern int enc32(char*, int, uchar*, int);
293extern int dec16(uchar*, int, char*, int);
294extern int enc16(char*, int, uchar*, int);
295extern int encodefmt(Fmt*);
296
297/*
298 * synchronization
299 */
300typedef
301struct Lock {
302 int val;
303 int pid;
304} Lock;
305
306extern int _tas(int*);
307
308extern void lock(Lock*);
309extern void unlock(Lock*);
310extern int canlock(Lock*);
311
312typedef struct QLock QLock;
313struct QLock
314{
315 Lock use; /* to access Qlock structure */
316 Proc *head; /* next process waiting for object */
317 Proc *tail; /* last process waiting for object */
318 int locked; /* flag */
319};
320
321extern void qlock(QLock*);
322extern void qunlock(QLock*);
323extern int canqlock(QLock*);
324extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
325
326typedef
327struct RWLock
328{
329 Lock l; /* Lock modify lock */
330 QLock x; /* Mutual exclusion lock */
331 QLock k; /* Lock for waiting writers */
332 int readers; /* Count of readers in lock */
333} RWLock;
334
335extern int canrlock(RWLock*);
336extern int canwlock(RWLock*);
337extern void rlock(RWLock*);
338extern void runlock(RWLock*);
339extern void wlock(RWLock*);
340extern void wunlock(RWLock*);
341
342/*
343 * network dialing
344 */
345#define NETPATHLEN 40
346
347/*
348 * system calls
349 *
350 */
351#define STATMAX 65535U /* max length of machine-independent stat structure */
352#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
353#define ERRMAX 128 /* max length of error string */
354
355#define MORDER 0x0003 /* mask for bits defining order of mounting */
356#define MREPL 0x0000 /* mount replaces object */
357#define MBEFORE 0x0001 /* mount goes before others in union directory */
358#define MAFTER 0x0002 /* mount goes after others in union directory */
359#define MCREATE 0x0004 /* permit creation in mounted directory */
360#define MCACHE 0x0010 /* cache some data */
361#define MMASK 0x0017 /* all bits on */
362
363#define OREAD 0 /* open for read */
364#define OWRITE 1 /* write */
365#define ORDWR 2 /* read and write */
366#define OEXEC 3 /* execute, == read but check execute permission */
367#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
368#define OCEXEC 32 /* or'ed in, close on exec */
369#define ORCLOSE 64 /* or'ed in, remove on close */
370#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
371
372#define AEXIST 0 /* accessible: exists */
373#define AEXEC 1 /* execute access */
374#define AWRITE 2 /* write access */
375#define AREAD 4 /* read access */
376
377/* bits in Qid.type */
378#define QTDIR 0x80 /* type bit for directories */
379#define QTAPPEND 0x40 /* type bit for append only files */
380#define QTEXCL 0x20 /* type bit for exclusive use files */
381#define QTMOUNT 0x10 /* type bit for mounted channel */
382#define QTAUTH 0x08 /* type bit for authentication file */
383#define QTFILE 0x00 /* plain file */
384
385/* bits in Dir.mode */
386#define DMDIR 0x80000000 /* mode bit for directories */
387#define DMAPPEND 0x40000000 /* mode bit for append only files */
388#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
389#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
390#define DMAUTH 0x08000000 /* mode bit for authentication file */
391#define DMREAD 0x4 /* mode bit for read permission */
392#define DMWRITE 0x2 /* mode bit for write permission */
393#define DMEXEC 0x1 /* mode bit for execute permission */
394
395typedef
396struct Qid
397{
398 uvlong path;
399 ulong vers;
400 uchar type;
401} Qid;
402
403typedef
404struct Dir {
405 /* system-modified data */
406 ushort type; /* server type */
407 uint dev; /* server subtype */
408 /* file data */
409 Qid qid; /* unique id from server */
410 ulong mode; /* permissions */
411 ulong atime; /* last read time */
412 ulong mtime; /* last write time */
413 vlong length; /* file length */
414 char *name; /* last element of path */
415 char *uid; /* owner name */
416 char *gid; /* group name */
417 char *muid; /* last modifier name */
418} Dir;
419
420extern Dir* dirstat(char*);
421extern Dir* dirfstat(int);
422extern int dirwstat(char*, Dir*);
423extern int dirfwstat(int, Dir*);
424extern long dirread(int, Dir**);
425extern void nulldir(Dir*);
426extern long dirreadall(int, Dir**);
427
428typedef
429struct Waitmsg
430{
431 int pid; /* of loved one */
432 ulong time[3]; /* of loved one & descendants */
433 char *msg;
434} Waitmsg;
435
436extern void _exits(char*);
437
438extern void exits(char*);
439extern int create(char*, int, int);
440extern int errstr(char*, uint);
441
442extern void perror(const char*);
443extern long readn(int, void*, long);
444extern int remove(const char*);
445extern void rerrstr(char*, uint);
446extern vlong seek(int, vlong, int);
447extern int segflush(void*, ulong);
448extern void werrstr(char*, ...);
449
450extern char *argv0;
451#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
452 argv[0] && argv[0][0]=='-' && argv[0][1];\
453 argc--, argv++) {\
454 char *_args, *_argt;\
455 Rune _argc;\
456 _args = &argv[0][1];\
457 if(_args[0]=='-' && _args[1]==0){\
458 argc--; argv++; break;\
459 }\
460 _argc = 0;\
461 while(*_args && (_args += chartorune(&_argc, _args)))\
462 switch(_argc)
463#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
464#define ARGF() (_argt=_args, _args="",\
465 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
466#define EARGF(x) (_argt=_args, _args="",\
467 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
468
469#define ARGC() _argc
470
471/*
472 * Extensions for Inferno to basic libc.h
473 */
474
475#define setbinmode()
476
Nt/386/bin/awk.exe+0−0

Binary file not shown.

Nt/386/bin/c2l.exe+0−0

Binary file not shown.

Nt/386/bin/cp.exe+0−0

Binary file not shown.

Nt/386/bin/data2c.exe+0−0

Binary file not shown.

Nt/386/bin/echo.exe+0−0

Binary file not shown.

Nt/386/bin/format.exe+0−0

Binary file not shown.

Nt/386/bin/gzip.exe+0−0

Binary file not shown.

Nt/386/bin/infdb.exe+0−0

Binary file not shown.

Nt/386/bin/iyacc.exe+0−0

Binary file not shown.

Nt/386/bin/mk.exe+0−0

Binary file not shown.

Nt/386/bin/mkdir.exe+0−0

Binary file not shown.

Nt/386/bin/mkext.exe+0−0

Binary file not shown.

Nt/386/bin/mv.exe+0−0

Binary file not shown.

Nt/386/bin/rcsh.exe+0−0

Binary file not shown.

Nt/386/bin/rm.exe+0−0

Binary file not shown.

Nt/386/bin/sed.exe+0−0

Binary file not shown.

Nt/386/bin/test.exe+0−0

Binary file not shown.

Nt/386/bin/tr.exe+0−0

Binary file not shown.

Nt/386/include/emu.h+24−0
@@ -0,0 +1,24 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16extern void sleep(int);
17
18/* Set up private thread space */
19extern __declspec(thread) Proc* up;
20#define Sleep NTsleep
21
22typedef jmp_buf osjmpbuf;
23#define ossetjmp(buf) setjmp(buf)
24
Nt/386/include/lib9.h+485−0
@@ -0,0 +1,485 @@
1#define _POSIX_SOURCE
2#include <stdlib.h>
3#include <stdarg.h>
4#include <errno.h>
5#include <string.h>
6#include "math.h"
7#include <fcntl.h>
8#include <setjmp.h>
9#include <float.h>
10#include <time.h>
11#include <process.h>
12#include <io.h>
13#include <direct.h>
14
15#define getwd infgetwd
16
17/* do-it-yourself isinf and isnan */
18#ifndef isnan
19#define isnan(x) _isnan(x)
20#endif
21#ifndef isinf
22#define isinf(x) (!_finite(x))
23#endif
24
25#ifndef EMU
26typedef struct Proc Proc;
27#endif
28
29/*
30 * math module dtoa
31 */
32#define __LITTLE_ENDIAN
33
34 /* there must be a Win32 header macro for endian-ness!!! */
35
36/*
37 * disable various silly warnings
38 * 4018 signed/unsigned comparison
39 * 4245 signed/unsigned conversion
40 * 4244 long to char conversion
41 * 4068 unknown pragma
42 * 4090 different volatile quals
43 * 4554 operator precedence
44 * 4146 unary - on unsigned type
45 * 4996 `deprecated' functions: they often suggest non-portable replacements
46 */
47#pragma warning( disable : 4305 4244 4102 4761 4018 4245 4244 4068 4090 4554 4146 4996)
48
49#define nil ((void*)0)
50
51typedef unsigned char uchar;
52typedef unsigned int uint;
53typedef unsigned long ulong;
54typedef signed char schar;
55typedef unsigned short ushort;
56typedef unsigned short Rune;
57typedef __int64 vlong;
58typedef unsigned __int64 uvlong;
59typedef unsigned int u32int;
60typedef uvlong u64int;
61
62typedef unsigned int mpdigit; /* for /sys/include/mp.h */
63typedef unsigned short u16int;
64typedef unsigned char u8int;
65typedef unsigned long uintptr;
66
67typedef signed char int8;
68typedef unsigned char uint8;
69typedef short int16;
70typedef unsigned short uint16;
71typedef int int32;
72typedef unsigned int uint32;
73typedef long long int64;
74typedef unsigned long long uint64;
75
76#define USED(x) if(x){}else{}
77#define SET(x)
78
79#undef nelem
80#define nelem(x) (sizeof(x)/sizeof((x)[0]))
81#undef offsetof
82#define offsetof(s, m) (ulong)(&(((s*)0)->m))
83#undef assert
84#define assert(x) if(x){}else _assert("x")
85
86/*
87 * most mem and string routines are declared by ANSI/POSIX files above
88 */
89
90extern char* strecpy(char*, char*, char*);
91extern char* strdup(const char*);
92extern int cistrncmp(char*, char*, int);
93extern int cistrcmp(char*, char*);
94extern char* cistrstr(char*, char*);
95extern int tokenize(char*, char**, int);
96extern vlong strtoll(const char*, char**, int);
97#define qsort infqsort
98extern void qsort(void*, long, long, int (*)(void*, void*));
99extern uvlong strtoull(const char*, char**, int);
100
101enum
102{
103 UTFmax = 3, /* maximum bytes per rune */
104 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
105 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
106 Runeerror = 0x80 /* decoding error in UTF */
107};
108
109/*
110 * rune routines
111 */
112extern int runetochar(char*, Rune*);
113extern int chartorune(Rune*, char*);
114extern int runelen(long);
115extern int runenlen(Rune*, int);
116extern int fullrune(char*, int);
117extern int utflen(char*);
118extern int utfnlen(char*, long);
119extern char* utfrune(char*, long);
120extern char* utfrrune(char*, long);
121extern char* utfutf(char*, char*);
122extern char* utfecpy(char*, char*, char*);
123
124extern Rune* runestrcat(Rune*, Rune*);
125extern Rune* runestrchr(Rune*, Rune);
126extern int runestrcmp(Rune*, Rune*);
127extern Rune* runestrcpy(Rune*, Rune*);
128extern Rune* runestrncpy(Rune*, Rune*, long);
129extern Rune* runestrecpy(Rune*, Rune*, Rune*);
130extern Rune* runestrdup(Rune*);
131extern Rune* runestrncat(Rune*, Rune*, long);
132extern int runestrncmp(Rune*, Rune*, long);
133extern Rune* runestrrchr(Rune*, Rune);
134extern long runestrlen(Rune*);
135extern Rune* runestrstr(Rune*, Rune*);
136
137extern Rune tolowerrune(Rune);
138extern Rune totitlerune(Rune);
139extern Rune toupperrune(Rune);
140extern int isalpharune(Rune);
141extern int islowerrune(Rune);
142extern int isspacerune(Rune);
143extern int istitlerune(Rune);
144extern int isupperrune(Rune);
145
146/*
147 * malloc
148 */
149extern void* malloc(size_t);
150extern void* mallocz(ulong, int);
151extern void free(void*);
152extern ulong msize(void*);
153extern void* calloc(size_t, size_t);
154extern void* realloc(void*, size_t);
155extern void setmalloctag(void*, ulong);
156extern void setrealloctag(void*, ulong);
157extern ulong getmalloctag(void*);
158extern ulong getrealloctag(void*);
159extern void* malloctopoolblock(void*);
160
161/*
162 * print routines
163 */
164typedef struct Fmt Fmt;
165struct Fmt{
166 uchar runes; /* output buffer is runes or chars? */
167 void *start; /* of buffer */
168 void *to; /* current place in the buffer */
169 void *stop; /* end of the buffer; overwritten if flush fails */
170 int (*flush)(Fmt *); /* called when to == stop */
171 void *farg; /* to make flush a closure */
172 int nfmt; /* num chars formatted so far */
173 va_list args; /* args passed to dofmt */
174 int r; /* % format Rune */
175 int width;
176 int prec;
177 ulong flags;
178};
179
180enum{
181 FmtWidth = 1,
182 FmtLeft = FmtWidth << 1,
183 FmtPrec = FmtLeft << 1,
184 FmtSharp = FmtPrec << 1,
185 FmtSpace = FmtSharp << 1,
186 FmtSign = FmtSpace << 1,
187 FmtZero = FmtSign << 1,
188 FmtUnsigned = FmtZero << 1,
189 FmtShort = FmtUnsigned << 1,
190 FmtLong = FmtShort << 1,
191 FmtVLong = FmtLong << 1,
192 FmtComma = FmtVLong << 1,
193 FmtByte = FmtComma << 1,
194
195 FmtFlag = FmtByte << 1
196};
197
198extern int print(char*, ...);
199extern char* seprint(char*, char*, char*, ...);
200extern char* vseprint(char*, char*, char*, va_list);
201extern int snprint(char*, int, char*, ...);
202extern int vsnprint(char*, int, char*, va_list);
203extern char* smprint(char*, ...);
204extern char* vsmprint(char*, va_list);
205extern int sprint(char*, char*, ...);
206extern int fprint(int, char*, ...);
207extern int vfprint(int, char*, va_list);
208
209extern int runesprint(Rune*, char*, ...);
210extern int runesnprint(Rune*, int, char*, ...);
211extern int runevsnprint(Rune*, int, char*, va_list);
212extern Rune* runeseprint(Rune*, Rune*, char*, ...);
213extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
214extern Rune* runesmprint(char*, ...);
215extern Rune* runevsmprint(char*, va_list);
216
217extern int fmtfdinit(Fmt*, int, char*, int);
218extern int fmtfdflush(Fmt*);
219extern int fmtstrinit(Fmt*);
220extern char* fmtstrflush(Fmt*);
221extern int runefmtstrinit(Fmt*);
222extern Rune* runefmtstrflush(Fmt*);
223
224extern int fmtinstall(int, int (*)(Fmt*));
225extern int dofmt(Fmt*, char*);
226extern int dorfmt(Fmt*, Rune*);
227extern int fmtprint(Fmt*, char*, ...);
228extern int fmtvprint(Fmt*, char*, va_list);
229extern int fmtrune(Fmt*, int);
230extern int fmtstrcpy(Fmt*, char*);
231extern int fmtrunestrcpy(Fmt*, Rune*);
232/*
233 * error string for %r
234 * supplied on per os basis, not part of fmt library
235 */
236extern int errfmt(Fmt *f);
237
238/*
239 * quoted strings
240 */
241extern char *unquotestrdup(char*);
242extern Rune *unquoterunestrdup(Rune*);
243extern char *quotestrdup(char*);
244extern Rune *quoterunestrdup(Rune*);
245extern int quotestrfmt(Fmt*);
246extern int quoterunestrfmt(Fmt*);
247extern void quotefmtinstall(void);
248extern int (*doquote)(int);
249
250/*
251 * random number
252 */
253extern ulong truerand(void);
254extern ulong ntruerand(ulong);
255
256/*
257 * math
258 */
259extern int isNaN(double);
260extern int isInf(double, int);
261
262#define PIO2 1.570796326794896619231e0
263#define PI (PIO2+PIO2)
264
265/*
266 * Time-of-day
267 */
268
269typedef struct Tm Tm;
270struct Tm {
271 int sec;
272 int min;
273 int hour;
274 int mday;
275 int mon;
276 int year;
277 int wday;
278 int yday;
279 char zone[4];
280 int tzoff;
281};
282extern vlong osnsec(void);
283#define nsec osnsec
284
285/*
286 * one-of-a-kind
287 */
288extern void _assert(char*);
289extern double charstod(int(*)(void*), void*);
290extern char* cleanname(char*);
291extern uintptr getcallerpc(void*);
292extern int getfields(char*, char**, int, int, char*);
293extern char* getuser(void);
294extern char* getuser(void);
295extern char* getwd(char*, int);
296extern char* getwd(char*, int);
297extern double ipow10(int);
298extern double pow10(int);
299extern void sysfatal(char*, ...);
300extern int dec64(uchar*, int, char*, int);
301extern int enc64(char*, int, uchar*, int);
302extern int dec32(uchar*, int, char*, int);
303extern int enc32(char*, int, uchar*, int);
304extern int dec16(uchar*, int, char*, int);
305extern int enc16(char*, int, uchar*, int);
306extern int encodefmt(Fmt*);
307
308/*
309 * synchronization
310 */
311typedef
312struct Lock {
313 int val;
314 int pid;
315} Lock;
316
317extern int _tas(int*);
318
319extern void lock(Lock*);
320extern void unlock(Lock*);
321extern int canlock(Lock*);
322
323typedef struct QLock QLock;
324struct QLock
325{
326 Lock use; /* to access Qlock structure */
327 Proc *head; /* next process waiting for object */
328 Proc *tail; /* last process waiting for object */
329 int locked; /* flag */
330};
331
332extern void qlock(QLock*);
333extern void qunlock(QLock*);
334extern int canqlock(QLock*);
335extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
336
337typedef
338struct RWLock
339{
340 Lock l; /* Lock modify lock */
341 QLock x; /* Mutual exclusion lock */
342 QLock k; /* Lock for waiting writers */
343 int readers; /* Count of readers in lock */
344} RWLock;
345
346extern int canrlock(RWLock*);
347extern int canwlock(RWLock*);
348extern void rlock(RWLock*);
349extern void runlock(RWLock*);
350extern void wlock(RWLock*);
351extern void wunlock(RWLock*);
352
353/*
354 * network dialing
355 */
356#define NETPATHLEN 40
357
358/*
359 * system calls
360 *
361 */
362#define STATMAX 65535U /* max length of machine-independent stat structure */
363#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
364#define ERRMAX 128 /* max length of error string */
365
366#define MORDER 0x0003 /* mask for bits defining order of mounting */
367#define MREPL 0x0000 /* mount replaces object */
368#define MBEFORE 0x0001 /* mount goes before others in union directory */
369#define MAFTER 0x0002 /* mount goes after others in union directory */
370#define MCREATE 0x0004 /* permit creation in mounted directory */
371#define MCACHE 0x0010 /* cache some data */
372#define MMASK 0x0017 /* all bits on */
373
374#define OREAD 0 /* open for read */
375#define OWRITE 1 /* write */
376#define ORDWR 2 /* read and write */
377#define OEXEC 3 /* execute, == read but check execute permission */
378#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
379#define OCEXEC 32 /* or'ed in, close on exec */
380#define ORCLOSE 64 /* or'ed in, remove on close */
381#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
382
383#define AEXIST 0 /* accessible: exists */
384#define AEXEC 1 /* execute access */
385#define AWRITE 2 /* write access */
386#define AREAD 4 /* read access */
387
388/* bits in Qid.type */
389#define QTDIR 0x80 /* type bit for directories */
390#define QTAPPEND 0x40 /* type bit for append only files */
391#define QTEXCL 0x20 /* type bit for exclusive use files */
392#define QTMOUNT 0x10 /* type bit for mounted channel */
393#define QTAUTH 0x08 /* type bit for authentication file */
394#define QTFILE 0x00 /* plain file */
395
396/* bits in Dir.mode */
397#define DMDIR 0x80000000 /* mode bit for directories */
398#define DMAPPEND 0x40000000 /* mode bit for append only files */
399#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
400#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
401#define DMAUTH 0x08000000 /* mode bit for authentication file */
402#define DMREAD 0x4 /* mode bit for read permission */
403#define DMWRITE 0x2 /* mode bit for write permission */
404#define DMEXEC 0x1 /* mode bit for execute permission */
405
406typedef
407struct Qid
408{
409 uvlong path;
410 ulong vers;
411 uchar type;
412} Qid;
413
414typedef
415struct Dir {
416 /* system-modified data */
417 ushort type; /* server type */
418 uint dev; /* server subtype */
419 /* file data */
420 Qid qid; /* unique id from server */
421 ulong mode; /* permissions */
422 ulong atime; /* last read time */
423 ulong mtime; /* last write time */
424 vlong length; /* file length */
425 char *name; /* last element of path */
426 char *uid; /* owner name */
427 char *gid; /* group name */
428 char *muid; /* last modifier name */
429} Dir;
430
431extern Dir* dirstat(char*);
432extern Dir* dirfstat(int);
433extern int dirwstat(char*, Dir*);
434extern int dirfwstat(int, Dir*);
435extern long dirread(int, Dir**);
436extern void nulldir(Dir*);
437extern long dirreadall(int, Dir**);
438
439typedef
440struct Waitmsg
441{
442 int pid; /* of loved one */
443 ulong time[3]; /* of loved one & descendants */
444 char *msg;
445} Waitmsg;
446
447extern void _exits(char*);
448
449extern void exits(char*);
450extern int create(char*, int, int);
451extern int errstr(char*, uint);
452
453extern long readn(int, void*, long);
454extern void rerrstr(char*, uint);
455extern vlong seek(int, vlong, int);
456extern void werrstr(char*, ...);
457
458extern char *argv0;
459#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
460 argv[0] && argv[0][0]=='-' && argv[0][1];\
461 argc--, argv++) {\
462 char *_args, *_argt;\
463 Rune _argc;\
464 _args = &argv[0][1];\
465 if(_args[0]=='-' && _args[1]==0){\
466 argc--; argv++; break;\
467 }\
468 _argc = 0;\
469 while(*_args && (_args += chartorune(&_argc, _args)))\
470 switch(_argc)
471#define ARGEND (_argt=0);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
472#define ARGF() (_argt=_args, _args="",\
473 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
474#define EARGF(x) (_argt=_args, _args="",\
475 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
476
477#define ARGC() _argc
478
479/*
480 * Extensions for Inferno to basic libc.h
481 */
482
483extern void setbinmode(void);
484extern void* sbrk(int);
485
OpenBSD/386/include/emu.h+30−0
@@ -0,0 +1,30 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7/*
8 * This structure must agree with FPsave and FPrestore asm routines
9 */
10typedef struct FPU FPU;
11struct FPU
12{
13 uchar env[28];
14};
15
16#define KSTACK (32 * 1024)
17
18static __inline Proc *getup(void) {
19 Proc *p;
20 __asm__( "movl %%esp, %%eax\n\t"
21 : "=a" (p)
22 );
23 return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
24};
25
26#define up (getup())
27
28typedef sigjmp_buf osjmpbuf;
29#define ossetjmp(buf) sigsetjmp(buf, 1)
30
OpenBSD/386/include/fpuctl.h+76−0
@@ -0,0 +1,76 @@
1/*
2 * 386 fpu support
3 * Mimic Plan9 floating point support
4 */
5
6static void
7setfcr(ulong fcr)
8{
9 __asm__( "xorb $0x3f, %%al\n\t"
10 "pushw %%ax\n\t"
11 "fwait\n\t"
12 "fldcw (%%esp)\n\t"
13 "popw %%ax\n\t"
14 : /* no output */
15 : "al" (fcr)
16 );
17}
18
19static ulong
20getfcr(void)
21{
22 ulong fcr = 0;
23
24 __asm__( "pushl %%eax\n\t"
25 "fwait\n\t"
26 "fstcw (%%esp)\n\t"
27 "popl %%eax\n\t"
28 "xorb $0x3f, %%al\n\t"
29 : "=a" (fcr)
30 : "eax" (fcr)
31 );
32 return fcr;
33}
34
35static ulong
36getfsr(void)
37{
38 ulong fsr = -1;
39
40 __asm__( "fwait\n\t"
41 "fstsw (%%eax)\n\t"
42 "movl (%%eax), %%eax\n\t"
43 "andl $0xffff, %%eax\n\t"
44 : "=a" (fsr)
45 : "eax" (&fsr)
46 );
47 return fsr;
48}
49
50static void
51setfsr(ulong fsr)
52{
53 __asm__("fclex\n\t");
54}
55
56/* FCR */
57#define FPINEX (1<<5)
58#define FPUNFL ((1<<4)|(1<<1))
59#define FPOVFL (1<<3)
60#define FPZDIV (1<<2)
61#define FPINVAL (1<<0)
62#define FPRNR (0<<10)
63#define FPRZ (3<<10)
64#define FPRPINF (2<<10)
65#define FPRNINF (1<<10)
66#define FPRMASK (3<<10)
67#define FPPEXT (3<<8)
68#define FPPSGL (0<<8)
69#define FPPDBL (2<<8)
70#define FPPMASK (3<<8)
71/* FSR */
72#define FPAINEX FPINEX
73#define FPAOVFL FPOVFL
74#define FPAUNFL FPUNFL
75#define FPAZDIV FPZDIV
76#define FPAINVAL FPINVAL
OpenBSD/386/include/lib9.h+473−0
@@ -0,0 +1,473 @@
1/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
2#ifndef _BSD_SOURCE
3#define _BSD_SOURCE
4#endif
5/* these aren't really needed because OpenBSD does the right thing and makes off_t 64 bits, full stop */
6#define _LARGEFILE64_SOURCE 1
7#define _FILE_OFFSET_BITS 64
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <stdlib.h>
11#include <stdarg.h>
12#include <unistd.h>
13#include <errno.h>
14#include <string.h>
15#include "math.h"
16#include <fcntl.h>
17#include <setjmp.h>
18#include <float.h>
19#include <time.h>
20
21#define getwd infgetwd
22
23#define round infround
24#define fmax inffmax
25#define log2 inflog2
26
27#ifndef EMU
28typedef struct Proc Proc;
29#endif
30
31/*
32 * math module dtoa
33 */
34#define __LITTLE_ENDIAN
35
36#define nil ((void*)0)
37
38typedef unsigned char uchar;
39typedef signed char schar;
40//typedef unsigned long ulong;
41typedef unsigned short Rune;
42typedef long long int vlong;
43typedef unsigned long long int uvlong;
44typedef unsigned int u32int;
45typedef uvlong u64int;
46
47typedef unsigned int mpdigit; /* for /sys/include/mp.h */
48typedef unsigned short u16int;
49typedef unsigned char u8int;
50typedef unsigned long uintptr;
51
52typedef signed char int8;
53typedef unsigned char uint8;
54typedef short int16;
55typedef unsigned short uint16;
56typedef int int32;
57typedef unsigned int uint32;
58typedef long long int64;
59typedef unsigned long long uint64;
60
61#define USED(x) if(x){}else{}
62#define SET(x)
63
64#undef nelem
65#define nelem(x) (sizeof(x)/sizeof((x)[0]))
66#undef offsetof
67#define offsetof(s, m) (ulong)(&(((s*)0)->m))
68#undef assert
69#define assert(x) if(x){}else _assert("x")
70
71/*
72 * most mem and string routines are declared by ANSI/POSIX files above
73 */
74
75extern char* strecpy(char*, char*, char*);
76extern char* strdup(const char*);
77extern int cistrncmp(char*, char*, int);
78extern int cistrcmp(char*, char*);
79extern char* cistrstr(char*, char*);
80extern int tokenize(char*, char**, int);
81
82enum
83{
84 UTFmax = 3, /* maximum bytes per rune */
85 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
86 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
87 Runeerror = 0x80 /* decoding error in UTF */
88};
89
90/*
91 * rune routines
92 */
93extern int runetochar(char*, Rune*);
94extern int chartorune(Rune*, char*);
95extern int runelen(long);
96extern int runenlen(Rune*, int);
97extern int fullrune(char*, int);
98extern int utflen(char*);
99extern int utfnlen(char*, long);
100extern char* utfrune(char*, long);
101extern char* utfrrune(char*, long);
102extern char* utfutf(char*, char*);
103extern char* utfecpy(char*, char*, char*);
104
105extern Rune* runestrcat(Rune*, Rune*);
106extern Rune* runestrchr(Rune*, Rune);
107extern int runestrcmp(Rune*, Rune*);
108extern Rune* runestrcpy(Rune*, Rune*);
109extern Rune* runestrncpy(Rune*, Rune*, long);
110extern Rune* runestrecpy(Rune*, Rune*, Rune*);
111extern Rune* runestrdup(Rune*);
112extern Rune* runestrncat(Rune*, Rune*, long);
113extern int runestrncmp(Rune*, Rune*, long);
114extern Rune* runestrrchr(Rune*, Rune);
115extern long runestrlen(Rune*);
116extern Rune* runestrstr(Rune*, Rune*);
117
118extern Rune tolowerrune(Rune);
119extern Rune totitlerune(Rune);
120extern Rune toupperrune(Rune);
121extern int isalpharune(Rune);
122extern int islowerrune(Rune);
123extern int isspacerune(Rune);
124extern int istitlerune(Rune);
125extern int isupperrune(Rune);
126
127/*
128 * malloc
129 */
130extern void* malloc(size_t);
131extern void* mallocz(ulong, int);
132extern void free(void*);
133extern ulong msize(void*);
134extern void* calloc(size_t, size_t);
135extern void* realloc(void*, size_t);
136extern void setmalloctag(void*, ulong);
137extern void setrealloctag(void*, ulong);
138extern ulong getmalloctag(void*);
139extern ulong getrealloctag(void*);
140extern void* malloctopoolblock(void*);
141
142/*
143 * print routines
144 */
145typedef struct Fmt Fmt;
146struct Fmt{
147 uchar runes; /* output buffer is runes or chars? */
148 void *start; /* of buffer */
149 void *to; /* current place in the buffer */
150 void *stop; /* end of the buffer; overwritten if flush fails */
151 int (*flush)(Fmt *); /* called when to == stop */
152 void *farg; /* to make flush a closure */
153 int nfmt; /* num chars formatted so far */
154 va_list args; /* args passed to dofmt */
155 int r; /* % format Rune */
156 int width;
157 int prec;
158 ulong flags;
159};
160
161enum{
162 FmtWidth = 1,
163 FmtLeft = FmtWidth << 1,
164 FmtPrec = FmtLeft << 1,
165 FmtSharp = FmtPrec << 1,
166 FmtSpace = FmtSharp << 1,
167 FmtSign = FmtSpace << 1,
168 FmtZero = FmtSign << 1,
169 FmtUnsigned = FmtZero << 1,
170 FmtShort = FmtUnsigned << 1,
171 FmtLong = FmtShort << 1,
172 FmtVLong = FmtLong << 1,
173 FmtComma = FmtVLong << 1,
174 FmtByte = FmtComma << 1,
175
176 FmtFlag = FmtByte << 1
177};
178
179extern int print(char*, ...);
180extern char* seprint(char*, char*, char*, ...);
181extern char* vseprint(char*, char*, char*, va_list);
182extern int snprint(char*, int, char*, ...);
183extern int vsnprint(char*, int, char*, va_list);
184extern char* smprint(char*, ...);
185extern char* vsmprint(char*, va_list);
186extern int sprint(char*, char*, ...);
187extern int fprint(int, char*, ...);
188extern int vfprint(int, char*, va_list);
189
190extern int runesprint(Rune*, char*, ...);
191extern int runesnprint(Rune*, int, char*, ...);
192extern int runevsnprint(Rune*, int, char*, va_list);
193extern Rune* runeseprint(Rune*, Rune*, char*, ...);
194extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
195extern Rune* runesmprint(char*, ...);
196extern Rune* runevsmprint(char*, va_list);
197
198extern int fmtfdinit(Fmt*, int, char*, int);
199extern int fmtfdflush(Fmt*);
200extern int fmtstrinit(Fmt*);
201extern char* fmtstrflush(Fmt*);
202extern int runefmtstrinit(Fmt*);
203extern Rune* runefmtstrflush(Fmt*);
204
205extern int fmtinstall(int, int (*)(Fmt*));
206extern int dofmt(Fmt*, char*);
207extern int dorfmt(Fmt*, Rune*);
208extern int fmtprint(Fmt*, char*, ...);
209extern int fmtvprint(Fmt*, char*, va_list);
210extern int fmtrune(Fmt*, int);
211extern int fmtstrcpy(Fmt*, char*);
212extern int fmtrunestrcpy(Fmt*, Rune*);
213/*
214 * error string for %r
215 * supplied on per os basis, not part of fmt library
216 */
217extern int errfmt(Fmt *f);
218
219/*
220 * quoted strings
221 */
222extern char *unquotestrdup(char*);
223extern Rune *unquoterunestrdup(Rune*);
224extern char *quotestrdup(char*);
225extern Rune *quoterunestrdup(Rune*);
226extern int quotestrfmt(Fmt*);
227extern int quoterunestrfmt(Fmt*);
228extern void quotefmtinstall(void);
229extern int (*doquote)(int);
230
231/*
232 * random number
233 */
234extern int nrand(int);
235extern ulong truerand(void);
236extern ulong ntruerand(ulong);
237
238/*
239 * math
240 */
241extern int isNaN(double);
242extern int isInf(double, int);
243extern double pow(double, double);
244
245/*
246 * Time-of-day
247 */
248
249typedef struct Tm Tm;
250struct Tm {
251 int sec;
252 int min;
253 int hour;
254 int mday;
255 int mon;
256 int year;
257 int wday;
258 int yday;
259 char zone[4];
260 int tzoff;
261};
262extern vlong osnsec(void);
263#define nsec osnsec
264
265/*
266 * one-of-a-kind
267 */
268extern void _assert(char*);
269extern double charstod(int(*)(void*), void*);
270extern char* cleanname(char*);
271extern double frexp(double, int*);
272extern uintptr getcallerpc(void*);
273extern int getfields(char*, char**, int, int, char*);
274extern char* getuser(void);
275extern char* getwd(char*, int);
276extern double ipow10(int);
277extern double ldexp(double, int);
278extern double modf(double, double*);
279#define pow10 infpow10
280extern double pow10(int);
281extern vlong strtoll(const char*, char**, int);
282#define qsort infqsort
283extern void qsort(void*, long, long, int (*)(void*, void*));
284extern uvlong strtoull(const char*, char**, int);
285extern void sysfatal(char*, ...);
286extern int dec64(uchar*, int, char*, int);
287extern int enc64(char*, int, uchar*, int);
288extern int dec32(uchar*, int, char*, int);
289extern int enc32(char*, int, uchar*, int);
290extern int dec16(uchar*, int, char*, int);
291extern int enc16(char*, int, uchar*, int);
292extern int encodefmt(Fmt*);
293
294/*
295 * synchronization
296 */
297typedef
298struct Lock {
299 int val;
300 int pid;
301} Lock;
302
303extern int _tas(int*);
304
305extern void lock(Lock*);
306extern void unlock(Lock*);
307extern int canlock(Lock*);
308
309typedef struct QLock QLock;
310struct QLock
311{
312 Lock use; /* to access Qlock structure */
313 Proc *head; /* next process waiting for object */
314 Proc *tail; /* last process waiting for object */
315 int locked; /* flag */
316};
317
318extern void qlock(QLock*);
319extern void qunlock(QLock*);
320extern int canqlock(QLock*);
321extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
322
323typedef
324struct RWLock
325{
326 Lock l; /* Lock modify lock */
327 QLock x; /* Mutual exclusion lock */
328 QLock k; /* Lock for waiting writers */
329 int readers; /* Count of readers in lock */
330} RWLock;
331
332extern int canrlock(RWLock*);
333extern int canwlock(RWLock*);
334extern void rlock(RWLock*);
335extern void runlock(RWLock*);
336extern void wlock(RWLock*);
337extern void wunlock(RWLock*);
338
339/*
340 * network dialing
341 */
342#define NETPATHLEN 40
343
344/*
345 * system calls
346 *
347 */
348#define STATMAX 65535U /* max length of machine-independent stat structure */
349#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
350#define ERRMAX 128 /* max length of error string */
351
352#define MORDER 0x0003 /* mask for bits defining order of mounting */
353#define MREPL 0x0000 /* mount replaces object */
354#define MBEFORE 0x0001 /* mount goes before others in union directory */
355#define MAFTER 0x0002 /* mount goes after others in union directory */
356#define MCREATE 0x0004 /* permit creation in mounted directory */
357#define MCACHE 0x0010 /* cache some data */
358#define MMASK 0x0017 /* all bits on */
359
360#define OREAD 0 /* open for read */
361#define OWRITE 1 /* write */
362#define ORDWR 2 /* read and write */
363#define OEXEC 3 /* execute, == read but check execute permission */
364#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
365#define OCEXEC 32 /* or'ed in, close on exec */
366#define ORCLOSE 64 /* or'ed in, remove on close */
367#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
368
369#define AEXIST 0 /* accessible: exists */
370#define AEXEC 1 /* execute access */
371#define AWRITE 2 /* write access */
372#define AREAD 4 /* read access */
373
374/* bits in Qid.type */
375#define QTDIR 0x80 /* type bit for directories */
376#define QTAPPEND 0x40 /* type bit for append only files */
377#define QTEXCL 0x20 /* type bit for exclusive use files */
378#define QTMOUNT 0x10 /* type bit for mounted channel */
379#define QTAUTH 0x08 /* type bit for authentication file */
380#define QTFILE 0x00 /* plain file */
381
382/* bits in Dir.mode */
383#define DMDIR 0x80000000 /* mode bit for directories */
384#define DMAPPEND 0x40000000 /* mode bit for append only files */
385#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
386#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
387#define DMAUTH 0x08000000 /* mode bit for authentication file */
388#define DMREAD 0x4 /* mode bit for read permission */
389#define DMWRITE 0x2 /* mode bit for write permission */
390#define DMEXEC 0x1 /* mode bit for execute permission */
391
392typedef
393struct Qid
394{
395 uvlong path;
396 ulong vers;
397 uchar type;
398} Qid;
399
400typedef
401struct Dir {
402 /* system-modified data */
403 ushort type; /* server type */
404 uint dev; /* server subtype */
405 /* file data */
406 Qid qid; /* unique id from server */
407 ulong mode; /* permissions */
408 ulong atime; /* last read time */
409 ulong mtime; /* last write time */
410 vlong length; /* file length */
411 char *name; /* last element of path */
412 char *uid; /* owner name */
413 char *gid; /* group name */
414 char *muid; /* last modifier name */
415} Dir;
416
417extern Dir* dirstat(char*);
418extern Dir* dirfstat(int);
419extern int dirwstat(char*, Dir*);
420extern int dirfwstat(int, Dir*);
421extern long dirread(int, Dir**);
422extern void nulldir(Dir*);
423extern long dirreadall(int, Dir**);
424
425typedef
426struct Waitmsg
427{
428 int pid; /* of loved one */
429 ulong time[3]; /* of loved one & descendants */
430 char *msg;
431} Waitmsg;
432
433extern void _exits(char*);
434
435extern void exits(char*);
436extern int create(char*, int, int);
437extern int errstr(char*, uint);
438
439extern void perror(const char*);
440extern long readn(int, void*, long);
441extern int remove(const char*);
442extern void rerrstr(char*, uint);
443extern vlong seek(int, vlong, int);
444extern int segflush(void*, ulong);
445extern void werrstr(char*, ...);
446
447extern char *argv0;
448#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
449 argv[0] && argv[0][0]=='-' && argv[0][1];\
450 argc--, argv++) {\
451 char *_args, *_argt;\
452 Rune _argc;\
453 _args = &argv[0][1];\
454 if(_args[0]=='-' && _args[1]==0){\
455 argc--; argv++; break;\
456 }\
457 _argc = 0;\
458 while(*_args && (_args += chartorune(&_argc, _args)))\
459 switch(_argc)
460#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
461#define ARGF() (_argt=_args, _args="",\
462 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
463#define EARGF(x) (_argt=_args, _args="",\
464 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
465
466#define ARGC() _argc
467
468/*
469 * Extensions for Inferno to basic libc.h
470 */
471
472#define setbinmode()
473
Plan9/386/bin/data2c+0−0

Binary file not shown.

Plan9/386/include/emu.h+22−0
@@ -0,0 +1,22 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12/*
13 * This structure must agree with FPsave and FPrestore asm routines
14 */
15struct FPU
16{
17 uchar env[28];
18};
19
20typedef jmp_buf osjmpbuf;
21#define ossetjmp(buf) setjmp(buf)
22
Plan9/386/include/lib9.h+658−0
@@ -0,0 +1,658 @@
1#include <u.h>
2typedef unsigned long size_t;
3
4#define nelem(x) (sizeof(x)/sizeof((x)[0]))
5#define offsetof(s, m) (ulong)(&(((s*)0)->m))
6#define assert(x) if(x){}else _assert("x")
7
8/*
9 * mem routines
10 */
11extern void* memccpy(void*, void*, int, ulong);
12extern void* memset(void*, int, ulong);
13extern int memcmp(void*, void*, ulong);
14extern void* memcpy(void*, void*, ulong);
15extern void* memmove(void*, void*, ulong);
16extern void* memchr(void*, int, ulong);
17
18/*
19 * string routines
20 */
21extern char* strcat(char*, char*);
22extern char* strchr(char*, int);
23extern int strcmp(char*, char*);
24extern char* strcpy(char*, char*);
25extern char* strecpy(char*, char*, char*);
26extern char* strdup(char*);
27extern char* strncat(char*, char*, long);
28extern char* strncpy(char*, char*, long);
29extern int strncmp(char*, char*, long);
30extern char* strpbrk(char*, char*);
31extern char* strrchr(char*, int);
32extern char* strtok(char*, char*);
33extern long strlen(char*);
34extern long strspn(char*, char*);
35extern long strcspn(char*, char*);
36extern char* strstr(char*, char*);
37extern int cistrncmp(char*, char*, int);
38extern int cistrcmp(char*, char*);
39extern char* cistrstr(char*, char*);
40extern int tokenize(char*, char**, int);
41
42enum
43{
44 UTFmax = 3, /* maximum bytes per rune */
45 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
46 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
47 Runeerror = 0x80, /* decoding error in UTF */
48};
49
50/*
51 * rune routines
52 */
53extern int runetochar(char*, Rune*);
54extern int chartorune(Rune*, char*);
55extern int runelen(long);
56extern int runenlen(Rune*, int);
57extern int fullrune(char*, int);
58extern int utflen(char*);
59extern int utfnlen(char*, long);
60extern char* utfrune(char*, long);
61extern char* utfrrune(char*, long);
62extern char* utfutf(char*, char*);
63extern char* utfecpy(char*, char*, char*);
64
65extern Rune* runestrcat(Rune*, Rune*);
66extern Rune* runestrchr(Rune*, Rune);
67extern int runestrcmp(Rune*, Rune*);
68extern Rune* runestrcpy(Rune*, Rune*);
69extern Rune* runestrncpy(Rune*, Rune*, long);
70extern Rune* runestrecpy(Rune*, Rune*, Rune*);
71extern Rune* runestrdup(Rune*);
72extern Rune* runestrncat(Rune*, Rune*, long);
73extern int runestrncmp(Rune*, Rune*, long);
74extern Rune* runestrrchr(Rune*, Rune);
75extern long runestrlen(Rune*);
76extern Rune* runestrstr(Rune*, Rune*);
77
78extern Rune tolowerrune(Rune);
79extern Rune totitlerune(Rune);
80extern Rune toupperrune(Rune);
81extern int isalpharune(Rune);
82extern int islowerrune(Rune);
83extern int isspacerune(Rune);
84extern int istitlerune(Rune);
85extern int isupperrune(Rune);
86
87/*
88 * malloc
89 */
90extern void* malloc(ulong);
91extern void* mallocz(ulong, int);
92extern void free(void*);
93extern ulong msize(void*);
94extern void* calloc(ulong, ulong);
95extern void* realloc(void*, ulong);
96extern void setmalloctag(void*, ulong);
97extern void setrealloctag(void*, ulong);
98extern ulong getmalloctag(void*);
99extern ulong getrealloctag(void*);
100extern void* malloctopoolblock(void*);
101
102/*
103 * print routines
104 */
105typedef struct Fmt Fmt;
106struct Fmt{
107 uchar runes; /* output buffer is runes or chars? */
108 void *start; /* of buffer */
109 void *to; /* current place in the buffer */
110 void *stop; /* end of the buffer; overwritten if flush fails */
111 int (*flush)(Fmt *); /* called when to == stop */
112 void *farg; /* to make flush a closure */
113 int nfmt; /* num chars formatted so far */
114 va_list args; /* args passed to dofmt */
115 int r; /* % format Rune */
116 int width;
117 int prec;
118 ulong flags;
119};
120
121enum{
122 FmtWidth = 1,
123 FmtLeft = FmtWidth << 1,
124 FmtPrec = FmtLeft << 1,
125 FmtSharp = FmtPrec << 1,
126 FmtSpace = FmtSharp << 1,
127 FmtSign = FmtSpace << 1,
128 FmtZero = FmtSign << 1,
129 FmtUnsigned = FmtZero << 1,
130 FmtShort = FmtUnsigned << 1,
131 FmtLong = FmtShort << 1,
132 FmtVLong = FmtLong << 1,
133 FmtComma = FmtVLong << 1,
134 FmtByte = FmtComma << 1,
135
136 FmtFlag = FmtByte << 1
137};
138
139extern int print(char*, ...);
140extern char* seprint(char*, char*, char*, ...);
141extern char* vseprint(char*, char*, char*, va_list);
142extern int snprint(char*, int, char*, ...);
143extern int vsnprint(char*, int, char*, va_list);
144extern char* smprint(char*, ...);
145extern char* vsmprint(char*, va_list);
146extern int sprint(char*, char*, ...);
147extern int fprint(int, char*, ...);
148extern int vfprint(int, char*, va_list);
149
150extern int runesprint(Rune*, char*, ...);
151extern int runesnprint(Rune*, int, char*, ...);
152extern int runevsnprint(Rune*, int, char*, va_list);
153extern Rune* runeseprint(Rune*, Rune*, char*, ...);
154extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
155extern Rune* runesmprint(char*, ...);
156extern Rune* runevsmprint(char*, va_list);
157
158extern int fmtfdinit(Fmt*, int, char*, int);
159extern int fmtfdflush(Fmt*);
160extern int fmtstrinit(Fmt*);
161extern char* fmtstrflush(Fmt*);
162extern int runefmtstrinit(Fmt*);
163extern Rune* runefmtstrflush(Fmt*);
164
165#pragma varargck argpos fmtprint 2
166#pragma varargck argpos fprint 2
167#pragma varargck argpos print 1
168#pragma varargck argpos runeseprint 3
169#pragma varargck argpos runesmprint 1
170#pragma varargck argpos runesnprint 3
171#pragma varargck argpos runesprint 2
172#pragma varargck argpos seprint 3
173#pragma varargck argpos smprint 1
174#pragma varargck argpos snprint 3
175#pragma varargck argpos sprint 2
176#pragma varargck argpos vseprint 3
177#pragma varargck argpos vsnprint 3
178
179#pragma varargck type "lld" vlong
180#pragma varargck type "llx" vlong
181#pragma varargck type "lld" uvlong
182#pragma varargck type "llx" uvlong
183#pragma varargck type "ld" long
184#pragma varargck type "lx" long
185#pragma varargck type "ld" ulong
186#pragma varargck type "lx" ulong
187#pragma varargck type "d" int
188#pragma varargck type "x" int
189#pragma varargck type "c" int
190#pragma varargck type "C" int
191#pragma varargck type "d" uint
192#pragma varargck type "x" uint
193#pragma varargck type "c" uint
194#pragma varargck type "C" uint
195#pragma varargck type "f" double
196#pragma varargck type "e" double
197#pragma varargck type "g" double
198#pragma varargck type "s" char*
199#pragma varargck type "q" char*
200#pragma varargck type "S" Rune*
201#pragma varargck type "Q" Rune*
202#pragma varargck type "r" void
203#pragma varargck type "%" void
204#pragma varargck type "n" int*
205#pragma varargck type "p" void*
206#pragma varargck flag ','
207#pragma varargck type "<" void*
208#pragma varargck type "[" void*
209#pragma varargck type "H" void*
210
211extern int fmtinstall(int, int (*)(Fmt*));
212extern int dofmt(Fmt*, char*);
213extern int dorfmt(Fmt*, Rune*);
214extern int fmtprint(Fmt*, char*, ...);
215extern int fmtvprint(Fmt*, char*, va_list);
216extern int fmtrune(Fmt*, int);
217extern int fmtstrcpy(Fmt*, char*);
218extern int fmtrunestrcpy(Fmt*, Rune*);
219/*
220 * error string for %r
221 * supplied on per os basis, not part of fmt library
222 */
223extern int errfmt(Fmt *f);
224
225/*
226 * quoted strings
227 */
228extern char *unquotestrdup(char*);
229extern Rune *unquoterunestrdup(Rune*);
230extern char *quotestrdup(char*);
231extern Rune *quoterunestrdup(Rune*);
232extern int quotestrfmt(Fmt*);
233extern int quoterunestrfmt(Fmt*);
234extern void quotefmtinstall(void);
235extern int (*doquote)(int);
236
237/*
238 * random number
239 */
240extern void srand(long);
241extern int rand(void);
242extern int nrand(int);
243extern long lrand(void);
244extern long lnrand(long);
245extern double frand(void);
246extern ulong truerand(void);
247extern ulong ntruerand(ulong);
248
249/*
250 * math
251 */
252extern ulong getfcr(void);
253extern void setfsr(ulong);
254extern ulong getfsr(void);
255extern void setfcr(ulong);
256extern double NaN(void);
257extern double Inf(int);
258extern int isNaN(double);
259extern int isInf(double, int);
260
261extern double pow(double, double);
262extern double atan2(double, double);
263extern double fabs(double);
264extern double atan(double);
265extern double log(double);
266extern double log10(double);
267extern double exp(double);
268extern double floor(double);
269extern double ceil(double);
270extern double hypot(double, double);
271extern double sin(double);
272extern double cos(double);
273extern double tan(double);
274extern double asin(double);
275extern double acos(double);
276extern double sinh(double);
277extern double cosh(double);
278extern double tanh(double);
279extern double sqrt(double);
280extern double fmod(double, double);
281
282#define HUGE 3.4028234e38
283#define PIO2 1.570796326794896619231e0
284#define PI (PIO2+PIO2)
285
286/*
287 * Time-of-day
288 */
289
290typedef
291struct Tm
292{
293 int sec;
294 int min;
295 int hour;
296 int mday;
297 int mon;
298 int year;
299 int wday;
300 int yday;
301 char zone[4];
302 int tzoff;
303} Tm;
304
305extern Tm* gmtime(long);
306extern Tm* localtime(long);
307extern char* asctime(Tm*);
308extern char* ctime(long);
309extern double cputime(void);
310extern long times(long*);
311extern long tm2sec(Tm*);
312extern vlong nsec(void);
313
314/*
315 * one-of-a-kind
316 */
317enum
318{
319 PNPROC = 1,
320 PNGROUP = 2,
321};
322
323extern void _assert(char*);
324extern int abs(int);
325extern int atexit(void(*)(void));
326extern void atexitdont(void(*)(void));
327extern int atnotify(int(*)(void*, char*), int);
328extern double atof(char*);
329extern int atoi(char*);
330extern long atol(char*);
331extern double charstod(int(*)(void*), void*);
332extern char* cleanname(char*);
333extern int decrypt(void*, void*, int);
334extern int encrypt(void*, void*, int);
335extern int dec64(uchar*, int, char*, int);
336extern int enc64(char*, int, uchar*, int);
337extern int dec32(uchar*, int, char*, int);
338extern int enc32(char*, int, uchar*, int);
339extern int dec16(uchar*, int, char*, int);
340extern int enc16(char*, int, uchar*, int);
341extern int encodefmt(Fmt*);
342extern void exits(char*);
343extern double frexp(double, int*);
344extern uintptr getcallerpc(void*);
345extern char* getenv(char*);
346extern int getfields(char*, char**, int, int, char*);
347extern char* getuser(void);
348extern char* getwd(char*, int);
349extern int iounit(int);
350extern long labs(long);
351extern double ldexp(double, int);
352extern void longjmp(jmp_buf, int);
353extern char* mktemp(char*);
354extern double modf(double, double*);
355extern int netcrypt(void*, void*);
356extern void notejmp(void*, jmp_buf, int);
357extern void perror(char*);
358extern int postnote(int, int, char *);
359extern double pow10(int);
360extern double ipow10(int);
361extern int putenv(char*, char*);
362extern void qsort(void*, long, long, int (*)(void*, void*));
363extern void* sbrk(ulong);
364extern int setjmp(jmp_buf);
365extern double strtod(char*, char**);
366extern long strtol(char*, char**, int);
367extern ulong strtoul(char*, char**, int);
368extern vlong strtoll(char*, char**, int);
369extern uvlong strtoull(char*, char**, int);
370extern void sysfatal(char*, ...);
371#pragma varargck argpos sysfatal 1
372extern void syslog(int, char*, char*, ...);
373#pragma varargck argpos syslog 3
374extern long time(long*);
375extern int tolower(int);
376extern int toupper(int);
377
378/*
379 * synchronization
380 */
381typedef
382struct Lock {
383 int val;
384} Lock;
385
386extern int _tas(int*);
387
388extern void lock(Lock*);
389extern void unlock(Lock*);
390extern int canlock(Lock*);
391
392typedef struct QLp QLp;
393struct QLp
394{
395 int inuse;
396 QLp *next;
397 char state;
398};
399
400typedef
401struct QLock
402{
403 Lock lock;
404 int locked;
405 QLp *head;
406 QLp *tail;
407} QLock;
408
409extern void qlock(QLock*);
410extern void qunlock(QLock*);
411extern int canqlock(QLock*);
412extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
413
414typedef
415struct RWLock
416{
417 Lock lock;
418 int readers; /* number of readers */
419 int writer; /* number of writers */
420 QLp *head; /* list of waiting processes */
421 QLp *tail;
422} RWLock;
423
424extern int canrlock(RWLock*);
425extern int canwlock(RWLock*);
426extern void rlock(RWLock*);
427extern void runlock(RWLock*);
428extern void wlock(RWLock*);
429extern void wunlock(RWLock*);
430
431extern void** privalloc(void);
432extern void privfree(void**);
433
434/*
435 * network dialing
436 */
437#define NETPATHLEN 40
438extern int accept(int, char*);
439extern int announce(char*, char*);
440extern int dial(char*, char*, char*, int*);
441extern void setnetmtpt(char*, int, char*);
442extern int hangup(int);
443extern int listen(char*, char*);
444extern char* netmkaddr(char*, char*, char*);
445extern int reject(int, char*, char*);
446
447/*
448 * system calls
449 *
450 */
451#define STATMAX 65535U /* max length of machine-independent stat structure */
452#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
453#define ERRMAX 128 /* max length of error string */
454
455#define MORDER 0x0003 /* mask for bits defining order of mounting */
456#define MREPL 0x0000 /* mount replaces object */
457#define MBEFORE 0x0001 /* mount goes before others in union directory */
458#define MAFTER 0x0002 /* mount goes after others in union directory */
459#define MCREATE 0x0004 /* permit creation in mounted directory */
460#define MCACHE 0x0010 /* cache some data */
461#define MMASK 0x0017 /* all bits on */
462
463#define OREAD 0 /* open for read */
464#define OWRITE 1 /* write */
465#define ORDWR 2 /* read and write */
466#define OEXEC 3 /* execute, == read but check execute permission */
467#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
468#define OCEXEC 32 /* or'ed in, close on exec */
469#define ORCLOSE 64 /* or'ed in, remove on close */
470#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
471
472#define AEXIST 0 /* accessible: exists */
473#define AEXEC 1 /* execute access */
474#define AWRITE 2 /* write access */
475#define AREAD 4 /* read access */
476
477
478/* Segattch */
479#define SG_RONLY 0040 /* read only */
480#define SG_CEXEC 0100 /* detach on exec */
481
482#define NCONT 0 /* continue after note */
483#define NDFLT 1 /* terminate after note */
484#define NSAVE 2 /* clear note but hold state */
485#define NRSTR 3 /* restore saved state */
486
487/* rfork */
488enum
489{
490 RFNAMEG = (1<<0),
491 RFENVG = (1<<1),
492 RFFDG = (1<<2),
493 RFNOTEG = (1<<3),
494 RFPROC = (1<<4),
495 RFMEM = (1<<5),
496 RFNOWAIT = (1<<6),
497 RFCNAMEG = (1<<10),
498 RFCENVG = (1<<11),
499 RFCFDG = (1<<12),
500 RFREND = (1<<13),
501 RFNOMNT = (1<<14)
502};
503
504/* bits in Qid.type */
505#define QTDIR 0x80 /* type bit for directories */
506#define QTAPPEND 0x40 /* type bit for append only files */
507#define QTEXCL 0x20 /* type bit for exclusive use files */
508#define QTMOUNT 0x10 /* type bit for mounted channel */
509#define QTAUTH 0x08 /* type bit for authentication file */
510#define QTFILE 0x00 /* plain file */
511
512/* bits in Dir.mode */
513#define DMDIR 0x80000000 /* mode bit for directories */
514#define DMAPPEND 0x40000000 /* mode bit for append only files */
515#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
516#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
517#define DMAUTH 0x08000000 /* mode bit for authentication file */
518#define DMREAD 0x4 /* mode bit for read permission */
519#define DMWRITE 0x2 /* mode bit for write permission */
520#define DMEXEC 0x1 /* mode bit for execute permission */
521
522typedef
523struct Qid
524{
525 uvlong path;
526 ulong vers;
527 uchar type;
528} Qid;
529
530typedef
531struct Dir {
532 /* system-modified data */
533 ushort type; /* server type */
534 uint dev; /* server subtype */
535 /* file data */
536 Qid qid; /* unique id from server */
537 ulong mode; /* permissions */
538 ulong atime; /* last read time */
539 ulong mtime; /* last write time */
540 vlong length; /* file length */
541 char *name; /* last element of path */
542 char *uid; /* owner name */
543 char *gid; /* group name */
544 char *muid; /* last modifier name */
545} Dir;
546
547extern Dir* dirstat(char*);
548extern Dir* dirfstat(int);
549extern int dirwstat(char*, Dir*);
550extern int dirfwstat(int, Dir*);
551extern long dirread(int, Dir**);
552extern void nulldir(Dir*);
553extern long dirreadall(int, Dir**);
554
555typedef
556struct Waitmsg
557{
558 int pid; /* of loved one */
559 ulong time[3]; /* of loved one & descendants */
560 char *msg;
561} Waitmsg;
562
563typedef
564struct IOchunk
565{
566 void *addr;
567 ulong len;
568} IOchunk;
569
570extern void _exits(char*);
571
572extern void abort(void);
573extern int access(char*, int);
574extern long alarm(ulong);
575extern int await(char*, int);
576extern int bind(char*, char*, int);
577extern int brk(void*);
578extern int chdir(char*);
579extern int close(int);
580extern int create(char*, int, ulong);
581extern int dup(int, int);
582extern int errstr(char*, uint);
583extern int exec(char*, char*[]);
584extern int execl(char*, ...);
585extern int fork(void);
586extern int rfork(int);
587extern int fauth(int, char*);
588extern int fstat(int, uchar*, int);
589extern int fwstat(int, uchar*, int);
590extern int fversion(int, int, char*, int);
591extern int mount(int, int, char*, int, char*);
592extern int unmount(char*, char*);
593extern int noted(int);
594extern int notify(void(*)(void*, char*));
595extern int open(char*, int);
596extern int fd2path(int, char*, int);
597extern int pipe(int*);
598extern long pread(int, void*, long, vlong);
599extern long preadv(int, IOchunk*, int, vlong);
600extern long pwrite(int, void*, long, vlong);
601extern long pwritev(int, IOchunk*, int, vlong);
602extern long read(int, void*, long);
603extern long readn(int, void*, long);
604extern long readv(int, IOchunk*, int);
605extern int remove(char*);
606extern void* sbrk(ulong);
607extern long oseek(int, long, int);
608extern vlong seek(int, vlong, int);
609extern long segattach(int, char*, void*, ulong);
610extern int segbrk(void*, void*);
611extern int segdetach(void*);
612extern int segflush(void*, ulong);
613extern int segfree(void*, ulong);
614extern int sleep(long);
615extern int stat(char*, uchar*, int);
616extern Waitmsg* wait(void);
617extern int waitpid(void);
618extern long write(int, void*, long);
619extern long writev(int, IOchunk*, int);
620extern int wstat(char*, uchar*, int);
621extern void* rendezvous(void*, void*);
622
623extern int getpid(void);
624extern int getppid(void);
625extern void rerrstr(char*, uint);
626extern char* sysname(void);
627extern void werrstr(char*, ...);
628#pragma varargck argpos werrstr 1
629
630extern char *argv0;
631#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
632 argv[0] && argv[0][0]=='-' && argv[0][1];\
633 argc--, argv++) {\
634 char *_args, *_argt;\
635 Rune _argc;\
636 _args = &argv[0][1];\
637 if(_args[0]=='-' && _args[1]==0){\
638 argc--; argv++; break;\
639 }\
640 _argc = 0;\
641 while(*_args && (_args += chartorune(&_argc, _args)))\
642 switch(_argc)
643#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
644#define ARGF() (_argt=_args, _args="",\
645 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
646#define EARGF(x) (_argt=_args, _args="",\
647 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
648
649#define ARGC() _argc
650
651
652/*
653 * Extensions for Inferno to basic libc.h
654 */
655
656#define setbinmode()
657#define __LITTLE_ENDIAN
658
Plan9/386/include/u.h+64−0
@@ -0,0 +1,64 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<5)
24#define FPUNFL ((1<<4)|(1<<1))
25#define FPOVFL (1<<3)
26#define FPZDIV (1<<2)
27#define FPINVAL (1<<0)
28#define FPRNR (0<<10)
29#define FPRZ (3<<10)
30#define FPRPINF (2<<10)
31#define FPRNINF (1<<10)
32#define FPRMASK (3<<10)
33#define FPPEXT (3<<8)
34#define FPPSGL (0<<8)
35#define FPPDBL (2<<8)
36#define FPPMASK (3<<8)
37/* FSR */
38#define FPAINEX FPINEX
39#define FPAOVFL FPOVFL
40#define FPAUNFL FPUNFL
41#define FPAZDIV FPZDIV
42#define FPAINVAL FPINVAL
43union FPdbleword
44{
45 double x;
46 struct { /* little endian */
47 ulong lo;
48 ulong hi;
49 };
50};
51
52typedef char* va_list;
53#define va_start(list, start) list =\
54 (sizeof(start) < 4?\
55 (char*)((int*)&(start)+1):\
56 (char*)(&(start)+1))
57#define va_end(list)\
58 USED(list)
59#define va_arg(list, mode)\
60 ((sizeof(mode) == 1)?\
61 ((mode*)(list += 4))[-4]:\
62 (sizeof(mode) == 2)?\
63 ((mode*)(list += 4))[-2]:\
64 ((mode*)(list += sizeof(mode)))[-1])
Plan9/arm/bin/.dreg+0−0

Empty file added.

Plan9/arm/include/emu.h+22−0
@@ -0,0 +1,22 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12/*
13 * This structure must agree with FPsave and FPrestore asm routines
14 */
15struct FPU
16{
17 int dummy[1]; /* XXX what goes here? */
18};
19
20typedef jmp_buf osjmpbuf;
21#define ossetjmp(buf) setjmp(buf)
22
Plan9/arm/include/lib9.h+658−0
@@ -0,0 +1,658 @@
1#include <u.h>
2typedef unsigned long size_t;
3
4#define nelem(x) (sizeof(x)/sizeof((x)[0]))
5#define offsetof(s, m) (ulong)(&(((s*)0)->m))
6#define assert(x) if(x){}else _assert("x")
7
8/*
9 * mem routines
10 */
11extern void* memccpy(void*, void*, int, ulong);
12extern void* memset(void*, int, ulong);
13extern int memcmp(void*, void*, ulong);
14extern void* memcpy(void*, void*, ulong);
15extern void* memmove(void*, void*, ulong);
16extern void* memchr(void*, int, ulong);
17
18/*
19 * string routines
20 */
21extern char* strcat(char*, char*);
22extern char* strchr(char*, int);
23extern int strcmp(char*, char*);
24extern char* strcpy(char*, char*);
25extern char* strecpy(char*, char*, char*);
26extern char* strdup(char*);
27extern char* strncat(char*, char*, long);
28extern char* strncpy(char*, char*, long);
29extern int strncmp(char*, char*, long);
30extern char* strpbrk(char*, char*);
31extern char* strrchr(char*, int);
32extern char* strtok(char*, char*);
33extern long strlen(char*);
34extern long strspn(char*, char*);
35extern long strcspn(char*, char*);
36extern char* strstr(char*, char*);
37extern int cistrncmp(char*, char*, int);
38extern int cistrcmp(char*, char*);
39extern char* cistrstr(char*, char*);
40extern int tokenize(char*, char**, int);
41
42enum
43{
44 UTFmax = 3, /* maximum bytes per rune */
45 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
46 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
47 Runeerror = 0x80, /* decoding error in UTF */
48};
49
50/*
51 * rune routines
52 */
53extern int runetochar(char*, Rune*);
54extern int chartorune(Rune*, char*);
55extern int runelen(long);
56extern int runenlen(Rune*, int);
57extern int fullrune(char*, int);
58extern int utflen(char*);
59extern int utfnlen(char*, long);
60extern char* utfrune(char*, long);
61extern char* utfrrune(char*, long);
62extern char* utfutf(char*, char*);
63extern char* utfecpy(char*, char*, char*);
64
65extern Rune* runestrcat(Rune*, Rune*);
66extern Rune* runestrchr(Rune*, Rune);
67extern int runestrcmp(Rune*, Rune*);
68extern Rune* runestrcpy(Rune*, Rune*);
69extern Rune* runestrncpy(Rune*, Rune*, long);
70extern Rune* runestrecpy(Rune*, Rune*, Rune*);
71extern Rune* runestrdup(Rune*);
72extern Rune* runestrncat(Rune*, Rune*, long);
73extern int runestrncmp(Rune*, Rune*, long);
74extern Rune* runestrrchr(Rune*, Rune);
75extern long runestrlen(Rune*);
76extern Rune* runestrstr(Rune*, Rune*);
77
78extern Rune tolowerrune(Rune);
79extern Rune totitlerune(Rune);
80extern Rune toupperrune(Rune);
81extern int isalpharune(Rune);
82extern int islowerrune(Rune);
83extern int isspacerune(Rune);
84extern int istitlerune(Rune);
85extern int isupperrune(Rune);
86
87/*
88 * malloc
89 */
90extern void* malloc(ulong);
91extern void* mallocz(ulong, int);
92extern void free(void*);
93extern ulong msize(void*);
94extern void* calloc(ulong, ulong);
95extern void* realloc(void*, ulong);
96extern void setmalloctag(void*, ulong);
97extern void setrealloctag(void*, ulong);
98extern ulong getmalloctag(void*);
99extern ulong getrealloctag(void*);
100extern void* malloctopoolblock(void*);
101
102/*
103 * print routines
104 */
105typedef struct Fmt Fmt;
106struct Fmt{
107 uchar runes; /* output buffer is runes or chars? */
108 void *start; /* of buffer */
109 void *to; /* current place in the buffer */
110 void *stop; /* end of the buffer; overwritten if flush fails */
111 int (*flush)(Fmt *); /* called when to == stop */
112 void *farg; /* to make flush a closure */
113 int nfmt; /* num chars formatted so far */
114 va_list args; /* args passed to dofmt */
115 int r; /* % format Rune */
116 int width;
117 int prec;
118 ulong flags;
119};
120
121enum{
122 FmtWidth = 1,
123 FmtLeft = FmtWidth << 1,
124 FmtPrec = FmtLeft << 1,
125 FmtSharp = FmtPrec << 1,
126 FmtSpace = FmtSharp << 1,
127 FmtSign = FmtSpace << 1,
128 FmtZero = FmtSign << 1,
129 FmtUnsigned = FmtZero << 1,
130 FmtShort = FmtUnsigned << 1,
131 FmtLong = FmtShort << 1,
132 FmtVLong = FmtLong << 1,
133 FmtComma = FmtVLong << 1,
134 FmtByte = FmtComma << 1,
135
136 FmtFlag = FmtByte << 1
137};
138
139extern int print(char*, ...);
140extern char* seprint(char*, char*, char*, ...);
141extern char* vseprint(char*, char*, char*, va_list);
142extern int snprint(char*, int, char*, ...);
143extern int vsnprint(char*, int, char*, va_list);
144extern char* smprint(char*, ...);
145extern char* vsmprint(char*, va_list);
146extern int sprint(char*, char*, ...);
147extern int fprint(int, char*, ...);
148extern int vfprint(int, char*, va_list);
149
150extern int runesprint(Rune*, char*, ...);
151extern int runesnprint(Rune*, int, char*, ...);
152extern int runevsnprint(Rune*, int, char*, va_list);
153extern Rune* runeseprint(Rune*, Rune*, char*, ...);
154extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
155extern Rune* runesmprint(char*, ...);
156extern Rune* runevsmprint(char*, va_list);
157
158extern int fmtfdinit(Fmt*, int, char*, int);
159extern int fmtfdflush(Fmt*);
160extern int fmtstrinit(Fmt*);
161extern char* fmtstrflush(Fmt*);
162extern int runefmtstrinit(Fmt*);
163extern Rune* runefmtstrflush(Fmt*);
164
165#pragma varargck argpos fmtprint 2
166#pragma varargck argpos fprint 2
167#pragma varargck argpos print 1
168#pragma varargck argpos runeseprint 3
169#pragma varargck argpos runesmprint 1
170#pragma varargck argpos runesnprint 3
171#pragma varargck argpos runesprint 2
172#pragma varargck argpos seprint 3
173#pragma varargck argpos smprint 1
174#pragma varargck argpos snprint 3
175#pragma varargck argpos sprint 2
176#pragma varargck argpos vseprint 3
177#pragma varargck argpos vsnprint 3
178
179#pragma varargck type "lld" vlong
180#pragma varargck type "llx" vlong
181#pragma varargck type "lld" uvlong
182#pragma varargck type "llx" uvlong
183#pragma varargck type "ld" long
184#pragma varargck type "lx" long
185#pragma varargck type "ld" ulong
186#pragma varargck type "lx" ulong
187#pragma varargck type "d" int
188#pragma varargck type "x" int
189#pragma varargck type "c" int
190#pragma varargck type "C" int
191#pragma varargck type "d" uint
192#pragma varargck type "x" uint
193#pragma varargck type "c" uint
194#pragma varargck type "C" uint
195#pragma varargck type "f" double
196#pragma varargck type "e" double
197#pragma varargck type "g" double
198#pragma varargck type "s" char*
199#pragma varargck type "q" char*
200#pragma varargck type "S" Rune*
201#pragma varargck type "Q" Rune*
202#pragma varargck type "r" void
203#pragma varargck type "%" void
204#pragma varargck type "n" int*
205#pragma varargck type "p" void*
206#pragma varargck flag ','
207#pragma varargck type "<" void*
208#pragma varargck type "[" void*
209#pragma varargck type "H" void*
210
211extern int fmtinstall(int, int (*)(Fmt*));
212extern int dofmt(Fmt*, char*);
213extern int dorfmt(Fmt*, Rune*);
214extern int fmtprint(Fmt*, char*, ...);
215extern int fmtvprint(Fmt*, char*, va_list);
216extern int fmtrune(Fmt*, int);
217extern int fmtstrcpy(Fmt*, char*);
218extern int fmtrunestrcpy(Fmt*, Rune*);
219/*
220 * error string for %r
221 * supplied on per os basis, not part of fmt library
222 */
223extern int errfmt(Fmt *f);
224
225/*
226 * quoted strings
227 */
228extern char *unquotestrdup(char*);
229extern Rune *unquoterunestrdup(Rune*);
230extern char *quotestrdup(char*);
231extern Rune *quoterunestrdup(Rune*);
232extern int quotestrfmt(Fmt*);
233extern int quoterunestrfmt(Fmt*);
234extern void quotefmtinstall(void);
235extern int (*doquote)(int);
236
237/*
238 * random number
239 */
240extern void srand(long);
241extern int rand(void);
242extern int nrand(int);
243extern long lrand(void);
244extern long lnrand(long);
245extern double frand(void);
246extern ulong truerand(void);
247extern ulong ntruerand(ulong);
248
249/*
250 * math
251 */
252extern ulong getfcr(void);
253extern void setfsr(ulong);
254extern ulong getfsr(void);
255extern void setfcr(ulong);
256extern double NaN(void);
257extern double Inf(int);
258extern int isNaN(double);
259extern int isInf(double, int);
260
261extern double pow(double, double);
262extern double atan2(double, double);
263extern double fabs(double);
264extern double atan(double);
265extern double log(double);
266extern double log10(double);
267extern double exp(double);
268extern double floor(double);
269extern double ceil(double);
270extern double hypot(double, double);
271extern double sin(double);
272extern double cos(double);
273extern double tan(double);
274extern double asin(double);
275extern double acos(double);
276extern double sinh(double);
277extern double cosh(double);
278extern double tanh(double);
279extern double sqrt(double);
280extern double fmod(double, double);
281
282#define HUGE 3.4028234e38
283#define PIO2 1.570796326794896619231e0
284#define PI (PIO2+PIO2)
285
286/*
287 * Time-of-day
288 */
289
290typedef
291struct Tm
292{
293 int sec;
294 int min;
295 int hour;
296 int mday;
297 int mon;
298 int year;
299 int wday;
300 int yday;
301 char zone[4];
302 int tzoff;
303} Tm;
304
305extern Tm* gmtime(long);
306extern Tm* localtime(long);
307extern char* asctime(Tm*);
308extern char* ctime(long);
309extern double cputime(void);
310extern long times(long*);
311extern long tm2sec(Tm*);
312extern vlong nsec(void);
313
314/*
315 * one-of-a-kind
316 */
317enum
318{
319 PNPROC = 1,
320 PNGROUP = 2,
321};
322
323extern void _assert(char*);
324extern int abs(int);
325extern int atexit(void(*)(void));
326extern void atexitdont(void(*)(void));
327extern int atnotify(int(*)(void*, char*), int);
328extern double atof(char*);
329extern int atoi(char*);
330extern long atol(char*);
331extern double charstod(int(*)(void*), void*);
332extern char* cleanname(char*);
333extern int decrypt(void*, void*, int);
334extern int encrypt(void*, void*, int);
335extern int dec64(uchar*, int, char*, int);
336extern int enc64(char*, int, uchar*, int);
337extern int dec32(uchar*, int, char*, int);
338extern int enc32(char*, int, uchar*, int);
339extern int dec16(uchar*, int, char*, int);
340extern int enc16(char*, int, uchar*, int);
341extern int encodefmt(Fmt*);
342extern void exits(char*);
343extern double frexp(double, int*);
344extern uintptr getcallerpc(void*);
345extern char* getenv(char*);
346extern int getfields(char*, char**, int, int, char*);
347extern char* getuser(void);
348extern char* getwd(char*, int);
349extern int iounit(int);
350extern long labs(long);
351extern double ldexp(double, int);
352extern void longjmp(jmp_buf, int);
353extern char* mktemp(char*);
354extern double modf(double, double*);
355extern int netcrypt(void*, void*);
356extern void notejmp(void*, jmp_buf, int);
357extern void perror(char*);
358extern int postnote(int, int, char *);
359extern double pow10(int);
360extern double ipow10(int);
361extern int putenv(char*, char*);
362extern void qsort(void*, long, long, int (*)(void*, void*));
363extern void* sbrk(ulong);
364extern int setjmp(jmp_buf);
365extern double strtod(char*, char**);
366extern long strtol(char*, char**, int);
367extern ulong strtoul(char*, char**, int);
368extern vlong strtoll(char*, char**, int);
369extern uvlong strtoull(char*, char**, int);
370extern void sysfatal(char*, ...);
371#pragma varargck argpos sysfatal 1
372extern void syslog(int, char*, char*, ...);
373#pragma varargck argpos syslog 3
374extern long time(long*);
375extern int tolower(int);
376extern int toupper(int);
377
378/*
379 * synchronization
380 */
381typedef
382struct Lock {
383 int val;
384} Lock;
385
386extern int _tas(int*);
387
388extern void lock(Lock*);
389extern void unlock(Lock*);
390extern int canlock(Lock*);
391
392typedef struct QLp QLp;
393struct QLp
394{
395 int inuse;
396 QLp *next;
397 char state;
398};
399
400typedef
401struct QLock
402{
403 Lock lock;
404 int locked;
405 QLp *head;
406 QLp *tail;
407} QLock;
408
409extern void qlock(QLock*);
410extern void qunlock(QLock*);
411extern int canqlock(QLock*);
412extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
413
414typedef
415struct RWLock
416{
417 Lock lock;
418 int readers; /* number of readers */
419 int writer; /* number of writers */
420 QLp *head; /* list of waiting processes */
421 QLp *tail;
422} RWLock;
423
424extern int canrlock(RWLock*);
425extern int canwlock(RWLock*);
426extern void rlock(RWLock*);
427extern void runlock(RWLock*);
428extern void wlock(RWLock*);
429extern void wunlock(RWLock*);
430
431extern void** privalloc(void);
432extern void privfree(void**);
433
434/*
435 * network dialing
436 */
437#define NETPATHLEN 40
438extern int accept(int, char*);
439extern int announce(char*, char*);
440extern int dial(char*, char*, char*, int*);
441extern void setnetmtpt(char*, int, char*);
442extern int hangup(int);
443extern int listen(char*, char*);
444extern char* netmkaddr(char*, char*, char*);
445extern int reject(int, char*, char*);
446
447/*
448 * system calls
449 *
450 */
451#define STATMAX 65535U /* max length of machine-independent stat structure */
452#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
453#define ERRMAX 128 /* max length of error string */
454
455#define MORDER 0x0003 /* mask for bits defining order of mounting */
456#define MREPL 0x0000 /* mount replaces object */
457#define MBEFORE 0x0001 /* mount goes before others in union directory */
458#define MAFTER 0x0002 /* mount goes after others in union directory */
459#define MCREATE 0x0004 /* permit creation in mounted directory */
460#define MCACHE 0x0010 /* cache some data */
461#define MMASK 0x0017 /* all bits on */
462
463#define OREAD 0 /* open for read */
464#define OWRITE 1 /* write */
465#define ORDWR 2 /* read and write */
466#define OEXEC 3 /* execute, == read but check execute permission */
467#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
468#define OCEXEC 32 /* or'ed in, close on exec */
469#define ORCLOSE 64 /* or'ed in, remove on close */
470#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
471
472#define AEXIST 0 /* accessible: exists */
473#define AEXEC 1 /* execute access */
474#define AWRITE 2 /* write access */
475#define AREAD 4 /* read access */
476
477
478/* Segattch */
479#define SG_RONLY 0040 /* read only */
480#define SG_CEXEC 0100 /* detach on exec */
481
482#define NCONT 0 /* continue after note */
483#define NDFLT 1 /* terminate after note */
484#define NSAVE 2 /* clear note but hold state */
485#define NRSTR 3 /* restore saved state */
486
487/* rfork */
488enum
489{
490 RFNAMEG = (1<<0),
491 RFENVG = (1<<1),
492 RFFDG = (1<<2),
493 RFNOTEG = (1<<3),
494 RFPROC = (1<<4),
495 RFMEM = (1<<5),
496 RFNOWAIT = (1<<6),
497 RFCNAMEG = (1<<10),
498 RFCENVG = (1<<11),
499 RFCFDG = (1<<12),
500 RFREND = (1<<13),
501 RFNOMNT = (1<<14)
502};
503
504/* bits in Qid.type */
505#define QTDIR 0x80 /* type bit for directories */
506#define QTAPPEND 0x40 /* type bit for append only files */
507#define QTEXCL 0x20 /* type bit for exclusive use files */
508#define QTMOUNT 0x10 /* type bit for mounted channel */
509#define QTAUTH 0x08 /* type bit for authentication file */
510#define QTFILE 0x00 /* plain file */
511
512/* bits in Dir.mode */
513#define DMDIR 0x80000000 /* mode bit for directories */
514#define DMAPPEND 0x40000000 /* mode bit for append only files */
515#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
516#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
517#define DMAUTH 0x08000000 /* mode bit for authentication file */
518#define DMREAD 0x4 /* mode bit for read permission */
519#define DMWRITE 0x2 /* mode bit for write permission */
520#define DMEXEC 0x1 /* mode bit for execute permission */
521
522typedef
523struct Qid
524{
525 uvlong path;
526 ulong vers;
527 uchar type;
528} Qid;
529
530typedef
531struct Dir {
532 /* system-modified data */
533 ushort type; /* server type */
534 uint dev; /* server subtype */
535 /* file data */
536 Qid qid; /* unique id from server */
537 ulong mode; /* permissions */
538 ulong atime; /* last read time */
539 ulong mtime; /* last write time */
540 vlong length; /* file length */
541 char *name; /* last element of path */
542 char *uid; /* owner name */
543 char *gid; /* group name */
544 char *muid; /* last modifier name */
545} Dir;
546
547extern Dir* dirstat(char*);
548extern Dir* dirfstat(int);
549extern int dirwstat(char*, Dir*);
550extern int dirfwstat(int, Dir*);
551extern long dirread(int, Dir**);
552extern void nulldir(Dir*);
553extern long dirreadall(int, Dir**);
554
555typedef
556struct Waitmsg
557{
558 int pid; /* of loved one */
559 ulong time[3]; /* of loved one & descendants */
560 char *msg;
561} Waitmsg;
562
563typedef
564struct IOchunk
565{
566 void *addr;
567 ulong len;
568} IOchunk;
569
570extern void _exits(char*);
571
572extern void abort(void);
573extern int access(char*, int);
574extern long alarm(ulong);
575extern int await(char*, int);
576extern int bind(char*, char*, int);
577extern int brk(void*);
578extern int chdir(char*);
579extern int close(int);
580extern int create(char*, int, ulong);
581extern int dup(int, int);
582extern int errstr(char*, uint);
583extern int exec(char*, char*[]);
584extern int execl(char*, ...);
585extern int fork(void);
586extern int rfork(int);
587extern int fauth(int, char*);
588extern int fstat(int, uchar*, int);
589extern int fwstat(int, uchar*, int);
590extern int fversion(int, int, char*, int);
591extern int mount(int, int, char*, int, char*);
592extern int unmount(char*, char*);
593extern int noted(int);
594extern int notify(void(*)(void*, char*));
595extern int open(char*, int);
596extern int fd2path(int, char*, int);
597extern int pipe(int*);
598extern long pread(int, void*, long, vlong);
599extern long preadv(int, IOchunk*, int, vlong);
600extern long pwrite(int, void*, long, vlong);
601extern long pwritev(int, IOchunk*, int, vlong);
602extern long read(int, void*, long);
603extern long readn(int, void*, long);
604extern long readv(int, IOchunk*, int);
605extern int remove(char*);
606extern void* sbrk(ulong);
607extern long oseek(int, long, int);
608extern vlong seek(int, vlong, int);
609extern long segattach(int, char*, void*, ulong);
610extern int segbrk(void*, void*);
611extern int segdetach(void*);
612extern int segflush(void*, ulong);
613extern int segfree(void*, ulong);
614extern int sleep(long);
615extern int stat(char*, uchar*, int);
616extern Waitmsg* wait(void);
617extern int waitpid(void);
618extern long write(int, void*, long);
619extern long writev(int, IOchunk*, int);
620extern int wstat(char*, uchar*, int);
621extern void* rendezvous(void*, void*);
622
623extern int getpid(void);
624extern int getppid(void);
625extern void rerrstr(char*, uint);
626extern char* sysname(void);
627extern void werrstr(char*, ...);
628#pragma varargck argpos werrstr 1
629
630extern char *argv0;
631#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
632 argv[0] && argv[0][0]=='-' && argv[0][1];\
633 argc--, argv++) {\
634 char *_args, *_argt;\
635 Rune _argc;\
636 _args = &argv[0][1];\
637 if(_args[0]=='-' && _args[1]==0){\
638 argc--; argv++; break;\
639 }\
640 _argc = 0;\
641 while(*_args && (_args += chartorune(&_argc, _args)))\
642 switch(_argc)
643#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
644#define ARGF() (_argt=_args, _args="",\
645 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
646#define EARGF(x) (_argt=_args, _args="",\
647 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
648
649#define ARGC() _argc
650
651
652/*
653 * Extensions for Inferno to basic libc.h
654 */
655
656#define setbinmode()
657#define __LITTLE_ENDIAN
658
Plan9/arm/include/u.h+65−0
@@ -0,0 +1,65 @@
1#define nil ((void*)0)
2
3typedef unsigned short ushort;
4typedef unsigned char uchar;
5typedef unsigned long ulong;
6typedef unsigned int uint;
7typedef signed char schar;
8typedef long long vlong;
9typedef unsigned long long uvlong;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21typedef unsigned long uintptr;
22
23/* FCR */
24#define FPINEX (1<<20)
25#define FPUNFL (1<<19)
26#define FPOVFL (1<<18)
27#define FPZDIV (1<<17)
28#define FPINVAL (1<<16)
29#define FPRNR (0<<0)
30#define FPRZ (1<<0)
31#define FPRPINF (2<<0)
32#define FPRNINF (3<<0)
33#define FPRMASK (3<<0)
34#define FPPEXT 0
35#define FPPSGL 0
36#define FPPDBL 0
37#define FPPMASK 0
38/* FSR */
39#define FPAINEX (1<<4)
40#define FPAUNFL (1<<3)
41#define FPAOVFL (1<<2)
42#define FPAZDIV (1<<1)
43#define FPAINVAL (1<<0)
44union FPdbleword
45{
46 double x;
47 struct { /* little endian (on VFP and now in software) */
48 ulong lo;
49 ulong hi;
50 };
51};
52
53typedef char* va_list;
54#define va_start(list, start) list =\
55 (sizeof(start) < 4?\
56 (char*)((int*)&(start)+1):\
57 (char*)(&(start)+1))
58#define va_end(list)\
59 USED(list)
60#define va_arg(list, mode)\
61 ((sizeof(mode) == 1)?\
62 ((mode*)(list += 4))[-4]:\
63 (sizeof(mode) == 2)?\
64 ((mode*)(list += 4))[-2]:\
65 ((mode*)(list += sizeof(mode)))[-1])
Plan9/arm/lib/.dreg+0−0

Empty file added.

Plan9/include/lib9.h+20−0
@@ -0,0 +1,20 @@
1#include <u.h>
2typedef usize size_t;
3
4#define Runeerror xRuneerror
5#define Rendez xRendez
6#include <libc.h>
7#undef Runeerror
8#undef Rendez
9
10
11enum
12{
13 Runeerror = 0x80, /* decoding error in UTF */
14};
15/*
16 * Extensions for Inferno to basic libc.h
17 */
18
19#define setbinmode()
20#define USE_FPdbleword
Plan9/include/lib9x.h+20−0
@@ -0,0 +1,20 @@
1#include <u.h>
2typedef usize size_t;
3
4#define Runeerror xRuneerror
5#define Rendez xRendez
6#include <libc.h>
7#undef Runeerror
8#undef Rendez
9
10
11enum
12{
13 Runeerror = 0x80, /* decoding error in UTF */
14};
15/*
16 * Extensions for Inferno to basic libc.h
17 */
18
19#define setbinmode()
20#define USE_FPdbleword
Plan9/mips/include/emu.h+23−0
@@ -0,0 +1,23 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12
13/*
14 * This structure must agree with FPsave and FPrestore asm routines
15 */
16struct FPU
17{
18 uchar env[28];
19};
20
21typedef jmp_buf osjmpbuf;
22#define ossetjmp(buf) setjmp(buf)
23
Plan9/mips/include/lib9.h+657−0
@@ -0,0 +1,657 @@
1#include <u.h>
2typedef unsigned long size_t;
3
4#define nelem(x) (sizeof(x)/sizeof((x)[0]))
5#define offsetof(s, m) (ulong)(&(((s*)0)->m))
6#define assert(x) if(x){}else _assert("x")
7
8/*
9 * mem routines
10 */
11extern void* memccpy(void*, void*, int, ulong);
12extern void* memset(void*, int, ulong);
13extern int memcmp(void*, void*, ulong);
14extern void* memcpy(void*, void*, ulong);
15extern void* memmove(void*, void*, ulong);
16extern void* memchr(void*, int, ulong);
17
18/*
19 * string routines
20 */
21extern char* strcat(char*, char*);
22extern char* strchr(char*, int);
23extern int strcmp(char*, char*);
24extern char* strcpy(char*, char*);
25extern char* strecpy(char*, char*, char*);
26extern char* strdup(char*);
27extern char* strncat(char*, char*, long);
28extern char* strncpy(char*, char*, long);
29extern int strncmp(char*, char*, long);
30extern char* strpbrk(char*, char*);
31extern char* strrchr(char*, int);
32extern char* strtok(char*, char*);
33extern long strlen(char*);
34extern long strspn(char*, char*);
35extern long strcspn(char*, char*);
36extern char* strstr(char*, char*);
37extern int cistrncmp(char*, char*, int);
38extern int cistrcmp(char*, char*);
39extern char* cistrstr(char*, char*);
40extern int tokenize(char*, char**, int);
41
42enum
43{
44 UTFmax = 3, /* maximum bytes per rune */
45 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
46 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
47 Runeerror = 0x80, /* decoding error in UTF */
48};
49
50/*
51 * rune routines
52 */
53extern int runetochar(char*, Rune*);
54extern int chartorune(Rune*, char*);
55extern int runelen(long);
56extern int runenlen(Rune*, int);
57extern int fullrune(char*, int);
58extern int utflen(char*);
59extern int utfnlen(char*, long);
60extern char* utfrune(char*, long);
61extern char* utfrrune(char*, long);
62extern char* utfutf(char*, char*);
63extern char* utfecpy(char*, char*, char*);
64
65extern Rune* runestrcat(Rune*, Rune*);
66extern Rune* runestrchr(Rune*, Rune);
67extern int runestrcmp(Rune*, Rune*);
68extern Rune* runestrcpy(Rune*, Rune*);
69extern Rune* runestrncpy(Rune*, Rune*, long);
70extern Rune* runestrecpy(Rune*, Rune*, Rune*);
71extern Rune* runestrdup(Rune*);
72extern Rune* runestrncat(Rune*, Rune*, long);
73extern int runestrncmp(Rune*, Rune*, long);
74extern Rune* runestrrchr(Rune*, Rune);
75extern long runestrlen(Rune*);
76extern Rune* runestrstr(Rune*, Rune*);
77
78extern Rune tolowerrune(Rune);
79extern Rune totitlerune(Rune);
80extern Rune toupperrune(Rune);
81extern int isalpharune(Rune);
82extern int islowerrune(Rune);
83extern int isspacerune(Rune);
84extern int istitlerune(Rune);
85extern int isupperrune(Rune);
86
87/*
88 * malloc
89 */
90extern void* malloc(ulong);
91extern void* mallocz(ulong, int);
92extern void free(void*);
93extern ulong msize(void*);
94extern void* calloc(ulong, ulong);
95extern void* realloc(void*, ulong);
96extern void setmalloctag(void*, ulong);
97extern void setrealloctag(void*, ulong);
98extern ulong getmalloctag(void*);
99extern ulong getrealloctag(void*);
100extern void* malloctopoolblock(void*);
101
102/*
103 * print routines
104 */
105typedef struct Fmt Fmt;
106struct Fmt{
107 uchar runes; /* output buffer is runes or chars? */
108 void *start; /* of buffer */
109 void *to; /* current place in the buffer */
110 void *stop; /* end of the buffer; overwritten if flush fails */
111 int (*flush)(Fmt *); /* called when to == stop */
112 void *farg; /* to make flush a closure */
113 int nfmt; /* num chars formatted so far */
114 va_list args; /* args passed to dofmt */
115 int r; /* % format Rune */
116 int width;
117 int prec;
118 ulong flags;
119};
120
121enum{
122 FmtWidth = 1,
123 FmtLeft = FmtWidth << 1,
124 FmtPrec = FmtLeft << 1,
125 FmtSharp = FmtPrec << 1,
126 FmtSpace = FmtSharp << 1,
127 FmtSign = FmtSpace << 1,
128 FmtZero = FmtSign << 1,
129 FmtUnsigned = FmtZero << 1,
130 FmtShort = FmtUnsigned << 1,
131 FmtLong = FmtShort << 1,
132 FmtVLong = FmtLong << 1,
133 FmtComma = FmtVLong << 1,
134 FmtByte = FmtComma << 1,
135
136 FmtFlag = FmtByte << 1
137};
138
139extern int print(char*, ...);
140extern char* seprint(char*, char*, char*, ...);
141extern char* vseprint(char*, char*, char*, va_list);
142extern int snprint(char*, int, char*, ...);
143extern int vsnprint(char*, int, char*, va_list);
144extern char* smprint(char*, ...);
145extern char* vsmprint(char*, va_list);
146extern int sprint(char*, char*, ...);
147extern int fprint(int, char*, ...);
148extern int vfprint(int, char*, va_list);
149
150extern int runesprint(Rune*, char*, ...);
151extern int runesnprint(Rune*, int, char*, ...);
152extern int runevsnprint(Rune*, int, char*, va_list);
153extern Rune* runeseprint(Rune*, Rune*, char*, ...);
154extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
155extern Rune* runesmprint(char*, ...);
156extern Rune* runevsmprint(char*, va_list);
157
158extern int fmtfdinit(Fmt*, int, char*, int);
159extern int fmtfdflush(Fmt*);
160extern int fmtstrinit(Fmt*);
161extern char* fmtstrflush(Fmt*);
162extern int runefmtstrinit(Fmt*);
163extern Rune* runefmtstrflush(Fmt*);
164
165#pragma varargck argpos fmtprint 2
166#pragma varargck argpos fprint 2
167#pragma varargck argpos print 1
168#pragma varargck argpos runeseprint 3
169#pragma varargck argpos runesmprint 1
170#pragma varargck argpos runesnprint 3
171#pragma varargck argpos runesprint 2
172#pragma varargck argpos seprint 3
173#pragma varargck argpos smprint 1
174#pragma varargck argpos snprint 3
175#pragma varargck argpos sprint 2
176#pragma varargck argpos vseprint 3
177#pragma varargck argpos vsnprint 3
178
179#pragma varargck type "lld" vlong
180#pragma varargck type "llx" vlong
181#pragma varargck type "lld" uvlong
182#pragma varargck type "llx" uvlong
183#pragma varargck type "ld" long
184#pragma varargck type "lx" long
185#pragma varargck type "ld" ulong
186#pragma varargck type "lx" ulong
187#pragma varargck type "d" int
188#pragma varargck type "x" int
189#pragma varargck type "c" int
190#pragma varargck type "C" int
191#pragma varargck type "d" uint
192#pragma varargck type "x" uint
193#pragma varargck type "c" uint
194#pragma varargck type "C" uint
195#pragma varargck type "f" double
196#pragma varargck type "e" double
197#pragma varargck type "g" double
198#pragma varargck type "s" char*
199#pragma varargck type "q" char*
200#pragma varargck type "S" Rune*
201#pragma varargck type "Q" Rune*
202#pragma varargck type "r" void
203#pragma varargck type "%" void
204#pragma varargck type "n" int*
205#pragma varargck type "p" void*
206#pragma varargck flag ','
207#pragma varargck type "<" void*
208#pragma varargck type "[" void*
209#pragma varargck type "H" void*
210
211extern int fmtinstall(int, int (*)(Fmt*));
212extern int dofmt(Fmt*, char*);
213extern int dorfmt(Fmt*, Rune*);
214extern int fmtprint(Fmt*, char*, ...);
215extern int fmtvprint(Fmt*, char*, va_list);
216extern int fmtrune(Fmt*, int);
217extern int fmtstrcpy(Fmt*, char*);
218extern int fmtrunestrcpy(Fmt*, Rune*);
219/*
220 * error string for %r
221 * supplied on per os basis, not part of fmt library
222 */
223extern int errfmt(Fmt *f);
224
225/*
226 * quoted strings
227 */
228extern char *unquotestrdup(char*);
229extern Rune *unquoterunestrdup(Rune*);
230extern char *quotestrdup(char*);
231extern Rune *quoterunestrdup(Rune*);
232extern int quotestrfmt(Fmt*);
233extern int quoterunestrfmt(Fmt*);
234extern void quotefmtinstall(void);
235extern int (*doquote)(int);
236
237/*
238 * random number
239 */
240extern void srand(long);
241extern int rand(void);
242extern int nrand(int);
243extern long lrand(void);
244extern long lnrand(long);
245extern double frand(void);
246extern ulong truerand(void);
247extern ulong ntruerand(ulong);
248
249/*
250 * math
251 */
252extern ulong getfcr(void);
253extern void setfsr(ulong);
254extern ulong getfsr(void);
255extern void setfcr(ulong);
256extern double NaN(void);
257extern double Inf(int);
258extern int isNaN(double);
259extern int isInf(double, int);
260
261extern double pow(double, double);
262extern double atan2(double, double);
263extern double fabs(double);
264extern double atan(double);
265extern double log(double);
266extern double log10(double);
267extern double exp(double);
268extern double floor(double);
269extern double ceil(double);
270extern double hypot(double, double);
271extern double sin(double);
272extern double cos(double);
273extern double tan(double);
274extern double asin(double);
275extern double acos(double);
276extern double sinh(double);
277extern double cosh(double);
278extern double tanh(double);
279extern double sqrt(double);
280extern double fmod(double, double);
281
282#define HUGE 3.4028234e38
283#define PIO2 1.570796326794896619231e0
284#define PI (PIO2+PIO2)
285
286/*
287 * Time-of-day
288 */
289
290typedef
291struct Tm
292{
293 int sec;
294 int min;
295 int hour;
296 int mday;
297 int mon;
298 int year;
299 int wday;
300 int yday;
301 char zone[4];
302 int tzoff;
303} Tm;
304
305extern Tm* gmtime(long);
306extern Tm* localtime(long);
307extern char* asctime(Tm*);
308extern char* ctime(long);
309extern double cputime(void);
310extern long times(long*);
311extern long tm2sec(Tm*);
312extern vlong nsec(void);
313
314/*
315 * one-of-a-kind
316 */
317enum
318{
319 PNPROC = 1,
320 PNGROUP = 2,
321};
322
323extern void _assert(char*);
324extern int abs(int);
325extern int atexit(void(*)(void));
326extern void atexitdont(void(*)(void));
327extern int atnotify(int(*)(void*, char*), int);
328extern double atof(char*);
329extern int atoi(char*);
330extern long atol(char*);
331extern double charstod(int(*)(void*), void*);
332extern char* cleanname(char*);
333extern int decrypt(void*, void*, int);
334extern int encrypt(void*, void*, int);
335extern int dec64(uchar*, int, char*, int);
336extern int enc64(char*, int, uchar*, int);
337extern int dec32(uchar*, int, char*, int);
338extern int enc32(char*, int, uchar*, int);
339extern int dec16(uchar*, int, char*, int);
340extern int enc16(char*, int, uchar*, int);
341extern int encodefmt(Fmt*);
342extern void exits(char*);
343extern double frexp(double, int*);
344extern uintptr getcallerpc(void*);
345extern char* getenv(char*);
346extern int getfields(char*, char**, int, int, char*);
347extern char* getuser(void);
348extern char* getwd(char*, int);
349extern int iounit(int);
350extern long labs(long);
351extern double ldexp(double, int);
352extern void longjmp(jmp_buf, int);
353extern char* mktemp(char*);
354extern double modf(double, double*);
355extern int netcrypt(void*, void*);
356extern void notejmp(void*, jmp_buf, int);
357extern void perror(char*);
358extern int postnote(int, int, char *);
359extern double pow10(int);
360extern double ipow10(int);
361extern int putenv(char*, char*);
362extern void qsort(void*, long, long, int (*)(void*, void*));
363extern void* sbrk(ulong);
364extern int setjmp(jmp_buf);
365extern double strtod(char*, char**);
366extern long strtol(char*, char**, int);
367extern ulong strtoul(char*, char**, int);
368extern vlong strtoll(char*, char**, int);
369extern uvlong strtoull(char*, char**, int);
370extern void sysfatal(char*, ...);
371#pragma varargck argpos sysfatal 1
372extern void syslog(int, char*, char*, ...);
373#pragma varargck argpos syslog 3
374extern long time(long*);
375extern int tolower(int);
376extern int toupper(int);
377
378/*
379 * synchronization
380 */
381typedef
382struct Lock {
383 int val;
384} Lock;
385
386extern int _tas(int*);
387
388extern void lock(Lock*);
389extern void unlock(Lock*);
390extern int canlock(Lock*);
391
392typedef struct QLp QLp;
393struct QLp
394{
395 int inuse;
396 QLp *next;
397 char state;
398};
399
400typedef
401struct QLock
402{
403 Lock lock;
404 int locked;
405 QLp *head;
406 QLp *tail;
407} QLock;
408
409extern void qlock(QLock*);
410extern void qunlock(QLock*);
411extern int canqlock(QLock*);
412extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
413
414typedef
415struct RWLock
416{
417 Lock lock;
418 int readers; /* number of readers */
419 int writer; /* number of writers */
420 QLp *head; /* list of waiting processes */
421 QLp *tail;
422} RWLock;
423
424extern int canrlock(RWLock*);
425extern int canwlock(RWLock*);
426extern void rlock(RWLock*);
427extern void runlock(RWLock*);
428extern void wlock(RWLock*);
429extern void wunlock(RWLock*);
430
431extern void** privalloc(void);
432extern void privfree(void**);
433
434/*
435 * network dialing
436 */
437#define NETPATHLEN 40
438extern int accept(int, char*);
439extern int announce(char*, char*);
440extern int dial(char*, char*, char*, int*);
441extern void setnetmtpt(char*, int, char*);
442extern int hangup(int);
443extern int listen(char*, char*);
444extern char* netmkaddr(char*, char*, char*);
445extern int reject(int, char*, char*);
446
447/*
448 * system calls
449 *
450 */
451#define STATMAX 65535U /* max length of machine-independent stat structure */
452#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
453#define ERRMAX 128 /* max length of error string */
454
455#define MORDER 0x0003 /* mask for bits defining order of mounting */
456#define MREPL 0x0000 /* mount replaces object */
457#define MBEFORE 0x0001 /* mount goes before others in union directory */
458#define MAFTER 0x0002 /* mount goes after others in union directory */
459#define MCREATE 0x0004 /* permit creation in mounted directory */
460#define MCACHE 0x0010 /* cache some data */
461#define MMASK 0x0017 /* all bits on */
462
463#define OREAD 0 /* open for read */
464#define OWRITE 1 /* write */
465#define ORDWR 2 /* read and write */
466#define OEXEC 3 /* execute, == read but check execute permission */
467#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
468#define OCEXEC 32 /* or'ed in, close on exec */
469#define ORCLOSE 64 /* or'ed in, remove on close */
470#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
471
472#define AEXIST 0 /* accessible: exists */
473#define AEXEC 1 /* execute access */
474#define AWRITE 2 /* write access */
475#define AREAD 4 /* read access */
476
477
478/* Segattch */
479#define SG_RONLY 0040 /* read only */
480#define SG_CEXEC 0100 /* detach on exec */
481
482#define NCONT 0 /* continue after note */
483#define NDFLT 1 /* terminate after note */
484#define NSAVE 2 /* clear note but hold state */
485#define NRSTR 3 /* restore saved state */
486
487/* rfork */
488enum
489{
490 RFNAMEG = (1<<0),
491 RFENVG = (1<<1),
492 RFFDG = (1<<2),
493 RFNOTEG = (1<<3),
494 RFPROC = (1<<4),
495 RFMEM = (1<<5),
496 RFNOWAIT = (1<<6),
497 RFCNAMEG = (1<<10),
498 RFCENVG = (1<<11),
499 RFCFDG = (1<<12),
500 RFREND = (1<<13),
501 RFNOMNT = (1<<14)
502};
503
504/* bits in Qid.type */
505#define QTDIR 0x80 /* type bit for directories */
506#define QTAPPEND 0x40 /* type bit for append only files */
507#define QTEXCL 0x20 /* type bit for exclusive use files */
508#define QTMOUNT 0x10 /* type bit for mounted channel */
509#define QTAUTH 0x08 /* type bit for authentication file */
510#define QTFILE 0x00 /* plain file */
511
512/* bits in Dir.mode */
513#define DMDIR 0x80000000 /* mode bit for directories */
514#define DMAPPEND 0x40000000 /* mode bit for append only files */
515#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
516#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
517#define DMAUTH 0x08000000 /* mode bit for authentication file */
518#define DMREAD 0x4 /* mode bit for read permission */
519#define DMWRITE 0x2 /* mode bit for write permission */
520#define DMEXEC 0x1 /* mode bit for execute permission */
521
522typedef
523struct Qid
524{
525 uvlong path;
526 ulong vers;
527 uchar type;
528} Qid;
529
530typedef
531struct Dir {
532 /* system-modified data */
533 ushort type; /* server type */
534 uint dev; /* server subtype */
535 /* file data */
536 Qid qid; /* unique id from server */
537 ulong mode; /* permissions */
538 ulong atime; /* last read time */
539 ulong mtime; /* last write time */
540 vlong length; /* file length */
541 char *name; /* last element of path */
542 char *uid; /* owner name */
543 char *gid; /* group name */
544 char *muid; /* last modifier name */
545} Dir;
546
547extern Dir* dirstat(char*);
548extern Dir* dirfstat(int);
549extern int dirwstat(char*, Dir*);
550extern int dirfwstat(int, Dir*);
551extern long dirread(int, Dir**);
552extern void nulldir(Dir*);
553extern long dirreadall(int, Dir**);
554
555typedef
556struct Waitmsg
557{
558 int pid; /* of loved one */
559 ulong time[3]; /* of loved one & descendants */
560 char *msg;
561} Waitmsg;
562
563typedef
564struct IOchunk
565{
566 void *addr;
567 ulong len;
568} IOchunk;
569
570extern void _exits(char*);
571
572extern void abort(void);
573extern int access(char*, int);
574extern long alarm(ulong);
575extern int await(char*, int);
576extern int bind(char*, char*, int);
577extern int brk(void*);
578extern int chdir(char*);
579extern int close(int);
580extern int create(char*, int, ulong);
581extern int dup(int, int);
582extern int errstr(char*, uint);
583extern int exec(char*, char*[]);
584extern int execl(char*, ...);
585extern int fork(void);
586extern int rfork(int);
587extern int fauth(int, char*);
588extern int fstat(int, uchar*, int);
589extern int fwstat(int, uchar*, int);
590extern int fversion(int, int, char*, int);
591extern int mount(int, int, char*, int, char*);
592extern int unmount(char*, char*);
593extern int noted(int);
594extern int notify(void(*)(void*, char*));
595extern int open(char*, int);
596extern int fd2path(int, char*, int);
597extern int pipe(int*);
598extern long pread(int, void*, long, vlong);
599extern long preadv(int, IOchunk*, int, vlong);
600extern long pwrite(int, void*, long, vlong);
601extern long pwritev(int, IOchunk*, int, vlong);
602extern long read(int, void*, long);
603extern long readn(int, void*, long);
604extern long readv(int, IOchunk*, int);
605extern int remove(char*);
606extern void* sbrk(ulong);
607extern long oseek(int, long, int);
608extern vlong seek(int, vlong, int);
609extern long segattach(int, char*, void*, ulong);
610extern int segbrk(void*, void*);
611extern int segdetach(void*);
612extern int segflush(void*, ulong);
613extern int segfree(void*, ulong);
614extern int sleep(long);
615extern int stat(char*, uchar*, int);
616extern Waitmsg* wait(void);
617extern int waitpid(void);
618extern long write(int, void*, long);
619extern long writev(int, IOchunk*, int);
620extern int wstat(char*, uchar*, int);
621extern void* rendezvous(void*, void*);
622
623extern int getpid(void);
624extern int getppid(void);
625extern void rerrstr(char*, uint);
626extern char* sysname(void);
627extern void werrstr(char*, ...);
628#pragma varargck argpos werrstr 1
629
630extern char *argv0;
631#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
632 argv[0] && argv[0][0]=='-' && argv[0][1];\
633 argc--, argv++) {\
634 char *_args, *_argt;\
635 Rune _argc;\
636 _args = &argv[0][1];\
637 if(_args[0]=='-' && _args[1]==0){\
638 argc--; argv++; break;\
639 }\
640 _argc = 0;\
641 while(*_args && (_args += chartorune(&_argc, _args)))\
642 switch(_argc)
643#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
644#define ARGF() (_argt=_args, _args="",\
645 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
646#define EARGF(x) (_argt=_args, _args="",\
647 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
648
649#define ARGC() _argc
650
651/*
652 * Extensions for Inferno to basic libc.h
653 */
654
655#define setbinmode()
656#undef __LITTLE_ENDIAN
657
Plan9/mips/include/u.h+65−0
@@ -0,0 +1,65 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<7)
24#define FPUNFL (1<<8)
25#define FPOVFL (1<<9)
26#define FPZDIV (1<<10)
27#define FPINVAL (1<<11)
28#define FPRNR (0<<0)
29#define FPRZ (1<<0)
30#define FPRPINF (2<<0)
31#define FPRNINF (3<<0)
32#define FPRMASK (3<<0)
33#define FPPEXT 0
34#define FPPSGL 0
35#define FPPDBL 0
36#define FPPMASK 0
37/* FSR */
38#define FPAINEX (1<<2)
39#define FPAOVFL (1<<4)
40#define FPAUNFL (1<<3)
41#define FPAZDIV (1<<5)
42#define FPAINVAL (1<<6)
43union FPdbleword
44{
45 double x;
46 struct { /* big endian */
47 ulong hi;
48 ulong lo;
49 };
50};
51
52/* stdarg */
53typedef char* va_list;
54#define va_start(list, start) list =\
55 (sizeof(start) < 4?\
56 (char*)((int*)&(start)+1):\
57 (char*)(&(start)+1))
58#define va_end(list)\
59 USED(list)
60#define va_arg(list, mode)\
61 ((sizeof(mode) == 1)?\
62 ((mode*)(list += 4))[-1]:\
63 (sizeof(mode) == 2)?\
64 ((mode*)(list += 4))[-1]:\
65 ((mode*)(list += sizeof(mode)))[-1])
Plan9/power/include/emu.h+30−0
@@ -0,0 +1,30 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12/*
13 * This structure must agree with FPsave and FPrestore asm routines
14 */
15typedef struct FPU FPU;
16struct FPU
17{
18 double fpreg[32];
19 union {
20 double fpscrd;
21 struct {
22 ulong pad;
23 ulong fpscr;
24 };
25 };
26};
27
28typedef jmp_buf osjmpbuf;
29#define ossetjmp(buf) setjmp(buf)
30
Plan9/power/include/lib9.h+657−0
@@ -0,0 +1,657 @@
1#include <u.h>
2typedef unsigned long size_t;
3
4#define nelem(x) (sizeof(x)/sizeof((x)[0]))
5#define offsetof(s, m) (ulong)(&(((s*)0)->m))
6#define assert(x) if(x){}else _assert("x")
7
8/*
9 * mem routines
10 */
11extern void* memccpy(void*, void*, int, ulong);
12extern void* memset(void*, int, ulong);
13extern int memcmp(void*, void*, ulong);
14extern void* memcpy(void*, void*, ulong);
15extern void* memmove(void*, void*, ulong);
16extern void* memchr(void*, int, ulong);
17
18/*
19 * string routines
20 */
21extern char* strcat(char*, char*);
22extern char* strchr(char*, int);
23extern int strcmp(char*, char*);
24extern char* strcpy(char*, char*);
25extern char* strecpy(char*, char*, char*);
26extern char* strdup(char*);
27extern char* strncat(char*, char*, long);
28extern char* strncpy(char*, char*, long);
29extern int strncmp(char*, char*, long);
30extern char* strpbrk(char*, char*);
31extern char* strrchr(char*, int);
32extern char* strtok(char*, char*);
33extern long strlen(char*);
34extern long strspn(char*, char*);
35extern long strcspn(char*, char*);
36extern char* strstr(char*, char*);
37extern int cistrncmp(char*, char*, int);
38extern int cistrcmp(char*, char*);
39extern char* cistrstr(char*, char*);
40extern int tokenize(char*, char**, int);
41
42enum
43{
44 UTFmax = 3, /* maximum bytes per rune */
45 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
46 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
47 Runeerror = 0x80, /* decoding error in UTF */
48};
49
50/*
51 * rune routines
52 */
53extern int runetochar(char*, Rune*);
54extern int chartorune(Rune*, char*);
55extern int runelen(long);
56extern int runenlen(Rune*, int);
57extern int fullrune(char*, int);
58extern int utflen(char*);
59extern int utfnlen(char*, long);
60extern char* utfrune(char*, long);
61extern char* utfrrune(char*, long);
62extern char* utfutf(char*, char*);
63extern char* utfecpy(char*, char*, char*);
64
65extern Rune* runestrcat(Rune*, Rune*);
66extern Rune* runestrchr(Rune*, Rune);
67extern int runestrcmp(Rune*, Rune*);
68extern Rune* runestrcpy(Rune*, Rune*);
69extern Rune* runestrncpy(Rune*, Rune*, long);
70extern Rune* runestrecpy(Rune*, Rune*, Rune*);
71extern Rune* runestrdup(Rune*);
72extern Rune* runestrncat(Rune*, Rune*, long);
73extern int runestrncmp(Rune*, Rune*, long);
74extern Rune* runestrrchr(Rune*, Rune);
75extern long runestrlen(Rune*);
76extern Rune* runestrstr(Rune*, Rune*);
77
78extern Rune tolowerrune(Rune);
79extern Rune totitlerune(Rune);
80extern Rune toupperrune(Rune);
81extern int isalpharune(Rune);
82extern int islowerrune(Rune);
83extern int isspacerune(Rune);
84extern int istitlerune(Rune);
85extern int isupperrune(Rune);
86
87/*
88 * malloc
89 */
90extern void* malloc(ulong);
91extern void* mallocz(ulong, int);
92extern void free(void*);
93extern ulong msize(void*);
94extern void* calloc(ulong, ulong);
95extern void* realloc(void*, ulong);
96extern void setmalloctag(void*, ulong);
97extern void setrealloctag(void*, ulong);
98extern ulong getmalloctag(void*);
99extern ulong getrealloctag(void*);
100extern void* malloctopoolblock(void*);
101
102/*
103 * print routines
104 */
105typedef struct Fmt Fmt;
106struct Fmt{
107 uchar runes; /* output buffer is runes or chars? */
108 void *start; /* of buffer */
109 void *to; /* current place in the buffer */
110 void *stop; /* end of the buffer; overwritten if flush fails */
111 int (*flush)(Fmt *); /* called when to == stop */
112 void *farg; /* to make flush a closure */
113 int nfmt; /* num chars formatted so far */
114 va_list args; /* args passed to dofmt */
115 int r; /* % format Rune */
116 int width;
117 int prec;
118 ulong flags;
119};
120
121enum{
122 FmtWidth = 1,
123 FmtLeft = FmtWidth << 1,
124 FmtPrec = FmtLeft << 1,
125 FmtSharp = FmtPrec << 1,
126 FmtSpace = FmtSharp << 1,
127 FmtSign = FmtSpace << 1,
128 FmtZero = FmtSign << 1,
129 FmtUnsigned = FmtZero << 1,
130 FmtShort = FmtUnsigned << 1,
131 FmtLong = FmtShort << 1,
132 FmtVLong = FmtLong << 1,
133 FmtComma = FmtVLong << 1,
134 FmtByte = FmtComma << 1,
135
136 FmtFlag = FmtByte << 1
137};
138
139extern int print(char*, ...);
140extern char* seprint(char*, char*, char*, ...);
141extern char* vseprint(char*, char*, char*, va_list);
142extern int snprint(char*, int, char*, ...);
143extern int vsnprint(char*, int, char*, va_list);
144extern char* smprint(char*, ...);
145extern char* vsmprint(char*, va_list);
146extern int sprint(char*, char*, ...);
147extern int fprint(int, char*, ...);
148extern int vfprint(int, char*, va_list);
149
150extern int runesprint(Rune*, char*, ...);
151extern int runesnprint(Rune*, int, char*, ...);
152extern int runevsnprint(Rune*, int, char*, va_list);
153extern Rune* runeseprint(Rune*, Rune*, char*, ...);
154extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
155extern Rune* runesmprint(char*, ...);
156extern Rune* runevsmprint(char*, va_list);
157
158extern int fmtfdinit(Fmt*, int, char*, int);
159extern int fmtfdflush(Fmt*);
160extern int fmtstrinit(Fmt*);
161extern char* fmtstrflush(Fmt*);
162extern int runefmtstrinit(Fmt*);
163extern Rune* runefmtstrflush(Fmt*);
164
165#pragma varargck argpos fmtprint 2
166#pragma varargck argpos fprint 2
167#pragma varargck argpos print 1
168#pragma varargck argpos runeseprint 3
169#pragma varargck argpos runesmprint 1
170#pragma varargck argpos runesnprint 3
171#pragma varargck argpos runesprint 2
172#pragma varargck argpos seprint 3
173#pragma varargck argpos smprint 1
174#pragma varargck argpos snprint 3
175#pragma varargck argpos sprint 2
176#pragma varargck argpos vseprint 3
177#pragma varargck argpos vsnprint 3
178
179#pragma varargck type "lld" vlong
180#pragma varargck type "llx" vlong
181#pragma varargck type "lld" uvlong
182#pragma varargck type "llx" uvlong
183#pragma varargck type "ld" long
184#pragma varargck type "lx" long
185#pragma varargck type "ld" ulong
186#pragma varargck type "lx" ulong
187#pragma varargck type "d" int
188#pragma varargck type "x" int
189#pragma varargck type "c" int
190#pragma varargck type "C" int
191#pragma varargck type "d" uint
192#pragma varargck type "x" uint
193#pragma varargck type "c" uint
194#pragma varargck type "C" uint
195#pragma varargck type "f" double
196#pragma varargck type "e" double
197#pragma varargck type "g" double
198#pragma varargck type "s" char*
199#pragma varargck type "q" char*
200#pragma varargck type "S" Rune*
201#pragma varargck type "Q" Rune*
202#pragma varargck type "r" void
203#pragma varargck type "%" void
204#pragma varargck type "n" int*
205#pragma varargck type "p" void*
206#pragma varargck flag ','
207#pragma varargck type "<" void*
208#pragma varargck type "[" void*
209#pragma varargck type "H" void*
210
211extern int fmtinstall(int, int (*)(Fmt*));
212extern int dofmt(Fmt*, char*);
213extern int dorfmt(Fmt*, Rune*);
214extern int fmtprint(Fmt*, char*, ...);
215extern int fmtvprint(Fmt*, char*, va_list);
216extern int fmtrune(Fmt*, int);
217extern int fmtstrcpy(Fmt*, char*);
218extern int fmtrunestrcpy(Fmt*, Rune*);
219/*
220 * error string for %r
221 * supplied on per os basis, not part of fmt library
222 */
223extern int errfmt(Fmt *f);
224
225/*
226 * quoted strings
227 */
228extern char *unquotestrdup(char*);
229extern Rune *unquoterunestrdup(Rune*);
230extern char *quotestrdup(char*);
231extern Rune *quoterunestrdup(Rune*);
232extern int quotestrfmt(Fmt*);
233extern int quoterunestrfmt(Fmt*);
234extern void quotefmtinstall(void);
235extern int (*doquote)(int);
236
237/*
238 * random number
239 */
240extern void srand(long);
241extern int rand(void);
242extern int nrand(int);
243extern long lrand(void);
244extern long lnrand(long);
245extern double frand(void);
246extern ulong truerand(void);
247extern ulong ntruerand(ulong);
248
249/*
250 * math
251 */
252extern ulong getfcr(void);
253extern void setfsr(ulong);
254extern ulong getfsr(void);
255extern void setfcr(ulong);
256extern double NaN(void);
257extern double Inf(int);
258extern int isNaN(double);
259extern int isInf(double, int);
260
261extern double pow(double, double);
262extern double atan2(double, double);
263extern double fabs(double);
264extern double atan(double);
265extern double log(double);
266extern double log10(double);
267extern double exp(double);
268extern double floor(double);
269extern double ceil(double);
270extern double hypot(double, double);
271extern double sin(double);
272extern double cos(double);
273extern double tan(double);
274extern double asin(double);
275extern double acos(double);
276extern double sinh(double);
277extern double cosh(double);
278extern double tanh(double);
279extern double sqrt(double);
280extern double fmod(double, double);
281
282#define HUGE 3.4028234e38
283#define PIO2 1.570796326794896619231e0
284#define PI (PIO2+PIO2)
285
286/*
287 * Time-of-day
288 */
289
290typedef
291struct Tm
292{
293 int sec;
294 int min;
295 int hour;
296 int mday;
297 int mon;
298 int year;
299 int wday;
300 int yday;
301 char zone[4];
302 int tzoff;
303} Tm;
304
305extern Tm* gmtime(long);
306extern Tm* localtime(long);
307extern char* asctime(Tm*);
308extern char* ctime(long);
309extern double cputime(void);
310extern long times(long*);
311extern long tm2sec(Tm*);
312extern vlong nsec(void);
313
314/*
315 * one-of-a-kind
316 */
317enum
318{
319 PNPROC = 1,
320 PNGROUP = 2,
321};
322
323extern void _assert(char*);
324extern int abs(int);
325extern int atexit(void(*)(void));
326extern void atexitdont(void(*)(void));
327extern int atnotify(int(*)(void*, char*), int);
328extern double atof(char*);
329extern int atoi(char*);
330extern long atol(char*);
331extern double charstod(int(*)(void*), void*);
332extern char* cleanname(char*);
333extern int decrypt(void*, void*, int);
334extern int encrypt(void*, void*, int);
335extern int dec64(uchar*, int, char*, int);
336extern int enc64(char*, int, uchar*, int);
337extern int dec32(uchar*, int, char*, int);
338extern int enc32(char*, int, uchar*, int);
339extern int dec16(uchar*, int, char*, int);
340extern int enc16(char*, int, uchar*, int);
341extern int encodefmt(Fmt*);
342extern void exits(char*);
343extern double frexp(double, int*);
344extern uintptr getcallerpc(void*);
345extern char* getenv(char*);
346extern int getfields(char*, char**, int, int, char*);
347extern char* getuser(void);
348extern char* getwd(char*, int);
349extern int iounit(int);
350extern long labs(long);
351extern double ldexp(double, int);
352extern void longjmp(jmp_buf, int);
353extern char* mktemp(char*);
354extern double modf(double, double*);
355extern int netcrypt(void*, void*);
356extern void notejmp(void*, jmp_buf, int);
357extern void perror(char*);
358extern int postnote(int, int, char *);
359extern double pow10(int);
360extern double ipow10(int);
361extern int putenv(char*, char*);
362extern void qsort(void*, long, long, int (*)(void*, void*));
363extern void* sbrk(ulong);
364extern int setjmp(jmp_buf);
365extern double strtod(char*, char**);
366extern long strtol(char*, char**, int);
367extern ulong strtoul(char*, char**, int);
368extern vlong strtoll(char*, char**, int);
369extern uvlong strtoull(char*, char**, int);
370extern void sysfatal(char*, ...);
371#pragma varargck argpos sysfatal 1
372extern void syslog(int, char*, char*, ...);
373#pragma varargck argpos syslog 3
374extern long time(long*);
375extern int tolower(int);
376extern int toupper(int);
377
378/*
379 * synchronization
380 */
381typedef
382struct Lock {
383 int val;
384} Lock;
385
386extern int _tas(int*);
387
388extern void lock(Lock*);
389extern void unlock(Lock*);
390extern int canlock(Lock*);
391
392typedef struct QLp QLp;
393struct QLp
394{
395 int inuse;
396 QLp *next;
397 char state;
398};
399
400typedef
401struct QLock
402{
403 Lock lock;
404 int locked;
405 QLp *head;
406 QLp *tail;
407} QLock;
408
409extern void qlock(QLock*);
410extern void qunlock(QLock*);
411extern int canqlock(QLock*);
412extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
413
414typedef
415struct RWLock
416{
417 Lock lock;
418 int readers; /* number of readers */
419 int writer; /* number of writers */
420 QLp *head; /* list of waiting processes */
421 QLp *tail;
422} RWLock;
423
424extern int canrlock(RWLock*);
425extern int canwlock(RWLock*);
426extern void rlock(RWLock*);
427extern void runlock(RWLock*);
428extern void wlock(RWLock*);
429extern void wunlock(RWLock*);
430
431extern void** privalloc(void);
432extern void privfree(void**);
433
434/*
435 * network dialing
436 */
437#define NETPATHLEN 40
438extern int accept(int, char*);
439extern int announce(char*, char*);
440extern int dial(char*, char*, char*, int*);
441extern void setnetmtpt(char*, int, char*);
442extern int hangup(int);
443extern int listen(char*, char*);
444extern char* netmkaddr(char*, char*, char*);
445extern int reject(int, char*, char*);
446
447/*
448 * system calls
449 *
450 */
451#define STATMAX 65535U /* max length of machine-independent stat structure */
452#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
453#define ERRMAX 128 /* max length of error string */
454
455#define MORDER 0x0003 /* mask for bits defining order of mounting */
456#define MREPL 0x0000 /* mount replaces object */
457#define MBEFORE 0x0001 /* mount goes before others in union directory */
458#define MAFTER 0x0002 /* mount goes after others in union directory */
459#define MCREATE 0x0004 /* permit creation in mounted directory */
460#define MCACHE 0x0010 /* cache some data */
461#define MMASK 0x0017 /* all bits on */
462
463#define OREAD 0 /* open for read */
464#define OWRITE 1 /* write */
465#define ORDWR 2 /* read and write */
466#define OEXEC 3 /* execute, == read but check execute permission */
467#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
468#define OCEXEC 32 /* or'ed in, close on exec */
469#define ORCLOSE 64 /* or'ed in, remove on close */
470#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
471
472#define AEXIST 0 /* accessible: exists */
473#define AEXEC 1 /* execute access */
474#define AWRITE 2 /* write access */
475#define AREAD 4 /* read access */
476
477
478/* Segattch */
479#define SG_RONLY 0040 /* read only */
480#define SG_CEXEC 0100 /* detach on exec */
481
482#define NCONT 0 /* continue after note */
483#define NDFLT 1 /* terminate after note */
484#define NSAVE 2 /* clear note but hold state */
485#define NRSTR 3 /* restore saved state */
486
487/* rfork */
488enum
489{
490 RFNAMEG = (1<<0),
491 RFENVG = (1<<1),
492 RFFDG = (1<<2),
493 RFNOTEG = (1<<3),
494 RFPROC = (1<<4),
495 RFMEM = (1<<5),
496 RFNOWAIT = (1<<6),
497 RFCNAMEG = (1<<10),
498 RFCENVG = (1<<11),
499 RFCFDG = (1<<12),
500 RFREND = (1<<13),
501 RFNOMNT = (1<<14)
502};
503
504/* bits in Qid.type */
505#define QTDIR 0x80 /* type bit for directories */
506#define QTAPPEND 0x40 /* type bit for append only files */
507#define QTEXCL 0x20 /* type bit for exclusive use files */
508#define QTMOUNT 0x10 /* type bit for mounted channel */
509#define QTAUTH 0x08 /* type bit for authentication file */
510#define QTFILE 0x00 /* plain file */
511
512/* bits in Dir.mode */
513#define DMDIR 0x80000000 /* mode bit for directories */
514#define DMAPPEND 0x40000000 /* mode bit for append only files */
515#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
516#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
517#define DMAUTH 0x08000000 /* mode bit for authentication file */
518#define DMREAD 0x4 /* mode bit for read permission */
519#define DMWRITE 0x2 /* mode bit for write permission */
520#define DMEXEC 0x1 /* mode bit for execute permission */
521
522typedef
523struct Qid
524{
525 uvlong path;
526 ulong vers;
527 uchar type;
528} Qid;
529
530typedef
531struct Dir {
532 /* system-modified data */
533 ushort type; /* server type */
534 uint dev; /* server subtype */
535 /* file data */
536 Qid qid; /* unique id from server */
537 ulong mode; /* permissions */
538 ulong atime; /* last read time */
539 ulong mtime; /* last write time */
540 vlong length; /* file length */
541 char *name; /* last element of path */
542 char *uid; /* owner name */
543 char *gid; /* group name */
544 char *muid; /* last modifier name */
545} Dir;
546
547extern Dir* dirstat(char*);
548extern Dir* dirfstat(int);
549extern int dirwstat(char*, Dir*);
550extern int dirfwstat(int, Dir*);
551extern long dirread(int, Dir**);
552extern void nulldir(Dir*);
553extern long dirreadall(int, Dir**);
554
555typedef
556struct Waitmsg
557{
558 int pid; /* of loved one */
559 ulong time[3]; /* of loved one & descendants */
560 char *msg;
561} Waitmsg;
562
563typedef
564struct IOchunk
565{
566 void *addr;
567 ulong len;
568} IOchunk;
569
570extern void _exits(char*);
571
572extern void abort(void);
573extern int access(char*, int);
574extern long alarm(ulong);
575extern int await(char*, int);
576extern int bind(char*, char*, int);
577extern int brk(void*);
578extern int chdir(char*);
579extern int close(int);
580extern int create(char*, int, ulong);
581extern int dup(int, int);
582extern int errstr(char*, uint);
583extern int exec(char*, char*[]);
584extern int execl(char*, ...);
585extern int fork(void);
586extern int rfork(int);
587extern int fauth(int, char*);
588extern int fstat(int, uchar*, int);
589extern int fwstat(int, uchar*, int);
590extern int fversion(int, int, char*, int);
591extern int mount(int, int, char*, int, char*);
592extern int unmount(char*, char*);
593extern int noted(int);
594extern int notify(void(*)(void*, char*));
595extern int open(char*, int);
596extern int fd2path(int, char*, int);
597extern int pipe(int*);
598extern long pread(int, void*, long, vlong);
599extern long preadv(int, IOchunk*, int, vlong);
600extern long pwrite(int, void*, long, vlong);
601extern long pwritev(int, IOchunk*, int, vlong);
602extern long read(int, void*, long);
603extern long readn(int, void*, long);
604extern long readv(int, IOchunk*, int);
605extern int remove(char*);
606extern void* sbrk(ulong);
607extern long oseek(int, long, int);
608extern vlong seek(int, vlong, int);
609extern long segattach(int, char*, void*, ulong);
610extern int segbrk(void*, void*);
611extern int segdetach(void*);
612extern int segflush(void*, ulong);
613extern int segfree(void*, ulong);
614extern int sleep(long);
615extern int stat(char*, uchar*, int);
616extern Waitmsg* wait(void);
617extern int waitpid(void);
618extern long write(int, void*, long);
619extern long writev(int, IOchunk*, int);
620extern int wstat(char*, uchar*, int);
621extern void* rendezvous(void*, void*);
622
623extern int getpid(void);
624extern int getppid(void);
625extern void rerrstr(char*, uint);
626extern char* sysname(void);
627extern void werrstr(char*, ...);
628#pragma varargck argpos werrstr 1
629
630extern char *argv0;
631#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
632 argv[0] && argv[0][0]=='-' && argv[0][1];\
633 argc--, argv++) {\
634 char *_args, *_argt;\
635 Rune _argc;\
636 _args = &argv[0][1];\
637 if(_args[0]=='-' && _args[1]==0){\
638 argc--; argv++; break;\
639 }\
640 _argc = 0;\
641 while(*_args && (_args += chartorune(&_argc, _args)))\
642 switch(_argc)
643#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
644#define ARGF() (_argt=_args, _args="",\
645 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
646#define EARGF(x) (_argt=_args, _args="",\
647 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
648
649#define ARGC() _argc
650
651/*
652 * Extensions for Inferno to basic libc.h
653 */
654
655#define setbinmode()
656#undef __LITTLE_ENDIAN
657
Plan9/power/include/u.h+84−0
@@ -0,0 +1,84 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC 0
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FPSCR */
23#define FPSFX (1<<31) /* exception summary (sticky) */
24#define FPSEX (1<<30) /* enabled exception summary */
25#define FPSVX (1<<29) /* invalid operation exception summary */
26#define FPSOX (1<<28) /* overflow exception OX (sticky) */
27#define FPSUX (1<<27) /* underflow exception UX (sticky) */
28#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
29#define FPSXX (1<<25) /* inexact exception XX (sticky) */
30#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
31#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
32#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
33#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
34#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
35#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
36#define FPSFR (1<<18) /* fraction rounded */
37#define FPSFI (1<<17) /* fraction inexact */
38#define FPSFPRF (1<<16) /* floating point result class */
39#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
40#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
41#define FPVE (1<<7) /* invalid operation exception enable */
42#define FPOVFL (1<<6) /* enable overflow exceptions */
43#define FPUNFL (1<<5) /* enable underflow */
44#define FPZDIV (1<<4) /* enable zero divide */
45#define FPINEX (1<<3) /* enable inexact exceptions */
46#define FPRMASK (3<<0) /* rounding mode */
47#define FPRNR (0<<0)
48#define FPRZ (1<<0)
49#define FPRPINF (2<<0)
50#define FPRNINF (3<<0)
51#define FPPEXT 0
52#define FPPSGL 0
53#define FPPDBL 0
54#define FPPMASK 0
55#define FPINVAL FPVE
56
57#define FPAOVFL FPSOX
58#define FPAINEX FPSXX
59#define FPAUNFL FPSUX
60#define FPAZDIV FPSZX
61#define FPAINVAL FPSVX
62
63union FPdbleword
64{
65 double x;
66 struct { /* big endian */
67 ulong hi;
68 ulong lo;
69 };
70};
71
72typedef char* va_list;
73#define va_start(list, start) list =\
74 (sizeof(start) < 4?\
75 (char*)((int*)&(start)+1):\
76 (char*)(&(start)+1))
77#define va_end(list)\
78 USED(list)
79#define va_arg(list, mode)\
80 ((sizeof(mode) == 1)?\
81 ((mode*)(list += 4))[-1]:\
82 (sizeof(mode) == 2)?\
83 ((mode*)(list += 4))[-1]:\
84 ((mode*)(list += sizeof(mode)))[-1])
Plan9/sparc/include/emu.h+22−0
@@ -0,0 +1,22 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc** Xup;
8#define up (*Xup)
9
10typedef struct FPU FPU;
11
12/*
13 * This structure must agree with FPsave and FPrestore asm routines
14 */
15struct FPU
16{
17 ulong fsr;
18};
19
20typedef jmp_buf osjmpbuf;
21#define ossetjmp(buf) setjmp(buf)
22
Plan9/sparc/include/lib9.h+657−0
@@ -0,0 +1,657 @@
1#include <u.h>
2typedef unsigned long size_t;
3
4#define nelem(x) (sizeof(x)/sizeof((x)[0]))
5#define offsetof(s, m) (ulong)(&(((s*)0)->m))
6#define assert(x) if(x){}else _assert("x")
7
8/*
9 * mem routines
10 */
11extern void* memccpy(void*, void*, int, ulong);
12extern void* memset(void*, int, ulong);
13extern int memcmp(void*, void*, ulong);
14extern void* memcpy(void*, void*, ulong);
15extern void* memmove(void*, void*, ulong);
16extern void* memchr(void*, int, ulong);
17
18/*
19 * string routines
20 */
21extern char* strcat(char*, char*);
22extern char* strchr(char*, int);
23extern int strcmp(char*, char*);
24extern char* strcpy(char*, char*);
25extern char* strecpy(char*, char*, char*);
26extern char* strdup(char*);
27extern char* strncat(char*, char*, long);
28extern char* strncpy(char*, char*, long);
29extern int strncmp(char*, char*, long);
30extern char* strpbrk(char*, char*);
31extern char* strrchr(char*, int);
32extern char* strtok(char*, char*);
33extern long strlen(char*);
34extern long strspn(char*, char*);
35extern long strcspn(char*, char*);
36extern char* strstr(char*, char*);
37extern int cistrncmp(char*, char*, int);
38extern int cistrcmp(char*, char*);
39extern char* cistrstr(char*, char*);
40extern int tokenize(char*, char**, int);
41
42enum
43{
44 UTFmax = 3, /* maximum bytes per rune */
45 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
46 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
47 Runeerror = 0x80, /* decoding error in UTF */
48};
49
50/*
51 * rune routines
52 */
53extern int runetochar(char*, Rune*);
54extern int chartorune(Rune*, char*);
55extern int runelen(long);
56extern int runenlen(Rune*, int);
57extern int fullrune(char*, int);
58extern int utflen(char*);
59extern int utfnlen(char*, long);
60extern char* utfrune(char*, long);
61extern char* utfrrune(char*, long);
62extern char* utfutf(char*, char*);
63extern char* utfecpy(char*, char*, char*);
64
65extern Rune* runestrcat(Rune*, Rune*);
66extern Rune* runestrchr(Rune*, Rune);
67extern int runestrcmp(Rune*, Rune*);
68extern Rune* runestrcpy(Rune*, Rune*);
69extern Rune* runestrncpy(Rune*, Rune*, long);
70extern Rune* runestrecpy(Rune*, Rune*, Rune*);
71extern Rune* runestrdup(Rune*);
72extern Rune* runestrncat(Rune*, Rune*, long);
73extern int runestrncmp(Rune*, Rune*, long);
74extern Rune* runestrrchr(Rune*, Rune);
75extern long runestrlen(Rune*);
76extern Rune* runestrstr(Rune*, Rune*);
77
78extern Rune tolowerrune(Rune);
79extern Rune totitlerune(Rune);
80extern Rune toupperrune(Rune);
81extern int isalpharune(Rune);
82extern int islowerrune(Rune);
83extern int isspacerune(Rune);
84extern int istitlerune(Rune);
85extern int isupperrune(Rune);
86
87/*
88 * malloc
89 */
90extern void* malloc(ulong);
91extern void* mallocz(ulong, int);
92extern void free(void*);
93extern ulong msize(void*);
94extern void* calloc(ulong, ulong);
95extern void* realloc(void*, ulong);
96extern void setmalloctag(void*, ulong);
97extern void setrealloctag(void*, ulong);
98extern ulong getmalloctag(void*);
99extern ulong getrealloctag(void*);
100extern void* malloctopoolblock(void*);
101
102/*
103 * print routines
104 */
105typedef struct Fmt Fmt;
106struct Fmt{
107 uchar runes; /* output buffer is runes or chars? */
108 void *start; /* of buffer */
109 void *to; /* current place in the buffer */
110 void *stop; /* end of the buffer; overwritten if flush fails */
111 int (*flush)(Fmt *); /* called when to == stop */
112 void *farg; /* to make flush a closure */
113 int nfmt; /* num chars formatted so far */
114 va_list args; /* args passed to dofmt */
115 int r; /* % format Rune */
116 int width;
117 int prec;
118 ulong flags;
119};
120
121enum{
122 FmtWidth = 1,
123 FmtLeft = FmtWidth << 1,
124 FmtPrec = FmtLeft << 1,
125 FmtSharp = FmtPrec << 1,
126 FmtSpace = FmtSharp << 1,
127 FmtSign = FmtSpace << 1,
128 FmtZero = FmtSign << 1,
129 FmtUnsigned = FmtZero << 1,
130 FmtShort = FmtUnsigned << 1,
131 FmtLong = FmtShort << 1,
132 FmtVLong = FmtLong << 1,
133 FmtComma = FmtVLong << 1,
134 FmtByte = FmtComma << 1,
135
136 FmtFlag = FmtByte << 1
137};
138
139extern int print(char*, ...);
140extern char* seprint(char*, char*, char*, ...);
141extern char* vseprint(char*, char*, char*, va_list);
142extern int snprint(char*, int, char*, ...);
143extern int vsnprint(char*, int, char*, va_list);
144extern char* smprint(char*, ...);
145extern char* vsmprint(char*, va_list);
146extern int sprint(char*, char*, ...);
147extern int fprint(int, char*, ...);
148extern int vfprint(int, char*, va_list);
149
150extern int runesprint(Rune*, char*, ...);
151extern int runesnprint(Rune*, int, char*, ...);
152extern int runevsnprint(Rune*, int, char*, va_list);
153extern Rune* runeseprint(Rune*, Rune*, char*, ...);
154extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
155extern Rune* runesmprint(char*, ...);
156extern Rune* runevsmprint(char*, va_list);
157
158extern int fmtfdinit(Fmt*, int, char*, int);
159extern int fmtfdflush(Fmt*);
160extern int fmtstrinit(Fmt*);
161extern char* fmtstrflush(Fmt*);
162extern int runefmtstrinit(Fmt*);
163extern Rune* runefmtstrflush(Fmt*);
164
165#pragma varargck argpos fmtprint 2
166#pragma varargck argpos fprint 2
167#pragma varargck argpos print 1
168#pragma varargck argpos runeseprint 3
169#pragma varargck argpos runesmprint 1
170#pragma varargck argpos runesnprint 3
171#pragma varargck argpos runesprint 2
172#pragma varargck argpos seprint 3
173#pragma varargck argpos smprint 1
174#pragma varargck argpos snprint 3
175#pragma varargck argpos sprint 2
176#pragma varargck argpos vseprint 3
177#pragma varargck argpos vsnprint 3
178
179#pragma varargck type "lld" vlong
180#pragma varargck type "llx" vlong
181#pragma varargck type "lld" uvlong
182#pragma varargck type "llx" uvlong
183#pragma varargck type "ld" long
184#pragma varargck type "lx" long
185#pragma varargck type "ld" ulong
186#pragma varargck type "lx" ulong
187#pragma varargck type "d" int
188#pragma varargck type "x" int
189#pragma varargck type "c" int
190#pragma varargck type "C" int
191#pragma varargck type "d" uint
192#pragma varargck type "x" uint
193#pragma varargck type "c" uint
194#pragma varargck type "C" uint
195#pragma varargck type "f" double
196#pragma varargck type "e" double
197#pragma varargck type "g" double
198#pragma varargck type "s" char*
199#pragma varargck type "q" char*
200#pragma varargck type "S" Rune*
201#pragma varargck type "Q" Rune*
202#pragma varargck type "r" void
203#pragma varargck type "%" void
204#pragma varargck type "n" int*
205#pragma varargck type "p" void*
206#pragma varargck flag ','
207#pragma varargck type "<" void*
208#pragma varargck type "[" void*
209#pragma varargck type "H" void*
210
211extern int fmtinstall(int, int (*)(Fmt*));
212extern int dofmt(Fmt*, char*);
213extern int dorfmt(Fmt*, Rune*);
214extern int fmtprint(Fmt*, char*, ...);
215extern int fmtvprint(Fmt*, char*, va_list);
216extern int fmtrune(Fmt*, int);
217extern int fmtstrcpy(Fmt*, char*);
218extern int fmtrunestrcpy(Fmt*, Rune*);
219/*
220 * error string for %r
221 * supplied on per os basis, not part of fmt library
222 */
223extern int errfmt(Fmt *f);
224
225/*
226 * quoted strings
227 */
228extern char *unquotestrdup(char*);
229extern Rune *unquoterunestrdup(Rune*);
230extern char *quotestrdup(char*);
231extern Rune *quoterunestrdup(Rune*);
232extern int quotestrfmt(Fmt*);
233extern int quoterunestrfmt(Fmt*);
234extern void quotefmtinstall(void);
235extern int (*doquote)(int);
236
237/*
238 * random number
239 */
240extern void srand(long);
241extern int rand(void);
242extern int nrand(int);
243extern long lrand(void);
244extern long lnrand(long);
245extern double frand(void);
246extern ulong truerand(void);
247extern ulong ntruerand(ulong);
248
249/*
250 * math
251 */
252extern ulong getfcr(void);
253extern void setfsr(ulong);
254extern ulong getfsr(void);
255extern void setfcr(ulong);
256extern double NaN(void);
257extern double Inf(int);
258extern int isNaN(double);
259extern int isInf(double, int);
260
261extern double pow(double, double);
262extern double atan2(double, double);
263extern double fabs(double);
264extern double atan(double);
265extern double log(double);
266extern double log10(double);
267extern double exp(double);
268extern double floor(double);
269extern double ceil(double);
270extern double hypot(double, double);
271extern double sin(double);
272extern double cos(double);
273extern double tan(double);
274extern double asin(double);
275extern double acos(double);
276extern double sinh(double);
277extern double cosh(double);
278extern double tanh(double);
279extern double sqrt(double);
280extern double fmod(double, double);
281
282#define HUGE 3.4028234e38
283#define PIO2 1.570796326794896619231e0
284#define PI (PIO2+PIO2)
285
286/*
287 * Time-of-day
288 */
289
290typedef
291struct Tm
292{
293 int sec;
294 int min;
295 int hour;
296 int mday;
297 int mon;
298 int year;
299 int wday;
300 int yday;
301 char zone[4];
302 int tzoff;
303} Tm;
304
305extern Tm* gmtime(long);
306extern Tm* localtime(long);
307extern char* asctime(Tm*);
308extern char* ctime(long);
309extern double cputime(void);
310extern long times(long*);
311extern long tm2sec(Tm*);
312extern vlong nsec(void);
313
314/*
315 * one-of-a-kind
316 */
317enum
318{
319 PNPROC = 1,
320 PNGROUP = 2,
321};
322
323extern void _assert(char*);
324extern int abs(int);
325extern int atexit(void(*)(void));
326extern void atexitdont(void(*)(void));
327extern int atnotify(int(*)(void*, char*), int);
328extern double atof(char*);
329extern int atoi(char*);
330extern long atol(char*);
331extern double charstod(int(*)(void*), void*);
332extern char* cleanname(char*);
333extern int decrypt(void*, void*, int);
334extern int encrypt(void*, void*, int);
335extern int dec64(uchar*, int, char*, int);
336extern int enc64(char*, int, uchar*, int);
337extern int dec32(uchar*, int, char*, int);
338extern int enc32(char*, int, uchar*, int);
339extern int dec16(uchar*, int, char*, int);
340extern int enc16(char*, int, uchar*, int);
341extern int encodefmt(Fmt*);
342extern void exits(char*);
343extern double frexp(double, int*);
344extern uintptr getcallerpc(void*);
345extern char* getenv(char*);
346extern int getfields(char*, char**, int, int, char*);
347extern char* getuser(void);
348extern char* getwd(char*, int);
349extern int iounit(int);
350extern long labs(long);
351extern double ldexp(double, int);
352extern void longjmp(jmp_buf, int);
353extern char* mktemp(char*);
354extern double modf(double, double*);
355extern int netcrypt(void*, void*);
356extern void notejmp(void*, jmp_buf, int);
357extern void perror(char*);
358extern int postnote(int, int, char *);
359extern double pow10(int);
360extern double ipow10(int);
361extern int putenv(char*, char*);
362extern void qsort(void*, long, long, int (*)(void*, void*));
363extern void* sbrk(ulong);
364extern int setjmp(jmp_buf);
365extern double strtod(char*, char**);
366extern long strtol(char*, char**, int);
367extern ulong strtoul(char*, char**, int);
368extern vlong strtoll(char*, char**, int);
369extern uvlong strtoull(char*, char**, int);
370extern void sysfatal(char*, ...);
371#pragma varargck argpos sysfatal 1
372extern void syslog(int, char*, char*, ...);
373#pragma varargck argpos syslog 3
374extern long time(long*);
375extern int tolower(int);
376extern int toupper(int);
377
378/*
379 * synchronization
380 */
381typedef
382struct Lock {
383 int val;
384} Lock;
385
386extern int _tas(int*);
387
388extern void lock(Lock*);
389extern void unlock(Lock*);
390extern int canlock(Lock*);
391
392typedef struct QLp QLp;
393struct QLp
394{
395 int inuse;
396 QLp *next;
397 char state;
398};
399
400typedef
401struct QLock
402{
403 Lock lock;
404 int locked;
405 QLp *head;
406 QLp *tail;
407} QLock;
408
409extern void qlock(QLock*);
410extern void qunlock(QLock*);
411extern int canqlock(QLock*);
412extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
413
414typedef
415struct RWLock
416{
417 Lock lock;
418 int readers; /* number of readers */
419 int writer; /* number of writers */
420 QLp *head; /* list of waiting processes */
421 QLp *tail;
422} RWLock;
423
424extern int canrlock(RWLock*);
425extern int canwlock(RWLock*);
426extern void rlock(RWLock*);
427extern void runlock(RWLock*);
428extern void wlock(RWLock*);
429extern void wunlock(RWLock*);
430
431extern void** privalloc(void);
432extern void privfree(void**);
433
434/*
435 * network dialing
436 */
437#define NETPATHLEN 40
438extern int accept(int, char*);
439extern int announce(char*, char*);
440extern int dial(char*, char*, char*, int*);
441extern void setnetmtpt(char*, int, char*);
442extern int hangup(int);
443extern int listen(char*, char*);
444extern char* netmkaddr(char*, char*, char*);
445extern int reject(int, char*, char*);
446
447/*
448 * system calls
449 *
450 */
451#define STATMAX 65535U /* max length of machine-independent stat structure */
452#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
453#define ERRMAX 128 /* max length of error string */
454
455#define MORDER 0x0003 /* mask for bits defining order of mounting */
456#define MREPL 0x0000 /* mount replaces object */
457#define MBEFORE 0x0001 /* mount goes before others in union directory */
458#define MAFTER 0x0002 /* mount goes after others in union directory */
459#define MCREATE 0x0004 /* permit creation in mounted directory */
460#define MCACHE 0x0010 /* cache some data */
461#define MMASK 0x0017 /* all bits on */
462
463#define OREAD 0 /* open for read */
464#define OWRITE 1 /* write */
465#define ORDWR 2 /* read and write */
466#define OEXEC 3 /* execute, == read but check execute permission */
467#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
468#define OCEXEC 32 /* or'ed in, close on exec */
469#define ORCLOSE 64 /* or'ed in, remove on close */
470#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
471
472#define AEXIST 0 /* accessible: exists */
473#define AEXEC 1 /* execute access */
474#define AWRITE 2 /* write access */
475#define AREAD 4 /* read access */
476
477
478/* Segattch */
479#define SG_RONLY 0040 /* read only */
480#define SG_CEXEC 0100 /* detach on exec */
481
482#define NCONT 0 /* continue after note */
483#define NDFLT 1 /* terminate after note */
484#define NSAVE 2 /* clear note but hold state */
485#define NRSTR 3 /* restore saved state */
486
487/* rfork */
488enum
489{
490 RFNAMEG = (1<<0),
491 RFENVG = (1<<1),
492 RFFDG = (1<<2),
493 RFNOTEG = (1<<3),
494 RFPROC = (1<<4),
495 RFMEM = (1<<5),
496 RFNOWAIT = (1<<6),
497 RFCNAMEG = (1<<10),
498 RFCENVG = (1<<11),
499 RFCFDG = (1<<12),
500 RFREND = (1<<13),
501 RFNOMNT = (1<<14)
502};
503
504/* bits in Qid.type */
505#define QTDIR 0x80 /* type bit for directories */
506#define QTAPPEND 0x40 /* type bit for append only files */
507#define QTEXCL 0x20 /* type bit for exclusive use files */
508#define QTMOUNT 0x10 /* type bit for mounted channel */
509#define QTAUTH 0x08 /* type bit for authentication file */
510#define QTFILE 0x00 /* plain file */
511
512/* bits in Dir.mode */
513#define DMDIR 0x80000000 /* mode bit for directories */
514#define DMAPPEND 0x40000000 /* mode bit for append only files */
515#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
516#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
517#define DMAUTH 0x08000000 /* mode bit for authentication file */
518#define DMREAD 0x4 /* mode bit for read permission */
519#define DMWRITE 0x2 /* mode bit for write permission */
520#define DMEXEC 0x1 /* mode bit for execute permission */
521
522typedef
523struct Qid
524{
525 uvlong path;
526 ulong vers;
527 uchar type;
528} Qid;
529
530typedef
531struct Dir {
532 /* system-modified data */
533 ushort type; /* server type */
534 uint dev; /* server subtype */
535 /* file data */
536 Qid qid; /* unique id from server */
537 ulong mode; /* permissions */
538 ulong atime; /* last read time */
539 ulong mtime; /* last write time */
540 vlong length; /* file length */
541 char *name; /* last element of path */
542 char *uid; /* owner name */
543 char *gid; /* group name */
544 char *muid; /* last modifier name */
545} Dir;
546
547extern Dir* dirstat(char*);
548extern Dir* dirfstat(int);
549extern int dirwstat(char*, Dir*);
550extern int dirfwstat(int, Dir*);
551extern long dirread(int, Dir**);
552extern void nulldir(Dir*);
553extern long dirreadall(int, Dir**);
554
555typedef
556struct Waitmsg
557{
558 int pid; /* of loved one */
559 ulong time[3]; /* of loved one & descendants */
560 char *msg;
561} Waitmsg;
562
563typedef
564struct IOchunk
565{
566 void *addr;
567 ulong len;
568} IOchunk;
569
570extern void _exits(char*);
571
572extern void abort(void);
573extern int access(char*, int);
574extern long alarm(ulong);
575extern int await(char*, int);
576extern int bind(char*, char*, int);
577extern int brk(void*);
578extern int chdir(char*);
579extern int close(int);
580extern int create(char*, int, ulong);
581extern int dup(int, int);
582extern int errstr(char*, uint);
583extern int exec(char*, char*[]);
584extern int execl(char*, ...);
585extern int fork(void);
586extern int rfork(int);
587extern int fauth(int, char*);
588extern int fstat(int, uchar*, int);
589extern int fwstat(int, uchar*, int);
590extern int fversion(int, int, char*, int);
591extern int mount(int, int, char*, int, char*);
592extern int unmount(char*, char*);
593extern int noted(int);
594extern int notify(void(*)(void*, char*));
595extern int open(char*, int);
596extern int fd2path(int, char*, int);
597extern int pipe(int*);
598extern long pread(int, void*, long, vlong);
599extern long preadv(int, IOchunk*, int, vlong);
600extern long pwrite(int, void*, long, vlong);
601extern long pwritev(int, IOchunk*, int, vlong);
602extern long read(int, void*, long);
603extern long readn(int, void*, long);
604extern long readv(int, IOchunk*, int);
605extern int remove(char*);
606extern void* sbrk(ulong);
607extern long oseek(int, long, int);
608extern vlong seek(int, vlong, int);
609extern long segattach(int, char*, void*, ulong);
610extern int segbrk(void*, void*);
611extern int segdetach(void*);
612extern int segflush(void*, ulong);
613extern int segfree(void*, ulong);
614extern int sleep(long);
615extern int stat(char*, uchar*, int);
616extern Waitmsg* wait(void);
617extern int waitpid(void);
618extern long write(int, void*, long);
619extern long writev(int, IOchunk*, int);
620extern int wstat(char*, uchar*, int);
621extern void* rendezvous(void*, void*);
622
623extern int getpid(void);
624extern int getppid(void);
625extern void rerrstr(char*, uint);
626extern char* sysname(void);
627extern void werrstr(char*, ...);
628#pragma varargck argpos werrstr 1
629
630extern char *argv0;
631#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
632 argv[0] && argv[0][0]=='-' && argv[0][1];\
633 argc--, argv++) {\
634 char *_args, *_argt;\
635 Rune _argc;\
636 _args = &argv[0][1];\
637 if(_args[0]=='-' && _args[1]==0){\
638 argc--; argv++; break;\
639 }\
640 _argc = 0;\
641 while(*_args && (_args += chartorune(&_argc, _args)))\
642 switch(_argc)
643#define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
644#define ARGF() (_argt=_args, _args="",\
645 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
646#define EARGF(x) (_argt=_args, _args="",\
647 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
648
649#define ARGC() _argc
650
651/*
652 * Extensions for Inferno to basic libc.h
653 */
654
655#define setbinmode()
656#undef __LITTLE_ENDIAN
657
Plan9/sparc/include/os.h+17−0
@@ -0,0 +1,17 @@
1/*
2 * Solaris 2.5/sparc
3 */
4
5/*
6 * This structure must agree with FPsave and FPrestore asm routines
7 */
8typedef struct FPU FPU;
9struct FPU
10{
11 ulong fsr;
12};
13
14extern Proc *getup();
15#define up (getup())
16
17#define BIGEND
Plan9/sparc/include/u.h+64−0
@@ -0,0 +1,64 @@
1#define nil ((void*)0)
2typedef unsigned short ushort;
3typedef unsigned char uchar;
4typedef unsigned long ulong;
5typedef unsigned int uint;
6typedef signed char schar;
7typedef long long vlong;
8typedef unsigned long long uvlong;
9typedef unsigned long uintptr;
10typedef ushort Rune;
11typedef union FPdbleword FPdbleword;
12typedef long jmp_buf[2];
13#define JMPBUFSP 0
14#define JMPBUFPC 1
15#define JMPBUFDPC (-8)
16typedef unsigned int mpdigit; /* for /sys/include/mp.h */
17typedef unsigned char u8int;
18typedef unsigned short u16int;
19typedef unsigned int u32int;
20typedef unsigned long long u64int;
21
22/* FCR */
23#define FPINEX (1<<23)
24#define FPOVFL (1<<26)
25#define FPUNFL (1<<25)
26#define FPZDIV (1<<24)
27#define FPRNR (0<<30)
28#define FPRZ (1<<30)
29#define FPINVAL (1<<27)
30#define FPRPINF (2<<30)
31#define FPRNINF (3<<30)
32#define FPRMASK (3<<30)
33#define FPPEXT 0
34#define FPPSGL 0
35#define FPPDBL 0
36#define FPPMASK 0
37/* FSR */
38#define FPAINEX (1<<5)
39#define FPAZDIV (1<<6)
40#define FPAUNFL (1<<7)
41#define FPAOVFL (1<<8)
42#define FPAINVAL (1<<9)
43union FPdbleword
44{
45 double x;
46 struct { /* big endian */
47 ulong hi;
48 ulong lo;
49 };
50};
51
52typedef char* va_list;
53#define va_start(list, start) list =\
54 (sizeof(start) < 4?\
55 (char*)((int*)&(start)+1):\
56 (char*)(&(start)+1))
57#define va_end(list)\
58 USED(list)
59#define va_arg(list, mode)\
60 ((sizeof(mode) == 1)?\
61 ((mode*)(list += 4))[-1]:\
62 (sizeof(mode) == 2)?\
63 ((mode*)(list += 4))[-1]:\
64 ((mode*)(list += sizeof(mode)))[-1])
README.gcode+11−0
@@ -0,0 +1,11 @@
1This subversion distribution contains the Inferno distribution trees starting with 20060303 EXCLUDING
2derived executable files in the per-platform bin directories (except for those needed
3on a given platform to build anything, such as mk or yacc). It also EXCLUDES any non-Free
4components, mainly the Bigelow & Holmes fonts, which can be obtained from the primary
5Inferno distribution. Since the fonts hardly ever change, you need only do that once.
6The /dis files are also derived, of course, but they are included;
7the extra space is modest these days, and it helps support some regression testing.
8
9The overall licence is GPLv2, to accord with Google understandable limitation to one licence,
10since GPLv2 arguably imposes most constraints on redistribution (of the set we use in the full distribution),
11but where less restrictive licence is available, and could be used, that is noted in a NOTICE file.
Solaris/386/include/emu.h+21−0
@@ -0,0 +1,21 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc* getup(void);
8#define up (getup())
9
10/*
11 * This structure must agree with FPsave and FPrestore asm routines
12 */
13typedef struct FPU FPU;
14struct FPU
15{
16 uchar env[28];
17};
18
19typedef sigjmp_buf osjmpbuf;
20#define ossetjmp(buf) sigsetjmp(buf, 1)
21
Solaris/386/include/lib9.h+393−0
@@ -0,0 +1,393 @@
1#define _POSIX_SOURCE
2#define _POSIX_C_SOURCE 1
3#define _LARGEFILE64_SOURCE 1
4#define _FILE_OFFSET_BITS 64
5#include <stdlib.h>
6#include <stdarg.h>
7#include <errno.h>
8#include <string.h>
9#include "math.h"
10#include <fcntl.h>
11#include <setjmp.h>
12#include <float.h>
13
14#define getwd infgetwd
15
16/*
17 * math/dtoa.c
18 */
19#define __LITTLE_ENDIAN
20
21#define nil ((void*)0)
22
23typedef unsigned char uchar;
24typedef unsigned int uint;
25typedef unsigned long ulong;
26typedef signed char schar;
27typedef unsigned short ushort;
28typedef unsigned short Rune;
29typedef long long int vlong;
30typedef unsigned long long int uvlong;
31typedef unsigned int mpdigit; /* for /sys/include/mp.h */
32typedef unsigned short u16int;
33typedef unsigned char u8int;
34typedef unsigned long uintptr;
35
36typedef signed char int8;
37typedef unsigned char uint8;
38typedef short int16;
39typedef unsigned short uint16;
40typedef int int32;
41typedef unsigned int uint32;
42typedef long long int64;
43typedef unsigned long long uint64;
44
45#define USED(x) if(x);else
46#define SET(x)
47
48#define nelem(x) (sizeof(x)/sizeof((x)[0]))
49
50/*
51 * mem and string routines are declared by ANSI/POSIX files above
52 */
53
54enum
55{
56 UTFmax = 3, /* maximum bytes per rune */
57 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
58 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
59 Runeerror = 0x80 /* decoding error in UTF */
60};
61
62/*
63 * rune routines
64 */
65extern int runetochar(char*, Rune*);
66extern int chartorune(Rune*, char*);
67extern int runelen(long);
68extern int runenlen(Rune*, int);
69extern int fullrune(char*, int);
70extern int utflen(char*);
71extern int utfnlen(char*, long);
72extern char* utfrune(char*, long);
73extern char* utfrrune(char*, long);
74extern char* utfutf(char*, char*);
75extern char* utfecpy(char*, char*, char*);
76
77extern Rune* runestrcat(Rune*, Rune*);
78extern Rune* runestrchr(Rune*, Rune);
79extern int runestrcmp(Rune*, Rune*);
80extern Rune* runestrcpy(Rune*, Rune*);
81extern Rune* runestrncpy(Rune*, Rune*, long);
82extern Rune* runestrecpy(Rune*, Rune*, Rune*);
83extern Rune* runestrdup(Rune*);
84extern Rune* runestrncat(Rune*, Rune*, long);
85extern int runestrncmp(Rune*, Rune*, long);
86extern Rune* runestrrchr(Rune*, Rune);
87extern long runestrlen(Rune*);
88extern Rune* runestrstr(Rune*, Rune*);
89
90extern Rune tolowerrune(Rune);
91extern Rune totitlerune(Rune);
92extern Rune toupperrune(Rune);
93extern int isalpharune(Rune);
94extern int islowerrune(Rune);
95extern int isspacerune(Rune);
96extern int istitlerune(Rune);
97extern int isupperrune(Rune);
98
99/*
100 * malloc
101 */
102extern void* malloc(size_t);
103extern void* mallocz(ulong, int);
104extern void free(void*);
105extern ulong msize(void*);
106extern void* calloc(size_t, size_t);
107extern void* realloc(void*, size_t);
108extern void setmalloctag(void*, ulong);
109extern void setrealloctag(void*, ulong);
110extern ulong getmalloctag(void*);
111extern ulong getrealloctag(void*);
112extern void* malloctopoolblock(void*);
113
114extern int getfields(char*, char**, int, int, char*);
115extern uintptr getcallerpc(void*);
116
117/*
118 * print routines
119 */
120typedef struct Fmt Fmt;
121struct Fmt{
122 uchar runes; /* output buffer is runes or chars? */
123 void *start; /* of buffer */
124 void *to; /* current place in the buffer */
125 void *stop; /* end of the buffer; overwritten if flush fails */
126 int (*flush)(Fmt *); /* called when to == stop */
127 void *farg; /* to make flush a closure */
128 int nfmt; /* num chars formatted so far */
129 va_list args; /* args passed to dofmt */
130 int r; /* % format Rune */
131 int width;
132 int prec;
133 ulong flags;
134};
135
136enum{
137 FmtWidth = 1,
138 FmtLeft = FmtWidth << 1,
139 FmtPrec = FmtLeft << 1,
140 FmtSharp = FmtPrec << 1,
141 FmtSpace = FmtSharp << 1,
142 FmtSign = FmtSpace << 1,
143 FmtZero = FmtSign << 1,
144 FmtUnsigned = FmtZero << 1,
145 FmtShort = FmtUnsigned << 1,
146 FmtLong = FmtShort << 1,
147 FmtVLong = FmtLong << 1,
148 FmtComma = FmtVLong << 1,
149 FmtByte = FmtComma << 1,
150
151 FmtFlag = FmtByte << 1
152};
153
154extern int print(char*, ...);
155extern char* seprint(char*, char*, char*, ...);
156extern char* vseprint(char*, char*, char*, va_list);
157extern int snprint(char*, int, char*, ...);
158extern int vsnprint(char*, int, char*, va_list);
159extern char* smprint(char*, ...);
160extern char* vsmprint(char*, va_list);
161extern int sprint(char*, char*, ...);
162extern int fprint(int, char*, ...);
163extern int vfprint(int, char*, va_list);
164
165extern int runesprint(Rune*, char*, ...);
166extern int runesnprint(Rune*, int, char*, ...);
167extern int runevsnprint(Rune*, int, char*, va_list);
168extern Rune* runeseprint(Rune*, Rune*, char*, ...);
169extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
170extern Rune* runesmprint(char*, ...);
171extern Rune* runevsmprint(char*, va_list);
172
173extern int fmtfdinit(Fmt*, int, char*, int);
174extern int fmtfdflush(Fmt*);
175extern int fmtstrinit(Fmt*);
176extern char* fmtstrflush(Fmt*);
177extern int runefmtstrinit(Fmt*);
178extern Rune* runefmtstrflush(Fmt*);
179
180extern int fmtinstall(int, int (*)(Fmt*));
181extern int dofmt(Fmt*, char*);
182extern int dorfmt(Fmt*, Rune*);
183extern int fmtprint(Fmt*, char*, ...);
184extern int fmtvprint(Fmt*, char*, va_list);
185extern int fmtrune(Fmt*, int);
186extern int fmtstrcpy(Fmt*, char*);
187extern int fmtrunestrcpy(Fmt*, Rune*);
188/*
189 * error string for %r
190 * supplied on per os basis, not part of fmt library
191 */
192extern int errfmt(Fmt *f);
193
194/*
195 * quoted strings
196 */
197extern char *unquotestrdup(char*);
198extern Rune *unquoterunestrdup(Rune*);
199extern char *quotestrdup(char*);
200extern Rune *quoterunestrdup(Rune*);
201extern int quotestrfmt(Fmt*);
202extern int quoterunestrfmt(Fmt*);
203extern void quotefmtinstall(void);
204extern int (*doquote)(int);
205
206extern char* strdup(const char*);
207extern int tokenize(char*, char**, int);
208extern vlong strtoll(const char*, char**, int);
209#define qsort infqsort
210extern void qsort(void*, long, long, int (*)(void*, void*));
211
212extern int isNaN(double);
213extern int isInf(double, int);
214
215/*
216 * Time-of-day
217 */
218
219typedef struct Tm Tm;
220struct Tm {
221 int sec;
222 int min;
223 int hour;
224 int mday;
225 int mon;
226 int year;
227 int wday;
228 int yday;
229 char zone[4];
230};
231
232/*
233 * one-of-a-kind
234 */
235extern int getfields(char*, char**, int, int, char*);
236extern char* getuser(void);
237extern char* getwd(char*, int);
238extern double pow10(int);
239extern double ipow10(int);
240extern vlong strtoll(const char*, char**, int);
241extern uvlong strtoull(const char*, char**, int);
242extern void sysfatal(char*, ...);
243extern int dec64(uchar*, int, char*, int);
244extern int enc64(char*, int, uchar*, int);
245extern int dec32(uchar*, int, char*, int);
246extern int enc32(char*, int, uchar*, int);
247extern int dec16(uchar*, int, char*, int);
248extern int enc16(char*, int, uchar*, int);
249extern int encodefmt(Fmt*);
250
251/*
252 * synchronization
253 */
254typedef
255struct Lock {
256 int val;
257 int pid;
258} Lock;
259
260extern int _tas(int*);
261
262extern void lock(Lock*);
263extern void unlock(Lock*);
264extern int canlock(Lock*);
265
266typedef struct QLock QLock;
267struct QLock
268{
269 Lock use; /* to access Qlock structure */
270 Proc *head; /* next process waiting for object */
271 Proc *tail; /* last process waiting for object */
272 int locked; /* flag */
273};
274
275extern void qlock(QLock*);
276extern void qunlock(QLock*);
277extern int canqlock(QLock*);
278extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
279
280typedef
281struct RWLock
282{
283 Lock l; /* Lock modify lock */
284 QLock x; /* Mutual exclusion lock */
285 QLock k; /* Lock for waiting writers */
286 int readers; /* Count of readers in lock */
287} RWLock;
288
289extern int canrlock(RWLock*);
290extern int canwlock(RWLock*);
291extern void rlock(RWLock*);
292extern void runlock(RWLock*);
293extern void wlock(RWLock*);
294extern void wunlock(RWLock*);
295
296/*
297 * system calls
298 *
299 */
300enum
301{
302 NAMELEN = 28,
303 ERRLEN = 64,
304 ERRMAX = 128,
305 DIRLEN = 116
306};
307
308#define CHDIR 0x80000000 /* mode bit for directories */
309#define CHAPPEND 0x40000000 /* mode bit for append only files */
310#define CHEXCL 0x20000000 /* mode bit for exclusive use files */
311#define CHMOUNT 0x10000000 /* mode bit for mounted channel */
312#define CHREAD 0x4 /* mode bit for read permission */
313#define CHWRITE 0x2 /* mode bit for write permission */
314#define CHEXEC 0x1 /* mode bit for execute permission */
315
316#define MORDER 0x0003 /* mask for bits defining order of mounting */
317#define MREPL 0x0000 /* mount replaces object */
318#define MBEFORE 0x0001 /* mount goes before others in union directory */
319#define MAFTER 0x0002 /* mount goes after others in union directory */
320#define MCREATE 0x0004 /* permit creation in mounted directory */
321#define MCACHE 0x0010 /* cache some data */
322#define MMASK 0x0007 /* all bits on */
323
324#define OREAD 0 /* open for read */
325#define OWRITE 1 /* write */
326#define ORDWR 2 /* read and write */
327#define OEXEC 3 /* execute, == read but check execute permission */
328#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
329#define OCEXEC 32 /* or'ed in, close on exec */
330#define ORCLOSE 64 /* or'ed in, remove on close */
331#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
332
333typedef
334struct Qid
335{
336 ulong path;
337 ulong vers;
338} Qid;
339
340typedef
341struct Dir
342{
343 char name[NAMELEN];
344 char uid[NAMELEN];
345 char gid[NAMELEN];
346 Qid qid;
347 ulong mode;
348 int atime;
349 int mtime;
350 vlong length;
351 ushort type;
352 ushort dev;
353} Dir;
354
355extern int dirfstat(int, Dir*);
356extern int dirstat(char*, Dir*);
357extern int dirfwstat(int, Dir*);
358extern int dirwstat(char*, Dir*);
359
360extern char* cleanname(char*);
361extern void exits(char*);
362extern void _exits(char*);
363extern int create(char*, int, int);
364
365extern char* getuser(void);
366extern char* getwd(char*, int);
367
368extern int errstr(char*, uint);
369extern void werrstr(char*, ...);
370
371#define ARGBEGIN for(argv++,argc--;\
372 argv[0] && argv[0][0]=='-' && argv[0][1];\
373 argc--, argv++) {\
374 char *_args, *_argt;\
375 char _argc;\
376 _args = &argv[0][1];\
377 if(_args[0]=='-' && _args[1]==0){\
378 argc--; argv++; break;\
379 }\
380 _argc = 0;\
381 while((_argc = *_args++)!='\0')\
382 switch(_argc)
383#define ARGEND }
384#define ARGF() (_argt=_args, _args="",\
385 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
386#define ARGC() _argc
387
388/*
389 * Extensions for Inferno to basic libc.h
390 */
391
392#define setbinmode()
393
Solaris/sparc/bin/data2c+0−0

Binary file not shown.

Solaris/sparc/bin/iyacc+0−0

Binary file not shown.

Solaris/sparc/bin/mk+0−0

Binary file not shown.

Solaris/sparc/bin/mkext+0−0

Binary file not shown.

Solaris/sparc/include/emu.h+21−0
@@ -0,0 +1,21 @@
1/*
2 * system- and machine-specific declarations for emu:
3 * floating-point save and restore, signal handling primitive, and
4 * implementation of the current-process variable `up'.
5 */
6
7extern Proc* getup(void);
8#define up (getup())
9
10/*
11 * This structure must agree with FPsave and FPrestore asm routines
12 */
13typedef struct FPU FPU;
14struct FPU
15{
16 ulong fsr;
17};
18
19typedef sigjmp_buf osjmpbuf;
20#define ossetjmp(buf) sigsetjmp(buf, 1)
21
Solaris/sparc/include/fpuctl.h+75−0
@@ -0,0 +1,75 @@
1/* This code is a little awkward. If somebody who understands Solaris
2 better would tell me an idiomatic way to invoke equivalent
3 behavior, I'd be grateful. ehg@bell-labs.com */
4
5/*
6 * accrued exception bits in the fsr
7 */
8#define FPAINEX (1<<5)
9#define FPAOVFL (1<<8)
10#define FPAUNFL (1<<7)
11#define FPAZDIV (1<<6)
12#define FPAINVAL (1<<9)
13
14/*
15 * exception enable bits in the fsr
16 */
17#define FPINEX (1<<23)
18#define FPOVFL (1<<26)
19#define FPUNFL (1<<25)
20#define FPZDIV (1<<24)
21#define FPINVAL (1<<27)
22
23/*
24 * rounding
25 */
26#define FPRMASK (3<<30)
27#define FPRNR (0<<30)
28#define FPRNINF (3<<30)
29#define FPRPINF (2<<30)
30#define FPRZ (1<<30)
31
32/*
33 * precision
34 */
35#define FPPDBL 0
36
37#define FPFCR (FPRMASK|FPINEX|FPOVFL|FPUNFL|FPZDIV|FPINVAL)
38#define FPFSR (FPAINEX|FPAOVFL|FPAUNFL|FPAZDIV|FPAINVAL)
39
40static ulong
41getfcr(void)
42{
43 ulong v;
44
45 asm(" st %fsr, [%fp-8]");
46 return v;
47}
48
49static void
50setfcr(ulong v)
51{
52 ulong vv;
53
54 vv = (getfcr() & ~FPFCR) | (v & FPFCR);
55 asm(" ld [%fp-4], %fsr");
56}
57
58static ulong
59getfsr(void)
60{
61 ulong v;
62
63 asm(" st %fsr, [%fp-8]");
64 return v;
65}
66
67static void
68setfsr(ulong v)
69{
70 ulong vv;
71
72 vv = (getfsr() & ~FPFSR) | (v & FPFSR);
73 asm(" ld [%fp-4], %fsr");
74}
75
Solaris/sparc/include/lib9.h+468−0
@@ -0,0 +1,468 @@
1#define _POSIX_SOURCE
2#define _POSIX_C_SOURCE 1
3#define _LARGEFILE64_SOURCE 1
4#define _FILE_OFFSET_BITS 64
5#include <sys/types.h>
6#include <stdlib.h>
7#include <stdarg.h>
8#define __EXTENSIONS__
9#include <unistd.h>
10#undef __EXTENSIONS__
11#include <errno.h>
12#include <string.h>
13#include "math.h"
14#include <fcntl.h>
15#include <setjmp.h>
16#include <float.h>
17#include <time.h>
18
19#define getwd infgetwd
20
21#ifndef EMU
22typedef struct Proc Proc;
23#endif
24
25#define nil ((void*)0)
26
27typedef unsigned char uchar;
28typedef unsigned int uint;
29typedef unsigned long ulong;
30typedef signed char schar;
31typedef unsigned short ushort;
32typedef unsigned short Rune;
33typedef long long int vlong;
34typedef unsigned long long int uvlong;
35typedef unsigned int u32int;
36typedef uvlong u64int;
37
38typedef unsigned int mpdigit; /* for /sys/include/mp.h */
39typedef unsigned short u16int;
40typedef unsigned char u8int;
41typedef unsigned long uintptr;
42
43typedef signed char int8;
44typedef unsigned char uint8;
45typedef short int16;
46typedef unsigned short uint16;
47typedef int int32;
48typedef unsigned int uint32;
49typedef long long int64;
50typedef unsigned long long uint64;
51
52#define USED(x) if(x){}else{}
53#define SET(x)
54
55#undef nelem
56#define nelem(x) (sizeof(x)/sizeof((x)[0]))
57#undef offsetof
58#define offsetof(s, m) (ulong)(&(((s*)0)->m))
59#undef assert
60#define assert(x) if(x){}else _assert("x")
61
62/*
63 * most mem and string routines are declared by ANSI/POSIX files above
64 */
65
66extern char* strecpy(char*, char*, char*);
67extern char* strdup(const char*);
68extern int cistrncmp(char*, char*, int);
69extern int cistrcmp(char*, char*);
70extern char* cistrstr(char*, char*);
71extern int tokenize(char*, char**, int);
72
73enum
74{
75 UTFmax = 3, /* maximum bytes per rune */
76 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
77 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
78 Runeerror = 0x80 /* decoding error in UTF */
79};
80
81/*
82 * rune routines
83 */
84extern int runetochar(char*, Rune*);
85extern int chartorune(Rune*, char*);
86extern int runelen(long);
87extern int runenlen(Rune*, int);
88extern int fullrune(char*, int);
89extern int utflen(char*);
90extern int utfnlen(char*, long);
91extern char* utfrune(char*, long);
92extern char* utfrrune(char*, long);
93extern char* utfutf(char*, char*);
94extern char* utfecpy(char*, char*, char*);
95
96extern Rune* runestrcat(Rune*, Rune*);
97extern Rune* runestrchr(Rune*, Rune);
98extern int runestrcmp(Rune*, Rune*);
99extern Rune* runestrcpy(Rune*, Rune*);
100extern Rune* runestrncpy(Rune*, Rune*, long);
101extern Rune* runestrecpy(Rune*, Rune*, Rune*);
102extern Rune* runestrdup(Rune*);
103extern Rune* runestrncat(Rune*, Rune*, long);
104extern int runestrncmp(Rune*, Rune*, long);
105extern Rune* runestrrchr(Rune*, Rune);
106extern long runestrlen(Rune*);
107extern Rune* runestrstr(Rune*, Rune*);
108
109extern Rune tolowerrune(Rune);
110extern Rune totitlerune(Rune);
111extern Rune toupperrune(Rune);
112extern int isalpharune(Rune);
113extern int islowerrune(Rune);
114extern int isspacerune(Rune);
115extern int istitlerune(Rune);
116extern int isupperrune(Rune);
117
118/*
119 * malloc
120 */
121extern void* malloc(size_t);
122extern void* mallocz(ulong, int);
123extern void free(void*);
124extern ulong msize(void*);
125extern void* calloc(size_t, size_t);
126extern void* realloc(void*, size_t);
127extern void setmalloctag(void*, ulong);
128extern void setrealloctag(void*, ulong);
129extern ulong getmalloctag(void*);
130extern ulong getrealloctag(void*);
131extern void* malloctopoolblock(void*);
132
133/*
134 * print routines
135 */
136typedef struct Fmt Fmt;
137struct Fmt{
138 uchar runes; /* output buffer is runes or chars? */
139 void *start; /* of buffer */
140 void *to; /* current place in the buffer */
141 void *stop; /* end of the buffer; overwritten if flush fails */
142 int (*flush)(Fmt *); /* called when to == stop */
143 void *farg; /* to make flush a closure */
144 int nfmt; /* num chars formatted so far */
145 va_list args; /* args passed to dofmt */
146 int r; /* % format Rune */
147 int width;
148 int prec;
149 ulong flags;
150};
151
152enum{
153 FmtWidth = 1,
154 FmtLeft = FmtWidth << 1,
155 FmtPrec = FmtLeft << 1,
156 FmtSharp = FmtPrec << 1,
157 FmtSpace = FmtSharp << 1,
158 FmtSign = FmtSpace << 1,
159 FmtZero = FmtSign << 1,
160 FmtUnsigned = FmtZero << 1,
161 FmtShort = FmtUnsigned << 1,
162 FmtLong = FmtShort << 1,
163 FmtVLong = FmtLong << 1,
164 FmtComma = FmtVLong << 1,
165 FmtByte = FmtComma << 1,
166
167 FmtFlag = FmtByte << 1
168};
169
170extern int print(char*, ...);
171extern char* seprint(char*, char*, char*, ...);
172extern char* vseprint(char*, char*, char*, va_list);
173extern int snprint(char*, int, char*, ...);
174extern int vsnprint(char*, int, char*, va_list);
175extern char* smprint(char*, ...);
176extern char* vsmprint(char*, va_list);
177extern int sprint(char*, char*, ...);
178extern int fprint(int, char*, ...);
179extern int vfprint(int, char*, va_list);
180
181extern int runesprint(Rune*, char*, ...);
182extern int runesnprint(Rune*, int, char*, ...);
183extern int runevsnprint(Rune*, int, char*, va_list);
184extern Rune* runeseprint(Rune*, Rune*, char*, ...);
185extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
186extern Rune* runesmprint(char*, ...);
187extern Rune* runevsmprint(char*, va_list);
188
189extern int fmtfdinit(Fmt*, int, char*, int);
190extern int fmtfdflush(Fmt*);
191extern int fmtstrinit(Fmt*);
192extern char* fmtstrflush(Fmt*);
193extern int runefmtstrinit(Fmt*);
194extern Rune* runefmtstrflush(Fmt*);
195
196extern int fmtinstall(int, int (*)(Fmt*));
197extern int dofmt(Fmt*, char*);
198extern int dorfmt(Fmt*, Rune*);
199extern int fmtprint(Fmt*, char*, ...);
200extern int fmtvprint(Fmt*, char*, va_list);
201extern int fmtrune(Fmt*, int);
202extern int fmtstrcpy(Fmt*, char*);
203extern int fmtrunestrcpy(Fmt*, Rune*);
204/*
205 * error string for %r
206 * supplied on per os basis, not part of fmt library
207 */
208extern int errfmt(Fmt *f);
209
210/*
211 * quoted strings
212 */
213extern char *unquotestrdup(char*);
214extern Rune *unquoterunestrdup(Rune*);
215extern char *quotestrdup(char*);
216extern Rune *quoterunestrdup(Rune*);
217extern int quotestrfmt(Fmt*);
218extern int quoterunestrfmt(Fmt*);
219extern void quotefmtinstall(void);
220extern int (*doquote)(int);
221
222/*
223 * random number
224 */
225extern int nrand(int);
226
227/*
228 * random number
229 */
230extern ulong truerand(void);
231extern ulong ntruerand(ulong);
232
233/*
234 * math
235 */
236extern int isNaN(double);
237extern int isInf(double, int);
238extern double pow(double, double);
239
240/*
241 * Time-of-day
242 */
243
244typedef struct Tm Tm;
245struct Tm {
246 int sec;
247 int min;
248 int hour;
249 int mday;
250 int mon;
251 int year;
252 int wday;
253 int yday;
254 char zone[4];
255 int tzoff;
256};
257extern vlong osnsec(void);
258#define nsec osnsec
259
260/*
261 * one-of-a-kind
262 */
263extern void _assert(char*);
264extern double charstod(int(*)(void*), void*);
265extern char* cleanname(char*);
266extern double frexp(double, int*);
267extern uintptr getcallerpc(void*);
268extern int getfields(char*, char**, int, int, char*);
269extern char* getuser(void);
270extern char* getwd(char*, int);
271extern double ipow10(int);
272extern double ldexp(double, int);
273extern double modf(double, double*);
274#define pow10 infpow10
275extern double pow10(int);
276extern vlong strtoll(const char*, char**, int);
277#define qsort infqsort
278extern void qsort(void*, long, long, int (*)(void*, void*));
279extern uvlong strtoull(const char*, char**, int);
280extern void sysfatal(char*, ...);
281extern int dec64(uchar*, int, char*, int);
282extern int enc64(char*, int, uchar*, int);
283extern int dec32(uchar*, int, char*, int);
284extern int enc32(char*, int, uchar*, int);
285extern int dec16(uchar*, int, char*, int);
286extern int enc16(char*, int, uchar*, int);
287extern int encodefmt(Fmt*);
288
289/*
290 * synchronization
291 */
292typedef
293struct Lock {
294 int val;
295 int pid;
296} Lock;
297
298extern int _tas(int*);
299
300extern void lock(Lock*);
301extern void unlock(Lock*);
302extern int canlock(Lock*);
303
304typedef struct QLock QLock;
305struct QLock
306{
307 Lock use; /* to access Qlock structure */
308 Proc *head; /* next process waiting for object */
309 Proc *tail; /* last process waiting for object */
310 int locked; /* flag */
311};
312
313extern void qlock(QLock*);
314extern void qunlock(QLock*);
315extern int canqlock(QLock*);
316extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
317
318typedef
319struct RWLock
320{
321 Lock l; /* Lock modify lock */
322 QLock x; /* Mutual exclusion lock */
323 QLock k; /* Lock for waiting writers */
324 int readers; /* Count of readers in lock */
325} RWLock;
326
327extern int canrlock(RWLock*);
328extern int canwlock(RWLock*);
329extern void rlock(RWLock*);
330extern void runlock(RWLock*);
331extern void wlock(RWLock*);
332extern void wunlock(RWLock*);
333
334/*
335 * network dialing
336 */
337#define NETPATHLEN 40
338
339/*
340 * system calls
341 *
342 */
343#define STATMAX 65535U /* max length of machine-independent stat structure */
344#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
345#define ERRMAX 128 /* max length of error string */
346
347#define MORDER 0x0003 /* mask for bits defining order of mounting */
348#define MREPL 0x0000 /* mount replaces object */
349#define MBEFORE 0x0001 /* mount goes before others in union directory */
350#define MAFTER 0x0002 /* mount goes after others in union directory */
351#define MCREATE 0x0004 /* permit creation in mounted directory */
352#define MCACHE 0x0010 /* cache some data */
353#define MMASK 0x0017 /* all bits on */
354
355#define OREAD 0 /* open for read */
356#define OWRITE 1 /* write */
357#define ORDWR 2 /* read and write */
358#define OEXEC 3 /* execute, == read but check execute permission */
359#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
360#define OCEXEC 32 /* or'ed in, close on exec */
361#define ORCLOSE 64 /* or'ed in, remove on close */
362#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
363
364#define AEXIST 0 /* accessible: exists */
365#define AEXEC 1 /* execute access */
366#define AWRITE 2 /* write access */
367#define AREAD 4 /* read access */
368
369/* bits in Qid.type */
370#define QTDIR 0x80 /* type bit for directories */
371#define QTAPPEND 0x40 /* type bit for append only files */
372#define QTEXCL 0x20 /* type bit for exclusive use files */
373#define QTMOUNT 0x10 /* type bit for mounted channel */
374#define QTAUTH 0x08 /* type bit for authentication file */
375#define QTFILE 0x00 /* plain file */
376
377/* bits in Dir.mode */
378#define DMDIR 0x80000000 /* mode bit for directories */
379#define DMAPPEND 0x40000000 /* mode bit for append only files */
380#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
381#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
382#define DMAUTH 0x08000000 /* mode bit for authentication file */
383#define DMREAD 0x4 /* mode bit for read permission */
384#define DMWRITE 0x2 /* mode bit for write permission */
385#define DMEXEC 0x1 /* mode bit for execute permission */
386
387typedef
388struct Qid
389{
390 uvlong path;
391 ulong vers;
392 uchar type;
393} Qid;
394
395typedef
396struct Dir {
397 /* system-modified data */
398 ushort type; /* server type */
399 uint dev; /* server subtype */
400 /* file data */
401 Qid qid; /* unique id from server */
402 ulong mode; /* permissions */
403 ulong atime; /* last read time */
404 ulong mtime; /* last write time */
405 vlong length; /* file length */
406 char *name; /* last element of path */
407 char *uid; /* owner name */
408 char *gid; /* group name */
409 char *muid; /* last modifier name */
410} Dir;
411
412extern Dir* dirstat(char*);
413extern Dir* dirfstat(int);
414extern int dirwstat(char*, Dir*);
415extern int dirfwstat(int, Dir*);
416extern long dirread(int, Dir**);
417extern void nulldir(Dir*);
418extern long dirreadall(int, Dir**);
419
420typedef
421struct Waitmsg
422{
423 int pid; /* of loved one */
424 ulong time[3]; /* of loved one & descendants */
425 char *msg;
426} Waitmsg;
427
428extern void _exits(char*);
429
430extern void exits(char*);
431extern int create(char*, int, int);
432extern int errstr(char*, uint);
433
434extern void perror(const char*);
435extern long readn(int, void*, long);
436extern int remove(const char*);
437extern void rerrstr(char*, uint);
438extern vlong seek(int, vlong, int);
439extern int segflush(void*, ulong);
440extern void werrstr(char*, ...);
441
442extern char *argv0;
443#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
444 argv[0] && argv[0][0]=='-' && argv[0][1];\
445 argc--, argv++) {\
446 char *_args, *_argt;\
447 Rune _argc;\
448 _args = &argv[0][1];\
449 if(_args[0]=='-' && _args[1]==0){\
450 argc--; argv++; break;\
451 }\
452 _argc = 0;\
453 while(*_args && (_args += chartorune(&_argc, _args)))\
454 switch(_argc)
455#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
456#define ARGF() (_argt=_args, _args="",\
457 (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
458#define EARGF(x) (_argt=_args, _args="",\
459 (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
460
461#define ARGC() _argc
462
463/*
464 * Extensions for Inferno to basic libc.h
465 */
466
467#define setbinmode()
468
acme/acid/Acid.dis+0−0

Binary file not shown.

acme/acid/Acid0.dis+0−0

Binary file not shown.

acme/acid/guide+2−0
@@ -0,0 +1,2 @@
1Acid pid
2Acid -l alef -l symsfile pid
acme/acid/readme+12−0
@@ -0,0 +1,12 @@
1Capital A Acid is a rudimentary acme interface to the debugger acid.
2It uses a win to provide an interactive window for acid. In that window,
3a couple of extra acme-specific features are enabled:
4
5w(command)
6 runs the command and places its output in a new window.
7 e.g. w(lstk()) places the stack trace in a distinct window.
8
9Also, in any such window, text executed with button 2 is
10presented as input to acid in the main Acid window. Thus, for
11example, one may evaluate variables presented in a stack trace
12by `executing' it with button 2.
acme/bin/guide+5−0
@@ -0,0 +1,5 @@
1win
2new command ...
3aspell file
4adiff file1 file2
5adict -d oed
acme/bin/readme+25−0
@@ -0,0 +1,25 @@
1This directory and its subdirectory $cputype are always mounted at
2the end of /bin for programs run from acme. They hold a collection
3of small acme-specific applications:
4
5win [command]
6 Create an acme window to serve as a terminal, analogous
7 to xterm. By default, it runs the shell, rc, but it works with
8 any interactive program, e.g. hoc. Within the window,
9 commands executed with button 2 are 'executed' by sending
10 their text to the standard input of the command, appending
11 a newline if necessary.
12new command
13 Run the non-interactive command, placing its standard and
14 diagnostic output in a new window.
15aspell file
16 Run spell on the file, labeling the output with addresses so
17 misspelled words can be found in context using button 3.
18adiff file1 file2
19 Run diff on the files, labeling the output with addresses so
20 changes can be found in context using button 3.
21adict
22 Interactive version of dict(1). Button 3 looks up words and
23 may be applied to any word in any adict window.
24 When a word has multiple definitions, indicate the number
25 (as in acme Mail) to disambiguate.
acme/dis/adiff.dis+0−0

Binary file not shown.

acme/dis/agrep.dis+0−0

Binary file not shown.

acme/dis/awd.dis+0−0

Binary file not shown.

acme/dis/cd.dis+0−0

Binary file not shown.

acme/dis/new.dis+0−0

Binary file not shown.

acme/dis/spout.dis+0−0

Binary file not shown.

acme/dis/win.dis+0−0

Binary file not shown.

acme/dis/winm.dis+0−0

Binary file not shown.

acme/edit/a.dis+0−0

Binary file not shown.

acme/edit/c.dis+0−0

Binary file not shown.

acme/edit/d.dis+0−0

Binary file not shown.

acme/edit/e.dis+0−0

Binary file not shown.

acme/edit/g.dis+0−0

Binary file not shown.

acme/edit/guide+4−0
@@ -0,0 +1,4 @@
1e file | x '/regexp/' | c 'replacement'
2e 'file:0,$' | x '/.*word.*\n/' | p -n
3e file | pipe command args ...
4New /absolute/file/name
acme/edit/i.dis+0−0

Binary file not shown.

acme/edit/p.dis+0−0

Binary file not shown.

acme/edit/pipe.dis+0−0

Binary file not shown.

acme/edit/readme+31−0
@@ -0,0 +1,31 @@
1The programs collected in /acme/edit offer a sam-like command interface
2to acme windows. The guide file
3 /acme/edit/guide
4holds templates for several editing operations implemented
5by external programs. These programs, composed in
6a pipeline, refine the sections of a file to be modified.
7Thus in sam when one says
8 x/.*\n/ g/foo/ p
9in /acme/edit one runs
10 x '/.*\n/' | g '/foo/' | p
11The e command, unrelated to e in sam, disambiguates file names, collects
12lists of names, etc., and produces input suitable for the other tools.
13For example:
14 e '/usr/rob/acme:0,$' | x /oldname/ | c /newname/
15changes oldname to newname in all the files loaded in acme whose names match
16the literal text /usr/rob/acme.
17
18The commands in /acme/edit are
19 e
20 x
21 g
22 c
23 d
24 p
25 pipe (like sam's | , which can't be used for syntactic reasons)
26
27p takes a -n flag analogous to grep's -n. There is no s command.
28e has a -l flag to produce line numbers instead of the default character numbers.
29Its implementation is poor but sufficient for the mundane job of recreating
30the occasional line number for tools like acid; its use with the other commands
31in this directory is discouraged.
acme/edit/x.dis+0−0

Binary file not shown.

acme/mail/Mail.dis+0−0

Binary file not shown.

acme/mail/Mailpop3.dis+0−0

Binary file not shown.

acme/mail/guide+5−0
@@ -0,0 +1,5 @@
1Mail /mail/box/$user/stored
2Mail
3Mailpop3
4mkbox /mail/box/$user/new_box
5mail -'x' someaddress
acme/mail/mkbox.dis+0−0

Binary file not shown.

acme/mail/readme+29−0
@@ -0,0 +1,29 @@
1Mail is the single program in this directory. Its argument specifies
2the mail box to read, default /mail/box/$user/mbox.
3For example, running
4 Mail /mail/box/$user/stored
5(a line in the guide file) looks at saved mail.
6
7Mail maintains a window containing headers for all the
8messages in the mailbox and monitors the mailbox for new messages.
9Using button 3 to indicate a message number opens
10a window on that message. commands in the mailbox window are
11 Put Write the mailbox back to the file (never done automatically)
12 Mail Make a new message window ready to mail someone.
13 Takes argument names analogously to acme's New.
14 Del Exit Mail, after checking that mailbox isn't modified.
15New messages appear at the top of the window and are highlighted upon arrival.
16(The messages are numbered oldest to newest, the opposite of regular mail.)
17
18Message windows have a simple format: the first line, up to the first tab or newline,
19holds the sender or, when sending, the addressee. Edit the line to change who the
20message goes to. Message windows contain the commands
21 Reply Make a new window to compose a reply to this message
22 Delmesg Delete the message from the screen and from the mailbox
23 Del Delete the window, leaving the message in the mailbox
24 Post Send the message to the addressee
25 Save Save to the named mailbox, default/mail/box/$user/stored
26Save takes a full file name; if that name has no slashes, the file is taken
27to be in /mail/box/$user and must already exist. Use mkbox in the guide to
28create target mailboxes in /mail/box/$user.
29Reply and mail windows contain an obvious subset of the commands.
appl/NOTICE+25−0
@@ -0,0 +1,25 @@
1This copyright NOTICE applies to all files in this directory and
2subdirectories, unless another copyright notice appears in a given
3file or subdirectory. If you take substantial code from this software to use in
4other programs, you must somehow include with it an appropriate
5copyright notice that includes the copyright notice and the other
6notices below. It is fine (and often tidier) to do that in a separate
7file such as NOTICE, LICENCE or COPYING.
8
9Copyright © 1995-1999 Lucent Technologies Inc.
10Portions Copyright © 1997-2000 Vita Nuova Limited
11Portions Copyright © 2000-2010 Vita Nuova Holdings Limited
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 2 of the License, or
16(at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
appl/acme/acme.b+1112−0
@@ -0,0 +1,1112 @@
1implement Acme;
2
3include "common.m";
4
5sys : Sys;
6bufio : Bufio;
7workdir : Workdir;
8drawm : Draw;
9styx : Styx;
10acme : Acme;
11gui : Gui;
12graph : Graph;
13dat : Dat;
14framem : Framem;
15utils : Utils;
16regx : Regx;
17scrl : Scroll;
18textm : Textm;
19filem : Filem;
20windowm : Windowm;
21rowm : Rowm;
22columnm : Columnm;
23bufferm : Bufferm;
24diskm : Diskm;
25exec : Exec;
26look : Look;
27timerm : Timerm;
28fsys : Fsys;
29xfidm : Xfidm;
30plumbmsg : Plumbmsg;
31editm: Edit;
32editlog: Editlog;
33editcmd: Editcmd;
34styxaux: Styxaux;
35
36sprint : import sys;
37BACK, HIGH, BORD, TEXT, HTEXT, NCOL : import Framem;
38Point, Rect, Font, Image, Display, Pointer: import drawm;
39TRUE, FALSE, maxtab : import dat;
40Ref, Reffont, Command, Timer, Lock, Cursor : import dat;
41row, reffont, activecol, mouse, typetext, mousetext, barttext, argtext, seltext, button, modbutton, colbutton, arrowcursor, boxcursor, plumbed : import dat;
42Xfid : import xfidm;
43cmouse, ckeyboard, cwait, ccommand, ckill, cxfidalloc, cxfidfree, cerr, cplumb, cedit : import dat;
44font, bflush, balloc, draw : import graph;
45Arg, PNPROC, PNGROUP : import utils;
46arginit, argopt, argf, error, warning, postnote : import utils;
47yellow, green, red, blue, black, white, mainwin, display : import gui;
48Disk : import diskm;
49Row : import rowm;
50Column : import columnm;
51Window : import windowm;
52Text, Tag, Body, Columntag : import textm;
53Buffer : import bufferm;
54snarfbuf : import exec;
55Msg : import plumbmsg;
56
57tfd : ref Sys->FD;
58lasttime : int;
59
60init(ctxt : ref Draw->Context, argl : list of string)
61{
62 acmectxt = ctxt;
63
64 sys = load Sys Sys->PATH;
65 sys->pctl(Sys->NEWPGRP, nil);
66
67 {
68 # tfd = sys->create("./time", Sys->OWRITE, 8r600);
69 # lasttime = sys->millisec();
70 bufio = load Bufio Bufio->PATH;
71 workdir = load Workdir Workdir->PATH;
72 drawm = load Draw Draw->PATH;
73
74 styx = load Styx Styx->PATH;
75
76 acme = load Acme SELF;
77
78 gui = load Gui path(Gui->PATH);
79 graph = load Graph path(Graph->PATH);
80 dat = load Dat path(Dat->PATH);
81 framem = load Framem path(Framem->PATH);
82 utils = load Utils path(Utils->PATH);
83 regx = load Regx path(Regx->PATH);
84 scrl = load Scroll path(Scroll->PATH);
85 textm = load Textm path(Textm->PATH);
86 filem = load Filem path(Filem->PATH);
87 windowm = load Windowm path(Windowm->PATH);
88 rowm = load Rowm path(Rowm->PATH);
89 columnm = load Columnm path(Columnm->PATH);
90 bufferm = load Bufferm path(Bufferm->PATH);
91 diskm = load Diskm path(Diskm->PATH);
92 exec = load Exec path(Exec->PATH);
93 look = load Look path(Look->PATH);
94 timerm = load Timerm path(Timerm->PATH);
95 fsys = load Fsys path(Fsys->PATH);
96 xfidm = load Xfidm path(Xfidm->PATH);
97 plumbmsg = load Plumbmsg Plumbmsg->PATH;
98 editm = load Edit path(Edit->PATH);
99 editlog = load Editlog path(Editlog->PATH);
100 editcmd = load Editcmd path(Editcmd->PATH);
101 styxaux = load Styxaux path(Styxaux->PATH);
102
103 mods := ref Dat->Mods(sys, bufio, drawm, styx, styxaux,
104 acme, gui, graph, dat, framem,
105 utils, regx, scrl,
106 textm, filem, windowm, rowm, columnm,
107 bufferm, diskm, exec, look, timerm,
108 fsys, xfidm, plumbmsg, editm, editlog, editcmd);
109
110 styx->init();
111 styxaux->init();
112
113 utils->init(mods);
114 gui->init(mods);
115 graph->init(mods);
116 dat->init(mods);
117 framem->init(mods);
118 regx->init(mods);
119 scrl->init(mods);
120 textm->init(mods);
121 filem->init(mods);
122 windowm->init(mods);
123 rowm->init(mods);
124 columnm->init(mods);
125 bufferm->init(mods);
126 diskm->init(mods);
127 exec->init(mods);
128 look->init(mods);
129 timerm->init(mods);
130 fsys->init(mods);
131 xfidm->init(mods);
132 editm->init(mods);
133 editlog->init(mods);
134 editcmd->init(mods);
135
136 utils->debuginit();
137
138 if (plumbmsg->init(1, "edit", Dat->PLUMBSIZE) >= 0)
139 plumbed = 1;
140
141 main(argl);
142
143 }
144# exception{
145# * =>
146# sys->fprint(sys->fildes(2), "acme: fatal: %s\n", utils->getexc());
147# sys->print("acme: fatal: %s\n", utils->getexc());
148# shutdown("error");
149# }
150}
151
152timing(s : string)
153{
154 thistime := sys->millisec();
155 sys->fprint(tfd, "%s %d\n", s, thistime-lasttime);
156 lasttime = thistime;
157}
158
159path(p : string) : string
160{
161 if (RELEASECOPY)
162 return p;
163 else {
164 # inlined strrchr since not loaded yet
165 for (n := len p - 1; n >= 0; n--)
166 if (p[n] == '/')
167 break;
168 if (n >= 0)
169 p = p[n+1:];
170 return "/usr/jrf/acme/" + p;
171 }
172}
173
174waitpid0, waitpid1 : int;
175mainpid : int;
176
177fontcache : array of ref Reffont;
178nfontcache : int;
179reffonts : array of ref Reffont;
180deffontnames := array[2] of {
181 "/fonts/lucidasans/euro.8.font",
182 "/fonts/lucm/unicode.9.font",
183};
184
185command : ref Command;
186
187WPERCOL : con 8;
188
189NSnarf : con 32;
190snarfrune : ref Dat->Astring;
191
192main(argl : list of string)
193{
194 i, ac : int;
195 loadfile : string;
196 p : int;
197 c : ref Column;
198 arg : ref Arg;
199 ncol : int;
200
201 ncol = -1;
202
203 mainpid = sys->pctl(0, nil);
204 loadfile = nil;
205 fontnames = array[2] of string;
206 fontnames[0:] = deffontnames[0:2];
207 f := utils->getenv("acme-font");
208 if (f != nil)
209 fontnames[0] = f;
210 f = utils->getenv("acme-Font");
211 if (f != nil)
212 fontnames[1] = f;
213 arg = arginit(argl);
214 while(ac = argopt(arg)) case(ac){
215 'b' =>
216 dat->bartflag = TRUE;
217 'c' =>
218 ncol = int argf(arg);
219 'f' =>
220 fontnames[0] = argf(arg);
221 'F' =>
222 fontnames[1] = argf(arg);
223 'l' =>
224 loadfile = argf(arg);
225 }
226
227 dat->home = utils->getenv("home");
228 if (dat->home == nil)
229 dat->home = utils->gethome(utils->getuser());
230 ts := utils->getenv("tabstop");
231 if (ts != nil)
232 maxtab = int ts;
233 if (maxtab <= 0)
234 maxtab = 4;
235 snarfrune = utils->stralloc(NSnarf);
236 sys->pctl(Sys->FORKNS|Sys->FORKENV, nil);
237 utils->setenv("font", fontnames[0]);
238 sys->bind("/acme/dis", "/dis", Sys->MBEFORE);
239 wdir = workdir->init();
240 if (wdir == nil)
241 wdir = ".";
242 workdir = nil;
243
244 graph->binit();
245 font = Font.open(display, fontnames[0]);
246 if(font == nil){
247 fontnames[0] = deffontnames[0];
248 font = Font.open(display, fontnames[0]);
249 if (font == nil) {
250 warning(nil, sprint("can't open font file %s: %r\n", fontnames[0]));
251 return;
252 }
253 }
254 reffont = ref Reffont;
255 reffont.r = Ref.init();
256 reffont.f = font;
257 reffonts = array[2] of ref Reffont;
258 reffonts[0] = reffont;
259 reffont.r.inc(); # one to hold up 'font' variable
260 reffont.r.inc(); # one to hold up reffonts[0]
261 fontcache = array[1] of ref Reffont;
262 nfontcache = 1;
263 fontcache[0] = reffont;
264
265 iconinit();
266 usercolinit();
267 timerm->timerinit();
268 regx->rxinit();
269
270 cwait = chan of string;
271 ccommand = chan of ref Command;
272 ckill = chan of string;
273 cxfidalloc = chan of ref Xfid;
274 cxfidfree = chan of ref Xfid;
275 cerr = chan of string;
276 cplumb = chan of ref Msg;
277 cedit = chan of int;
278
279 gui->spawnprocs();
280 # spawn keyboardproc();
281 # spawn mouseproc();
282 sync := chan of int;
283 spawn waitproc(sys->pctl(0, nil), sync);
284 <- sync;
285 spawn plumbproc();
286
287 fsys->fsysinit();
288 dat->disk = (dat->disk).init();
289 row = rowm->newrow();
290 if(loadfile != nil) {
291 row.qlock.lock(); # tasks->procs now
292 row.loadx(loadfile, TRUE);
293 row.qlock.unlock();
294 }
295 else{
296 row.init(mainwin.clipr);
297 if(ncol < 0){
298 if(arg.av == nil)
299 ncol = 2;
300 else{
301 ncol = (len arg.av+(WPERCOL-1))/WPERCOL;
302 if(ncol < 2)
303 ncol = 2;
304 }
305 }
306 if(ncol == 0)
307 ncol = 2;
308 for(i=0; i<ncol; i++){
309 c = row.add(nil, -1);
310 if(c==nil && i==0)
311 error("initializing columns");
312 }
313 c = row.col[row.ncol-1];
314 if(arg.av == nil)
315 readfile(c, wdir);
316 else
317 i = 0;
318 for( ; arg.av != nil; arg.av = tl arg.av){
319 filen := hd arg.av;
320 p = utils->strrchr(filen, '/');
321 if((p>=0 && filen[p:] == "/guide") || i/WPERCOL>=row.ncol)
322 readfile(c, filen);
323 else
324 readfile(row.col[i/WPERCOL], filen);
325 i++;
326 }
327 }
328 bflush();
329
330 spawn keyboardtask();
331 spawn mousetask();
332 spawn waittask();
333 spawn xfidalloctask();
334
335 # notify(shutdown);
336 # waitc := chan of int;
337 # <-waitc;
338 # killprocs();
339 exit;
340}
341
342readfile(c : ref Column, s : string)
343{
344 w : ref Window;
345 r : string;
346 nr : int;
347
348 w = c.add(nil, nil, -1);
349 (r, nr) = look->cleanname(s, len s);
350 w.setname(r, nr);
351 w.body.loadx(0, s, 1);
352 w.body.file.mod = FALSE;
353 w.dirty = FALSE;
354 w.settag();
355 scrl->scrdraw(w.body);
356 w.tag.setselect(w.tag.file.buf.nc, w.tag.file.buf.nc);
357}
358
359oknotes := array[6] of {
360 "delete",
361 "hangup",
362 "kill",
363 "exit",
364 "error",
365 nil
366};
367
368dumping : int;
369
370shutdown(msg : string)
371{
372 i : int;
373
374 # notify(nil);
375 if(!dumping && msg != "kill" && msg != "exit" && (1 || sys->pctl(0, nil)==mainpid) && row != nil){
376 dumping = TRUE;
377 row.dump(nil);
378 }
379 for(i=0; oknotes[i] != nil; i++)
380 if(utils->strncmp(oknotes[i], msg, len oknotes[i]) == 0) {
381 killprocs();
382 exit;
383 }
384 # killprocs();
385 sys->fprint(sys->fildes(2), "acme: %s\n", msg);
386 sys->print("acme: %s\n", msg);
387 # exit;
388}
389
390acmeexit(err: string)
391{
392 if(err != nil)
393 shutdown(err);
394 graph->cursorswitch(nil);
395 if (plumbed)
396 plumbmsg->shutdown();
397 killprocs();
398 gui->killwins();
399 exit;
400}
401
402killprocs()
403{
404 c : ref Command;
405 kill := "kill";
406 thispid := sys->pctl(0, nil);
407 fsys->fsysclose();
408
409 postnote(PNPROC, thispid, mousepid, kill);
410 postnote(PNPROC, thispid, keyboardpid, kill);
411 postnote(PNPROC, thispid, timerpid, kill);
412 postnote(PNPROC, thispid, waitpid0, kill);
413 postnote(PNPROC, thispid, waitpid1, kill);
414 postnote(PNPROC, thispid, fsyspid, kill);
415 postnote(PNPROC, thispid, mainpid, kill);
416 postnote(PNPROC, thispid, keytid, kill);
417 postnote(PNPROC, thispid, mousetid, kill);
418 postnote(PNPROC, thispid, waittid, kill);
419 postnote(PNPROC, thispid, xfidalloctid, kill);
420 # postnote(PNPROC, thispid, lockpid, kill);
421 postnote(PNPROC, thispid, plumbpid, kill);
422
423 # draw(mainwin, mainwin.r, white, nil, mainwin.r.min);
424
425 for(c=command; c != nil; c=c.next)
426 postnote(PNGROUP, thispid, c.pid, "kill");
427
428 xfidm->xfidkill();
429}
430
431keytid : int;
432mousetid : int;
433waittid : int;
434xfidalloctid : int;
435
436keyboardtask()
437{
438 r : int;
439 timer : ref Timer;
440 null : ref Timer;
441 t : ref Text;
442
443 {
444 keytid = sys->pctl(0, nil);
445 null = ref Timer;
446 null.c = chan of int;
447 timer = null;
448 typetext = nil;
449 for(;;){
450 alt{
451 <-(timer.c) =>
452 timerm->timerstop(timer);
453 t = typetext;
454 if(t!=nil && t.what==Tag && !t.w.qlock.locked()){
455 t.w.lock('K');
456 t.w.commit(t);
457 t.w.unlock();
458 bflush();
459 }
460 timer = null;
461 r = <-ckeyboard =>
462 gotkey := 1;
463 while (gotkey) {
464 typetext = row.typex(r, mouse.xy);
465 t = typetext;
466 if(t!=nil && t.col!=nil)
467 activecol = t.col;
468 if(t!=nil && t.w!=nil)
469 t.w.body.file.curtext = t.w.body;
470 if(timer != null)
471 spawn timerm->timerwaittask(timer);
472 if(t!=nil && t.what==Tag)
473 timer = timerm->timerstart(500);
474 else
475 timer = null;
476 alt {
477 r = <- ckeyboard =>
478 gotkey = 1; # do this case again
479 * =>
480 gotkey = 0;
481 }
482 bflush();
483 }
484 }
485 }
486 }
487 exception{
488 * =>
489 shutdown(utils->getexc());
490 raise;
491 # acmeexit(nil);
492 }
493}
494
495mousetask()
496{
497 t, argt : ref Text;
498 but, ok : int;
499 q0, q1 : int;
500 w : ref Window;
501 m : ref Msg;
502
503 {
504 mousetid = sys->pctl(0, nil);
505 sync := chan of int;
506 spawn waitproc(mousetid, sync);
507 <- sync;
508 for(;;){
509 alt{
510 *mouse = *<-cmouse =>
511 row.qlock.lock();
512 if (mouse.buttons & M_QUIT) {
513 if (row.clean(TRUE))
514 acmeexit(nil);
515 # shutdown("kill");
516 row.qlock.unlock();
517 break;
518 }
519 if (mouse.buttons & M_HELP) {
520 warning(nil, "no help provided (yet)");
521 bflush();
522 row.qlock.unlock();
523 break;
524 }
525 if(mouse.buttons & M_RESIZE){
526 draw(mainwin, mainwin.r, white, nil, mainwin.r.min);
527 scrl->scrresize();
528 row.reshape(mainwin.clipr);
529 bflush();
530 row.qlock.unlock();
531 break;
532 }
533 t = row.which(mouse.xy);
534 if(t!=mousetext && mousetext!=nil && mousetext.w!=nil){
535 mousetext.w.lock('M');
536 mousetext.eq0 = ~0;
537 mousetext.w.commit(mousetext);
538 mousetext.w.unlock();
539 }
540 mousetext = t;
541 if(t == nil) {
542 bflush();
543 row.qlock.unlock();
544 break;
545 }
546 w = t.w;
547 if(t==nil || mouse.buttons==0) {
548 bflush();
549 row.qlock.unlock();
550 break;
551 }
552 if(w != nil)
553 w.body.file.curtext = w.body;
554 but = 0;
555 if(mouse.buttons == 1)
556 but = 1;
557 else if(mouse.buttons == 2)
558 but = 2;
559 else if(mouse.buttons == 4)
560 but = 3;
561 barttext = t;
562 if(t.what==Body && mouse.xy.in(t.scrollr)){
563 if(but){
564 w.lock('M');
565 t.eq0 = ~0;
566 scrl->scroll(t, but);
567 t.w.unlock();
568 }
569 bflush();
570 row.qlock.unlock();
571 break;
572 }
573 if(mouse.xy.in(t.scrollr)){
574 if(but){
575 if(t.what == Columntag)
576 row.dragcol(t.col);
577 else if(t.what == Tag){
578 t.col.dragwin(t.w, but);
579 if(t.w != nil)
580 barttext = t.w.body;
581 }
582 if(t.col != nil)
583 activecol = t.col;
584 }
585 bflush();
586 row.qlock.unlock();
587 break;
588 }
589 if(mouse.buttons){
590 if(w != nil)
591 w.lock('M');
592 t.eq0 = ~0;
593 if(w != nil)
594 w.commit(t);
595 else
596 t.commit(TRUE);
597 if(mouse.buttons & 1){
598 t.select(0);
599 if(w != nil)
600 w.settag();
601 argtext = t;
602 seltext = t;
603 if(t.col != nil)
604 activecol = t.col; # button 1 only
605 if(t.w != nil && t == t.w.body)
606 dat->activewin = t.w;
607 }else if(mouse.buttons & 2){
608 (ok, argt, q0, q1) = t.select2(q0, q1);
609 if(ok)
610 exec->execute(t, q0, q1, FALSE, argt);
611 }else if(mouse.buttons & 4){
612 (ok, q0, q1) = t.select3(q0, q1);
613 if(ok)
614 look->look3(t, q0, q1, FALSE);
615 }
616 if(w != nil)
617 w.unlock();
618 bflush();
619 row.qlock.unlock();
620 break;
621 }
622 m = <- cplumb =>
623 if (m.kind == "text") {
624 attrs := plumbmsg->string2attrs(m.attr);
625 (found, act) := plumbmsg->lookup(attrs, "action");
626 if (!found || act == nil || act == "showfile")
627 look->plumblook(m);
628 else if (act == "showdata")
629 look->plumbshow(m);
630 }
631 bflush();
632 }
633 }
634 }
635 exception{
636 * =>
637 shutdown(utils->getexc());
638 raise;
639 # acmeexit(nil);
640 }
641}
642
643# list of processes that have exited but we have not heard of yet
644Pid : adt {
645 pid : int;
646 msg : string;
647 next : cyclic ref Pid;
648};
649
650waittask()
651{
652 status : string;
653 c, lc : ref Command;
654 pid : int;
655 found : int;
656 cmd : string;
657 err : string;
658 t : ref Text;
659 pids : ref Pid;
660
661 waittid = sys->pctl(0, nil);
662 command = nil;
663 for(;;){
664 alt{
665 err = <-cerr =>
666 row.qlock.lock();
667 warning(nil, err);
668 err = nil;
669 bflush();
670 row.qlock.unlock();
671 break;
672 cmd = <-ckill =>
673 found = FALSE;
674 for(c=command; c != nil; c=c.next){
675 # -1 for blank
676 if(c.name[0:len c.name - 1] == cmd){
677 if(postnote(PNGROUP, waittid, c.pid, "kill") < 0)
678 warning(nil, sprint("kill %s: %r\n", cmd));
679 found = TRUE;
680 }
681 }
682 if(!found)
683 warning(nil, sprint("Kill: no process %s\n", cmd));
684 cmd = nil;
685 break;
686 status = <-cwait =>
687 pid = int status;
688 lc = nil;
689 for(c=command; c != nil; c=c.next){
690 if(c.pid == pid){
691 if(lc != nil)
692 lc.next = c.next;
693 else
694 command = c.next;
695 break;
696 }
697 lc = c;
698 }
699 row.qlock.lock();
700 t = row.tag;
701 t.commit(TRUE);
702 if(c == nil){
703 # warning(nil, sprint("unknown child pid %d\n", pid));
704 p := ref Pid;
705 p.pid = pid;
706 p.msg = status;
707 p.next = pids;
708 pids = p;
709 }
710 else{
711 if(look->search(t, c.name, len c.name)){
712 t.delete(t.q0, t.q1, TRUE);
713 t.setselect(0, 0);
714 }
715 if(status[len status - 1] != ':')
716 warning(c.md, sprint("%s\n", status));
717 bflush();
718 }
719 row.qlock.unlock();
720 if(c != nil){
721 if(c.iseditcmd)
722 cedit <- = 0;
723 fsys->fsysdelid(c.md);
724 c = nil;
725 }
726 break;
727 c = <-ccommand =>
728 lastp : ref Pid = nil;
729 for(p := pids; p != nil; p = p.next){
730 if(p.pid == c.pid){
731 status = p.msg;
732 if(status[len status - 1] != ':')
733 warning(c.md, sprint("%s\n", status));
734 if(lastp == nil)
735 pids = p.next;
736 else
737 lastp.next = p.next;
738 if(c.iseditcmd)
739 cedit <- = 0;
740 fsys->fsysdelid(c.md);
741 c = nil;
742 break;
743 }
744 lastp = p;
745 }
746 c.next = command;
747 command = c;
748 row.qlock.lock();
749 t = row.tag;
750 t.commit(TRUE);
751 t.insert(0, c.name, len c.name, TRUE, 0);
752 t.setselect(0, 0);
753 bflush();
754 row.qlock.unlock();
755 break;
756 }
757 }
758}
759
760xfidalloctask()
761{
762 xfree, x : ref Xfid;
763
764 xfidalloctid = sys->pctl(0, nil);
765 xfree = nil;
766 for(;;){
767 alt{
768 <-cxfidalloc =>
769 x = xfree;
770 if(x != nil)
771 xfree = x.next;
772 else{
773 x = xfidm->newxfid();
774 x.c = chan of int;
775 spawn x.ctl();
776 }
777 cxfidalloc <-= x;
778 break;
779 x = <-cxfidfree =>
780 x.next = xfree;
781 xfree = x;
782 break;
783 }
784 }
785}
786
787frgetmouse()
788{
789 bflush();
790 *mouse = *<-cmouse;
791}
792
793waitproc(pid : int, sync: chan of int)
794{
795 fd : ref Sys->FD;
796 n : int;
797
798 if (waitpid0 == 0)
799 waitpid0 = sys->pctl(0, nil);
800 else
801 waitpid1 = sys->pctl(0, nil);
802 sys->pctl(Sys->FORKFD, nil);
803 # w := sprint("/prog/%d/wait", pid);
804 w := sprint("#p/%d/wait", pid);
805 fd = sys->open(w, Sys->OREAD);
806 if (fd == nil)
807 error("fd == nil in waitproc");
808 sync <-= 0;
809 buf := array[Sys->WAITLEN] of byte;
810 status := "";
811 for(;;){
812 if ((n = sys->read(fd, buf, len buf))<0)
813 error("bad read in waitproc");
814 status = string buf[0:n];
815 cwait <-= status;
816 }
817}
818
819get(fix : int, save : int, setfont : int, name : string) : ref Reffont
820{
821 r : ref Reffont;
822 f : ref Font;
823 i : int;
824
825 r = nil;
826 if(name == nil){
827 name = fontnames[fix];
828 r = reffonts[fix];
829 }
830 if(r == nil){
831 for(i=0; i<nfontcache; i++)
832 if(name == fontcache[i].f.name){
833 r = fontcache[i];
834 break;
835 }
836 if (i >= nfontcache) {
837 f = Font.open(display, name);
838 if(f == nil){
839 warning(nil, sprint("can't open font file %s: %r\n", name));
840 return nil;
841 }
842 r = ref Reffont;
843 r.r = Ref.init();
844 r.f = f;
845 ofc := fontcache;
846 fontcache = array[nfontcache+1] of ref Reffont;
847 fontcache[0:] = ofc[0:nfontcache];
848 ofc = nil;
849 fontcache[nfontcache++] = r;
850 }
851 }
852 if(save){
853 r.r.inc();
854 if(reffonts[fix] != nil)
855 reffonts[fix].close();
856 reffonts[fix] = r;
857 fontnames[fix] = name;
858 }
859 if(setfont){
860 reffont.f = r.f;
861 r.r.inc();
862 reffonts[0].close();
863 font = r.f;
864 reffonts[0] = r;
865 r.r.inc();
866 iconinit();
867 }
868 r.r.inc();
869 return r;
870}
871
872close(r : ref Reffont)
873{
874 i : int;
875
876 if(r.r.dec() == 0){
877 for(i=0; i<nfontcache; i++)
878 if(r == fontcache[i])
879 break;
880 if(i >= nfontcache)
881 warning(nil, "internal error: can't find font in cache\n");
882 else{
883 fontcache[i:] = fontcache[i+1:nfontcache];
884 nfontcache--;
885 }
886 r.f = nil;
887 r = nil;
888 }
889}
890
891arrowbits := array[64] of {
892 byte 16rFF, byte 16rE0, byte 16rFF, byte 16rE0,
893 byte 16rFF, byte 16rC0, byte 16rFF, byte 16r00,
894 byte 16rFF, byte 16r00, byte 16rFF, byte 16r80,
895 byte 16rFF, byte 16rC0, byte 16rFF, byte 16rE0,
896 byte 16rE7, byte 16rF0, byte 16rE3, byte 16rF8,
897 byte 16rC1, byte 16rFC, byte 16r00, byte 16rFE,
898 byte 16r00, byte 16r7F, byte 16r00, byte 16r3E,
899 byte 16r00, byte 16r1C, byte 16r00, byte 16r08,
900
901 byte 16r00, byte 16r00, byte 16r7F, byte 16rC0,
902 byte 16r7F, byte 16r00, byte 16r7C, byte 16r00,
903 byte 16r7E, byte 16r00, byte 16r7F, byte 16r00,
904 byte 16r6F, byte 16r80, byte 16r67, byte 16rC0,
905 byte 16r43, byte 16rE0, byte 16r41, byte 16rF0,
906 byte 16r00, byte 16rF8, byte 16r00, byte 16r7C,
907 byte 16r00, byte 16r3E, byte 16r00, byte 16r1C,
908 byte 16r00, byte 16r08, byte 16r00, byte 16r00,
909};
910
911# outer boundary of width 1 is white
912# next boundary of width 3 is black
913# next boundary of width 1 is white
914# inner boundary of width 4 is transparent
915boxbits := array[64] of {
916 byte 16rFF, byte 16rFF, byte 16rFF, byte 16rFF,
917 byte 16rFF, byte 16rFF, byte 16rFF, byte 16rFF,
918 byte 16rFF, byte 16rFF, byte 16rF8, byte 16r1F,
919 byte 16rF8, byte 16r1F, byte 16rF8, byte 16r1F,
920 byte 16rF8, byte 16r1F, byte 16rF8, byte 16r1F,
921 byte 16rF8, byte 16r1F, byte 16rFF, byte 16rFF,
922 byte 16rFF, byte 16rFF, byte 16rFF, byte 16rFF,
923 byte 16rFF, byte 16rFF, byte 16rFF, byte 16rFF,
924
925
926 byte 16r00, byte 16r00, byte 16r7F, byte 16rFE,
927 byte 16r7F, byte 16rFE, byte 16r7F, byte 16rFE,
928 byte 16r70, byte 16r0E, byte 16r70, byte 16r0E,
929 byte 16r70, byte 16r0E, byte 16r70, byte 16r0E,
930 byte 16r70, byte 16r0E, byte 16r70, byte 16r0E,
931 byte 16r70, byte 16r0E, byte 16r70, byte 16r0E,
932 byte 16r7F, byte 16rFE, byte 16r7F, byte 16rFE,
933 byte 16r7F, byte 16rFE, byte 16r00, byte 16r00,
934};
935
936iconinit()
937{
938 r : Rect;
939
940 # Blue
941 tagcols = array[NCOL] of ref Draw->Image;
942 tagcols[BACK] = display.colormix(Draw->Palebluegreen, Draw->White);
943 tagcols[HIGH] = display.color(Draw->Palegreygreen);
944 tagcols[BORD] = display.color(Draw->Purpleblue);
945 tagcols[TEXT] = black;
946 tagcols[HTEXT] = black;
947
948 # Yellow
949 textcols = array[NCOL] of ref Draw->Image;
950 textcols[BACK] = display.colormix(Draw->Paleyellow, Draw->White);
951 textcols[HIGH] = display.color(Draw->Darkyellow);
952 textcols[BORD] = display.color(Draw->Yellowgreen);
953 textcols[TEXT] = black;
954 textcols[HTEXT] = black;
955
956 if(button != nil)
957 button = modbutton = colbutton = nil;
958
959 r = ((0, 0), (Dat->Scrollwid+2, font.height+1));
960 button = balloc(r, mainwin.chans, Draw->White);
961 draw(button, r, tagcols[BACK], nil, r.min);
962 r.max.x -= 2;
963 draw(button, r, tagcols[BORD], nil, (0, 0));
964 r = r.inset(2);
965 draw(button, r, tagcols[BACK], nil, (0, 0));
966
967 r = button.r;
968 modbutton = balloc(r, mainwin.chans, Draw->White);
969 draw(modbutton, r, tagcols[BACK], nil, r.min);
970 r.max.x -= 2;
971 draw(modbutton, r, tagcols[BORD], nil, (0, 0));
972 r = r.inset(2);
973 draw(modbutton, r, display.rgb(16r00, 16r00, 16r99), nil, (0, 0)); # was DMedblue
974
975 r = button.r;
976 colbutton = balloc(r, mainwin.chans, Draw->White);
977 draw(colbutton, r, tagcols[BACK], nil, r.min);
978 r.max.x -= 2;
979 draw(colbutton, r, tagcols[BORD], nil, (0, 0));
980
981# arrowcursor = ref Cursor((-1, -1), (16, 32), arrowbits);
982 boxcursor = ref Cursor((-7, -7), (16, 32), boxbits);
983
984 but2col = display.rgb(16raa, 16r00, 16r00);
985 but3col = display.rgb(16r00, 16r66, 16r00);
986 but2colt = white;
987 but3colt = white;
988
989 graph->cursorswitch(arrowcursor);
990}
991
992colrec : adt {
993 name : string;
994 image : ref Image;
995};
996
997coltab : array of colrec;
998
999cinit()
1000{
1001 coltab = array[6] of colrec;
1002 coltab[0].name = "yellow"; coltab[0].image = yellow;
1003 coltab[1].name = "green"; coltab[1].image = green;
1004 coltab[2].name = "red"; coltab[2].image = red;
1005 coltab[3].name = "blue"; coltab[3].image = blue;
1006 coltab[4].name = "black"; coltab[4].image = black;
1007 coltab[5].name = "white"; coltab[5].image = white;
1008}
1009
1010col(s : string, n : int) : int
1011{
1012 return ((s[n]-'0') << 4) | (s[n+1]-'0');
1013}
1014
1015rgb(s : string, n : int) : (int, int, int)
1016{
1017 return (col(s, n), col(s, n+2), col(s, n+4));
1018}
1019
1020cenv(s : string, t : string, but : int, i : ref Image) : ref Image
1021{
1022 c := utils->getenv("acme-" + s + "-" + t + "-" + string but);
1023 if (c == nil)
1024 c = utils->getenv("acme-" + s + "-" + string but);
1025 if (c == nil && but != 0)
1026 c = utils->getenv("acme-" + s);
1027 if (c != nil) {
1028 if (c[0] == '#' && len c >= 7) {
1029 (r1, g1, b1) := rgb(c, 1);
1030 if (len c >= 15 && c[7] == '/' && c[8] == '#') {
1031 (r2, g2, b2) := rgb(c, 9);
1032 return display.colormix((r1<<24)|(g1<<16)|(b1<<8)|16rFF, (r2<<24)|(g2<<16)|(b2<<8)|16rFF);
1033 }
1034 return display.color((r1<<24)|(g1<<16)|(b1<<8)|16rFF);
1035 }
1036 for (j := 0; j < len c; j++)
1037 if (c[j] >= 'A' && c[j] <= 'Z')
1038 c[j] += 'a'-'A';
1039 for (j = 0; j < len coltab; j++)
1040 if (c == coltab[j].name)
1041 return coltab[j].image;
1042 }
1043 return i;
1044}
1045
1046usercolinit()
1047{
1048 cinit();
1049 textcols[TEXT] = cenv("fg", "text", 0, textcols[TEXT]);
1050 textcols[BACK] = cenv("bg", "text", 0, textcols[BACK]);
1051 textcols[HTEXT] = cenv("fg", "text", 1, textcols[HTEXT]);
1052 textcols[HIGH] = cenv("bg", "text", 1, textcols[HIGH]);
1053 but2colt= cenv("fg", "text", 2, but2colt);
1054 but2col = cenv("bg", "text", 2, but2col);
1055 but3colt = cenv("fg", "text", 3, but3colt);
1056 but3col = cenv("bg", "text", 3, but3col);
1057 tagcols[TEXT] = cenv("fg", "tag", 0, tagcols[TEXT]);
1058 tagcols[BACK] = cenv("bg", "tag", 0, tagcols[BACK]);
1059 tagcols[HTEXT] = cenv("fg", "tag", 1, tagcols[HTEXT]);
1060 tagcols[HIGH] = cenv("bg", "tag", 1, tagcols[HIGH]);
1061}
1062
1063getsnarf()
1064{
1065 # return;
1066 fd := sys->open("/chan/snarf", sys->OREAD);
1067 if(fd == nil)
1068 return;
1069 snarfbuf.reset();
1070 snarfbuf.loadx(0, fd);
1071}
1072
1073putsnarf()
1074{
1075 n : int;
1076
1077 # return;
1078 if(snarfbuf.nc == 0)
1079 return;
1080 fd := sys->open("/chan/snarf", sys->OWRITE);
1081 if(fd == nil)
1082 return;
1083 for(i:=0; i<snarfbuf.nc; i+=n){
1084 n = snarfbuf.nc-i;
1085 if(n >= NSnarf)
1086 n = NSnarf;
1087 snarfbuf.read(i, snarfrune, 0, n);
1088 sys->fprint(fd, "%s", snarfrune.s[0:n]);
1089 }
1090}
1091
1092plumbpid : int;
1093
1094plumbproc()
1095{
1096 plumbpid = sys->pctl(0, nil);
1097 for(;;){
1098 msg := Msg.recv();
1099 if(msg == nil){
1100 sys->print("Acme: can't read /chan/plumb.edit: %r\n");
1101 plumbpid = 0;
1102 plumbed = 0;
1103 return;
1104 }
1105 if(msg.kind != "text"){
1106 sys->print("Acme: can't interpret '%s' kind of message\n", msg.kind);
1107 continue;
1108 }
1109# sys->print("msg %s\n", string msg.data);
1110 cplumb <-= msg;
1111 }
1112}
appl/acme/acme.m+32−0
@@ -0,0 +1,32 @@
1Acme : module {
2 PATH : con "/dis/acme.dis";
3
4 RELEASECOPY : con 1;
5
6 M_LBUT : con 1;
7 M_MBUT : con 2;
8 M_RBUT : con 4;
9 M_TBS : con 8;
10 M_PLUMB : con 16;
11 M_QUIT : con 32;
12 M_HELP : con 64;
13 M_RESIZE : con 128;
14 M_DOUBLE : con 256;
15
16 textcols, tagcols : array of ref Draw->Image;
17 but2col, but3col, but2colt, but3colt : ref Draw->Image;
18
19 acmectxt : ref Draw->Context;
20 keyboardpid, mousepid, timerpid, fsyspid : int;
21 fontnames : array of string;
22 wdir : string;
23
24 init : fn(ctxt : ref Draw->Context, argv : list of string);
25 timing : fn(s : string);
26 frgetmouse : fn();
27 get : fn(p, q, r : int, b : string) : ref Dat->Reffont;
28 close : fn(r : ref Dat->Reffont);
29 acmeexit : fn(err : string);
30 getsnarf : fn();
31 putsnarf : fn();
32};
appl/acme/acme/acid/guide+2−0
@@ -0,0 +1,2 @@
1Acid pid
2Acid -l alef -l symsfile pid
appl/acme/acme/acid/mkfile+24−0
@@ -0,0 +1,24 @@
1<../../../../mkconfig
2
3BIN=$ROOT/acme/acid
4
5DIRS=\
6 src\
7
8TARG=\
9 guide\
10 readme\
11
12BINTARG=${TARG:%=$BIN/%}
13
14all:V: $TARG
15
16install:V: $BINTARG
17
18$BIN/guide : guide
19 rm -f $BIN/guide && cp guide $BIN/guide
20
21$BIN/readme : readme
22 rm -f $BIN/readme && cp readme $BIN/readme
23
24<$ROOT/mkfiles/mksubdirs
appl/acme/acme/acid/readme+12−0
@@ -0,0 +1,12 @@
1Capital A Acid is a rudimentary acme interface to the debugger acid.
2It uses a win to provide an interactive window for acid. In that window,
3a couple of extra acme-specific features are enabled:
4
5w(command)
6 runs the command and places its output in a new window.
7 e.g. w(lstk()) places the stack trace in a distinct window.
8
9Also, in any such window, text executed with button 2 is
10presented as input to acid in the main Acid window. Thus, for
11example, one may evaluate variables presented in a stack trace
12by `executing' it with button 2.
appl/acme/acme/acid/src/Acid.b+31−0
@@ -0,0 +1,31 @@
1implement Acid;
2
3include "sys.m";
4include "draw.m";
5include "sh.m";
6
7Acid : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11init(ctxt : ref Draw->Context, argl : list of string)
12{
13 sys := load Sys Sys->PATH;
14 stderr := sys->fildes(2);
15 if (len argl < 2) {
16 sys->fprint(stderr, "usage : Acid pid\n");
17 return;
18 }
19 cmd := "/acme/dis/win";
20 file := cmd + ".dis";
21 c := load Command file;
22 if(c == nil) {
23 sys->fprint(stderr, "%s: %r\n", cmd);
24 return;
25 }
26 argl = "-l" :: argl;
27 argl = "acid" :: argl;
28 argl = "/acme/dis/Acid0" :: argl;
29 argl = cmd :: argl;
30 c->init(ctxt, argl);
31}
appl/acme/acme/acid/src/Acid0.b+86−0
@@ -0,0 +1,86 @@
1implement Acidb;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10FD : import sys;
11Iobuf : import bufio;
12
13Acidb : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17init(nil : ref Draw->Context, nil : list of string)
18{
19 sys = load Sys Sys->PATH;
20 bufio = load Bufio Bufio->PATH;
21 # TBS main(argl);
22}
23
24False : con 0;
25True : con 1;
26
27EVENTSIZE : con 256;
28
29Event : adt {
30 c1, c2, q0, q1, flag, nb, nr : int;
31 b : array of byte;
32 r : array of int;
33 # TBS byte b[EVENTSIZE*UTFmax+1];
34 # TBS Rune r[EVENTSIZE+1];
35};
36
37Win : adt {
38 winid : int;
39 addr : int;
40 body : ref Iobuf;
41 ctl : int;
42 data : int;
43 event : int;
44 buf : array of byte;
45 # TBS byte buf[512];
46 bufp : int;
47 nbuf : int;
48
49 wnew : fn(w : ref Win);
50 wwritebody : fn(w : ref Win, s : array of byte, n : int);
51 wread : fn(w : ref Win, m : int, n : int, s : array of byte);
52 wclean : fn(w : ref Win);
53 wname : fn(w : ref Win, s : array of byte);
54 wdormant : fn(w : ref Win);
55 wevent : fn(w : ref Win, e : ref Event);
56 wtagwrite : fn(w : ref Win, s : array of byte, n : int);
57 wwriteevent : fn(w : ref Win, e : ref Event);
58 wslave : fn(w : ref Win, c : chan of Event);
59 wreplace : fn(w : ref Win, s : array of byte, b : array of byte, n : int);
60 wselect : fn(w : ref Win, s : array of byte);
61 wdel : fn(w : ref Win, n : int) : int;
62 wreadall : fn(w : ref Win) : (int, array of byte);
63
64 ctlwrite : fn(w : ref Win, s : array of byte);
65 getec : fn(w : ref Win) : int;
66 geten : fn(w : ref Win) : int;
67 geter : fn(w : ref Win, s : array of byte, r : array of int) : int;
68 openfile : fn(w : ref Win, b : array of byte) : int;
69 openbody : fn(w : ref Win, n : int);
70};
71
72Awin : adt {
73 w : Win;
74
75 slave : fn(w : ref Awin, s : array of byte, c : chan of int);
76 new : fn(w : ref Awin, s : array of byte);
77 command : fn(w : ref Awin, s : array of byte) : int;
78 send : fn(w : ref Awin, m : int, s : array of byte, n : int);
79};
80
81srvfd : ref FD;
82stdin : ref FD;
83srvenv : array of byte;
84# TBS byte srvenv[64];
85
86srvc : chan of array of byte;
appl/acme/acme/acid/src/mkfile+20−0
@@ -0,0 +1,20 @@
1<../../../../../mkconfig
2
3TARG=\
4 Acid.dis\
5 Acid0.dis\
6# acid.dis\
7# awin.dis\
8# util.dis\
9# win.dis\
10
11MODULES=\
12
13SYSMODULES=\
14 sh.m\
15 sys.m\
16 draw.m\
17
18DISBIN=$ROOT/acme/acid
19
20<$ROOT/mkfiles/mkdis
appl/acme/acme/bin/guide+5−0
@@ -0,0 +1,5 @@
1win
2new command ...
3aspell file
4adiff file1 file2
5adict -d oed
appl/acme/acme/bin/mkfile+24−0
@@ -0,0 +1,24 @@
1<../../../../mkconfig
2
3BIN=$ROOT/acme/bin
4
5DIRS=\
6 src\
7
8TARG=\
9 guide\
10 readme\
11
12BINTARG=${TARG:%=$BIN/%}
13
14all:V: $TARG
15
16install:V: $BINTARG
17
18$BIN/guide : guide
19 rm -f $BIN/guide && cp guide $BIN/guide
20
21$BIN/readme : readme
22 rm -f $BIN/readme && cp readme $BIN/readme
23
24<$ROOT/mkfiles/mksubdirs
appl/acme/acme/bin/readme+25−0
@@ -0,0 +1,25 @@
1This directory and its subdirectory $cputype are always mounted at
2the end of /bin for programs run from acme. They hold a collection
3of small acme-specific applications:
4
5win [command]
6 Create an acme window to serve as a terminal, analogous
7 to xterm. By default, it runs the shell, rc, but it works with
8 any interactive program, e.g. hoc. Within the window,
9 commands executed with button 2 are 'executed' by sending
10 their text to the standard input of the command, appending
11 a newline if necessary.
12new command
13 Run the non-interactive command, placing its standard and
14 diagnostic output in a new window.
15aspell file
16 Run spell on the file, labeling the output with addresses so
17 misspelled words can be found in context using button 3.
18adiff file1 file2
19 Run diff on the files, labeling the output with addresses so
20 changes can be found in context using button 3.
21adict
22 Interactive version of dict(1). Button 3 looks up words and
23 may be applied to any word in any adict window.
24 When a word has multiple definitions, indicate the number
25 (as in acme Mail) to disambiguate.
appl/acme/acme/bin/src/adiff.b+155−0
@@ -0,0 +1,155 @@
1implement Adiff;
2
3include "sys.m";
4include "draw.m";
5include "sh.m";
6include "workdir.m";
7include "bufio.m";
8
9Adiff : module {
10 init : fn(ctxt : ref Draw->Context, argl : list of string);
11};
12
13sys : Sys;
14
15Context : import Draw;
16OREAD, OWRITE, QTDIR, FD, FORKFD, open, read, write, sprint, fprint, stat, fildes, dup, pctl : import sys;
17
18init(ctxt : ref Context, argl : list of string)
19{
20 sys = load Sys Sys->PATH;
21 workdir := load Workdir Workdir->PATH;
22 stderr := fildes(2);
23 if (len argl != 3) {
24 fprint(stderr, "usage: adiff file1 file2\n");
25 return;
26 }
27 ncfd := open("/chan/new/ctl", OREAD);
28 if (ncfd == nil) {
29 fprint(stderr, "cannot open ctl file\n");
30 return;
31 }
32 b := array[128] of byte;
33 n := read(ncfd, b, len b);
34 id := string int string b[0:n];
35 f1 := hd tl argl;
36 f2 := hd tl tl argl;
37 (ok1, d1) := stat(f1);
38 if (ok1 < 0) {
39 fprint(stderr, "cannot stat %s\n", f1);
40 return;
41 }
42 (ok2, d2) := stat(f2);
43 if (ok2 < 0) {
44 fprint(stderr, "cannot stat %s\n", f2);
45 return;
46 }
47 if (d1.qid.qtype & QTDIR)
48 f1 = f1 + "/" + basename(f2);
49 else if (d2.qid.qtype & QTDIR)
50 f2 = f2 + "/" + basename(f1);
51 buf := "/chan/" + id + "/ctl";
52 icfd := open(buf, OWRITE);
53 if (icfd == nil) {
54 fprint(stderr, "cannot open control file\n");
55 return;
56 }
57 buf = "name " + workdir->init() + "/-diff-" + f1 + "\n";
58 b = array of byte buf;
59 write(icfd, b, len b);
60
61 fds := array[2] of ref FD;
62 if (sys->pipe(fds) < 0) {
63 fprint(stderr, "can't pipe\n");
64 return;
65 }
66 buf = "/chan/" + id + "/body";
67 bfd := open(buf, OWRITE);
68 if (bfd == nil) {
69 fprint(stderr, "cannot open body file\n");
70 return;
71 }
72 spawn diff(fds[1], f1, f2, ctxt);
73 fds[1] = nil;
74 awk(fds[0], bfd, f1, f2);
75 b = array of byte "clean\n";
76 write(icfd, b, len b);
77}
78
79strchr(s : string, c : int) : int
80{
81 for (i := 0; i < len s; i++)
82 if (s[i] == c)
83 return i;
84 return -1;
85}
86
87strchrs(s, pat : string) : int
88{
89 for (i := 0; i < len s; i++)
90 if (strchr(pat, s[i]) >= 0)
91 return i;
92 return -1;
93}
94
95awk(ifd, ofd : ref FD, f1, f2 : string)
96{
97 bufio := load Bufio Bufio->PATH;
98 Iobuf : import bufio;
99 b := bufio->fopen(ifd, OREAD);
100 while ((s := b.gets('\n')) != nil) {
101 if (s[0] >= '1' && s[0] <= '9') {
102 if ((n := strchrs(s, "acd")) >= 0)
103 s = f1 + ":" + s[0:n] + " " + s[n:n+1] + " " + f2 + ":" + s[n+1:];
104 }
105 fprint(ofd, "%s", s);
106 }
107}
108
109diff(ofd : ref FD, f1, f2 : string, ctxt : ref Context)
110{
111 args : list of string;
112
113 pctl(FORKFD, nil);
114 fd := open("/dev/null", OREAD);
115 dup(fd.fd, 0);
116 fd = nil;
117 dup(ofd.fd, 1);
118 dup(1, 2);
119 ofd = nil;
120 args = nil;
121 args = f2 :: args;
122 args = f1 :: args;
123 args = "diff" :: args;
124 exec("diff", args, ctxt);
125 exit;
126}
127
128exec(cmd : string, argl : list of string, ctxt : ref Context)
129{
130 file := cmd;
131 if(len file<4 || file[len file-4:]!=".dis")
132 file += ".dis";
133 c := load Command file;
134 if(c == nil) {
135 err := sprint("%r");
136 if(file[0]!='/' && file[0:2]!="./"){
137 c = load Command "/dis/"+file;
138 if(c == nil)
139 err = sprint("%r");
140 }
141 if(c == nil){
142 fprint(fildes(2), "%s: %s\n", cmd, err);
143 return;
144 }
145 }
146 c->init(ctxt, argl);
147}
148
149basename(s : string) : string
150{
151 for (i := len s -1; i >= 0; --i)
152 if (s[i] == '/')
153 return s[i+1:];
154 return s;
155}
appl/acme/acme/bin/src/agrep.b+46−0
@@ -0,0 +1,46 @@
1implement Agrep;
2
3include "sys.m";
4include "draw.m";
5include "sh.m";
6
7Agrep : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11init(ctxt : ref Draw->Context, argl : list of string)
12{
13 sys := load Sys Sys->PATH;
14 stderr := sys->fildes(2);
15 cmd := "grep";
16 file := cmd + ".dis";
17 c := load Command file;
18 if(c == nil) {
19 err := sys->sprint("%r");
20 if(file[0]!='/' && file[0:2]!="./"){
21 c = load Command "/dis/"+file;
22 if(c == nil)
23 err = sys->sprint("%r");
24 }
25 if(c == nil){
26 sys->fprint(stderr, "%s: %s\n", cmd, err);
27 return;
28 }
29 }
30 argl = tl argl;
31 argl = rev(argl);
32 argl = "/dev/null" :: argl;
33 argl = rev(argl);
34 argl = "-n" :: argl;
35 argl = cmd :: argl;
36 c->init(ctxt, argl);
37}
38
39rev(a : list of string) : list of string
40{
41 b : list of string;
42
43 for ( ; a != nil; a = tl a)
44 b = hd a :: b;
45 return b;
46}
appl/acme/acme/bin/src/awd.b+45−0
@@ -0,0 +1,45 @@
1implement Awd;
2
3include "sys.m";
4include "draw.m";
5include "workdir.m";
6
7Awd : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11sys : Sys;
12workdir : Workdir;
13
14FD, OWRITE, open, write : import sys;
15
16init(nil : ref Draw->Context, argl : list of string)
17{
18 n : int;
19 fd : ref FD;
20 buf, dir, str : string;
21 ab : array of byte;
22
23 sys = load Sys Sys->PATH;
24 workdir = load Workdir Workdir->PATH;
25 fd = open("/dev/acme/ctl", OWRITE);
26 if(fd == nil)
27 exit;
28 dir = workdir->init();
29 buf = "name " + dir;
30 n = len buf;
31 if(n>0 && buf[n-1] !='/')
32 buf[n++] = '/';
33 buf[n++] = '-';
34 if(tl argl != nil)
35 str = hd tl argl;
36 else
37 str = "rc";
38 buf += str + "\n";
39 ab = array of byte buf;
40 write(fd, ab, len ab);
41 buf = "dumpdir " + dir + "\n";
42 ab = array of byte buf;
43 write(fd, ab, len ab);
44 exit;
45}
appl/acme/acme/bin/src/cd.b+70−0
@@ -0,0 +1,70 @@
1implement Cd;
2
3include "sys.m";
4include "draw.m";
5include "workdir.m";
6
7Cd : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11sys : Sys;
12workdir : Workdir;
13
14FD, OREAD, OWRITE, open, read, write, chdir, fildes, fprint : import sys;
15
16init(nil : ref Draw->Context, argl : list of string)
17{
18 n : int;
19 fd, stderr : ref FD;
20 buf, dir, str : string;
21 ab : array of byte;
22
23 sys = load Sys Sys->PATH;
24 stderr = fildes(2);
25 argl = tl argl;
26 if (argl == nil)
27 argl = "/usr/" + user() :: nil;
28 if (tl argl != nil) {
29 fprint(stderr, "Usage: cd [directory]\n");
30 exit;
31 }
32 if (chdir(hd argl) < 0) {
33 fprint(stderr, "cd: %s: %r\n", hd argl);
34 exit;
35 }
36
37 workdir = load Workdir Workdir->PATH;
38 fd = open("/dev/acme/ctl", OWRITE);
39 if(fd == nil)
40 exit;
41 dir = workdir->init();
42 buf = "name " + dir;
43 n = len buf;
44 if(n>0 && buf[n-1] !='/')
45 buf[n++] = '/';
46 buf[n++] = '-';
47 if(tl argl != nil)
48 str = hd tl argl;
49 else
50 str = "sh";
51 buf += str + "\n";
52 ab = array of byte buf;
53 write(fd, ab, len ab);
54 buf = "dumpdir " + dir + "\n";
55 ab = array of byte buf;
56 write(fd, ab, len ab);
57 exit;
58}
59
60user(): string
61{
62 fd := open("/dev/user", OREAD);
63 if(fd == nil)
64 return "inferno";
65 buf := array[Sys->NAMEMAX] of byte;
66 n := read(fd, buf, len buf);
67 if(n <= 0)
68 return "inferno";
69 return string buf[0:n];
70}
appl/acme/acme/bin/src/mkfile+22−0
@@ -0,0 +1,22 @@
1<../../../../../mkconfig
2
3TARG=\
4 win.dis\
5 winm.dis\
6 adiff.dis\
7 agrep.dis\
8 new.dis\
9 spout.dis\
10 awd.dis\
11 cd.dis\
12
13MODULES=\
14
15SYSMODULES=\
16 sh.m\
17 sys.m\
18 draw.m\
19
20DISBIN=$ROOT/acme/dis
21
22<$ROOT/mkfiles/mkdis
appl/acme/acme/bin/src/new.b+70−0
@@ -0,0 +1,70 @@
1implement New;
2
3include "sys.m";
4include "draw.m";
5include "sh.m";
6include "workdir.m";
7
8New : module {
9 init : fn(ctxt : ref Draw->Context, argl : list of string);
10};
11
12sys : Sys;
13
14init(ctxt : ref Draw->Context, argl : list of string)
15{
16 sys = load Sys Sys->PATH;
17 workdir := load Workdir Workdir->PATH;
18 if (len argl <= 1)
19 return;
20 ncfd := sys->open("/mnt/acme/new/ctl", Sys->OREAD);
21 if (ncfd == nil)
22 return;
23 b := array[128] of byte;
24 n := sys->read(ncfd, b, len b);
25 id := string int string b[0:n];
26 buf := "/mnt/acme/" + id + "/ctl";
27 icfd := sys->open(buf, Sys->OWRITE);
28 if (icfd == nil)
29 return;
30 base := hd tl argl;
31 for (i := len base - 1; i >= 0; --i)
32 if (base[i] == '/') {
33 base = base[i+1:];
34 break;
35 }
36 buf = "name " + workdir->init() + "/-" + base + "\n";
37 b = array of byte buf;
38 sys->write(icfd, b, len b);
39 buf = "/mnt/acme/" + id + "/body";
40 bfd := sys->open(buf, Sys->OWRITE);
41 if (bfd == nil)
42 return;
43 sys->dup(bfd.fd, 1);
44 sys->dup(1, 2);
45 spawn exec(hd tl argl, tl argl, ctxt);
46 b = array of byte "clean\n";
47 sys->write(icfd, b, len b);
48}
49
50exec(cmd : string, argl : list of string, ctxt : ref Draw->Context)
51{
52 file := cmd;
53 if(len file<4 || file[len file-4:]!=".dis")
54 file += ".dis";
55 c := load Command file;
56 if(c == nil) {
57 err := sys->sprint("%r");
58 if(file[0]!='/' && file[0:2]!="./"){
59 c = load Command "/dis/"+file;
60 if(c == nil)
61 err = sys->sprint("%r");
62 }
63 if(c == nil){
64 sys->fprint(sys->fildes(2), "%s: %s\n", cmd, err);
65 return;
66 }
67 }
68 c->init(ctxt, argl);
69 exit;
70}
appl/acme/acme/bin/src/spout.b+143−0
@@ -0,0 +1,143 @@
1implement Spout;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7Spout : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11sys : Sys;
12bufio : Bufio;
13
14OREAD, OWRITE, ORDWR, FORKNS, FORKFD, NEWPGRP, MREPL, FD, UTFmax, pctl, open, read, write, fprint, sprint, fildes, bind, dup, byte2char, utfbytes : import sys;
15Iobuf : import bufio;
16
17stdin, stdout, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29bout : ref Iobuf;
30
31main(argv : list of string)
32{
33 fd : ref FD;
34
35 bout = bufio->fopen(stdout, OWRITE);
36 if(len argv == 1)
37 spout(stdin, "");
38 else
39 for(argv = tl argv; argv != nil; argv = tl argv){
40 fd = open(hd argv, OREAD);
41 if(fd == nil){
42 fprint(stderr, "spell: can't open %s: %r\n", hd argv);
43 continue;
44 }
45 spout(fd, hd argv);
46 fd = nil;
47 }
48 exit;
49}
50
51alpha(c : int) : int
52{
53 return ('a'<=(c) && (c)<='z') || ('A'<=(c) && (c)<='Z');
54}
55
56b : ref Iobuf;
57
58spout(fd : ref FD, name : string)
59{
60 s, buf : string;
61 t, w : int;
62 inword, wordchar : int;
63 n, wn, c, m : int;
64
65 b = bufio->fopen(fd, OREAD);
66 n = 0;
67 wn = 0;
68 while((s = b.gets('\n')) != nil){
69 if(s[len s-1] != '\n')
70 s[len s] = '\n';
71 if(s[0] == '.') {
72 for(c=0; c<3 && c < len s && s[c]>' '; c++)
73 n++;
74 s = s[c:];
75 }
76 inword = 0;
77 w = 0;
78 t = 0;
79 do{
80 c = s[t];
81 wordchar = 0;
82 if(alpha(c))
83 wordchar = 1;
84 if(inword && !wordchar){
85 if(c=='\'' && alpha(s[t+1])) {
86 n++;
87 t++;
88 continue;
89 }
90 m = t-w;
91 if(m > 1){
92 buf = s[w:w+m];
93 bout.puts(sprint("%s:#%d,#%d:%s\n", name, wn, n, buf));
94 }
95 inword = 0;
96 }else if(!inword && wordchar){
97 wn = n;
98 w = t;
99 inword = 1;
100 }
101 if(c=='\\' && (alpha(s[t+1]) || s[t+1]=='(')){
102 case(s[t+1]){
103 '(' =>
104 m = 4;
105 break;
106 'f' =>
107 if(s[t+2] == '(')
108 m = 5;
109 else
110 m = 3;
111 break;
112 's' =>
113 if(s[t+2] == '+' || s[t+2]=='-'){
114 if(s[t+3] == '(')
115 m = 6;
116 else
117 m = 4;
118 }else{
119 if(s[t+2] == '(')
120 m = 5;
121 else if(s[t+2]=='1' || s[t+2]=='2' || s[t+2]=='3')
122 m = 4;
123 else
124 m = 3;
125 }
126 break;
127 * =>
128 m = 2;
129 }
130 while(m-- > 0){
131 if(s[t] == '\n')
132 break;
133 n++;
134 t++;
135 }
136 continue;
137 }
138 n++;
139 t ++;
140 }while(c != '\n');
141 }
142 bout.flush();
143}
appl/acme/acme/bin/src/win.b+770−0
@@ -0,0 +1,770 @@
1implement Win;
2
3include "sys.m";
4include "draw.m";
5include "workdir.m";
6include "sh.m";
7include "env.m";
8
9sys : Sys;
10workdir : Workdir;
11env: Env;
12
13OREAD, OWRITE, ORDWR, FORKNS, FORKENV, FORKFD, NEWPGRP, MREPL, FD, UTFmax, pctl, open, read, write, fprint, sprint, fildes, bind, dup, byte2char, utfbytes : import sys;
14
15Win : module {
16 init : fn(ctxt : ref Draw->Context, argl : list of string);
17};
18
19Runeself : con 16r80;
20
21PNPROC, PNGROUP : con iota;
22
23stdout, stderr : ref FD;
24
25drawctxt : ref Draw->Context;
26finish : chan of int;
27
28Lock : adt {
29 c : chan of int;
30
31 init : fn() : ref Lock;
32 lock : fn(l : self ref Lock);
33 unlock : fn(l : self ref Lock);
34};
35
36init(ctxt : ref Draw->Context, argl : list of string)
37{
38 sys = load Sys Sys->PATH;
39 workdir = load Workdir Workdir->PATH;
40 env = load Env Env->PATH;
41 drawctxt = ctxt;
42 stdout = fildes(1);
43 stderr = fildes(2);
44 debuginit();
45 finish = chan[1] of int;
46 spawn main(argl);
47 <-finish;
48}
49
50Lock.init() : ref Lock
51{
52 return ref Lock(chan[1] of int);
53}
54
55Lock.lock(l : self ref Lock)
56{
57 l.c <-= 1;
58}
59
60Lock.unlock(l : self ref Lock)
61{
62 <-l.c;
63}
64
65dlock : ref Lock;
66debfd : ref Sys->FD;
67
68debuginit()
69{
70 # debfd = sys->create("./debugwin", Sys->OWRITE, 8r600);
71 # dlock = Lock.init();
72}
73
74debugpr(nil : string)
75{
76 # fprint(debfd, "%s", s);
77}
78
79debug(nil : string)
80{
81 # dlock.lock();
82 # fprint(debfd, "%s", s);
83 # dlock.unlock();
84}
85
86exec(cmd : string, argl : list of string)
87{
88 file := cmd;
89 if(len file<4 || file[len file-4:]!=".dis")
90 file += ".dis";
91
92 c := load Command file;
93 if(c == nil) {
94 err := sprint("%r");
95 if(file[0]!='/' && file[0:2]!="./"){
96 c = load Command "/dis/"+file;
97 if(c == nil)
98 err = sprint("%r");
99 }
100 if(c == nil){
101 fprint(stderr, "%s: %s\n", cmd, err);
102 return;
103 }
104 }
105 c->init(drawctxt, argl);
106}
107
108postnote(t : int, pid : int, note : string) : int
109{
110 # fd := open("/prog/" + string pid + "/ctl", OWRITE);
111 fd := open("#p/" + string pid + "/ctl", OWRITE);
112 if (fd == nil)
113 return -1;
114 if (t == PNGROUP)
115 note += "grp";
116 fprint(fd, "%s", note);
117
118 fd = nil;
119 return 0;
120}
121
122sysname(): string
123{
124 fd := sys->open("#c/sysname", sys->OREAD);
125 if(fd == nil)
126 return nil;
127 buf := array[128] of byte;
128 n := sys->read(fd, buf, len buf);
129 if(n < 0)
130 return nil;
131 return string buf[0:n];
132}
133
134EVENTSIZE : con 256;
135
136Event : adt {
137 c1 : int;
138 c2 : int;
139 q0 : int;
140 q1 : int;
141 flag : int;
142 nb : int;
143 nr : int;
144 b : array of byte;
145 r : array of int;
146};
147
148blank : ref Event;
149
150pid : int;
151# pgrpfd : ref FD;
152parentpid : int;
153
154typing : array of byte;
155ntypeb : int;
156ntyper : int;
157ntypebreak : int;
158
159Q : adt {
160 l : ref Lock;
161 p : int;
162 k : int;
163};
164
165q : Q;
166
167newevent(n : int) : ref Event
168{
169 e := ref Event;
170 e.b = array[n*UTFmax+1] of byte;
171 e.r = array[n+1] of int;
172 return e;
173}
174
175main(argv : list of string)
176{
177 program : list of string;
178 fd, ctlfd, eventfd, addrfd, datafd : ref FD;
179 id : int;
180 c : chan of int;
181 name : string;
182
183 sys->pctl(Sys->NEWPGRP, nil);
184 q.l = Lock.init();
185 blank = newevent(2);
186 blank.c1 = 'M';
187 blank.c2 = 'X';
188 blank.q0 = blank.q1 = blank.flag = 0;
189 blank.nb = blank.nr = 1;
190 blank.b[0] = byte ' ';
191 blank.b[1] = byte 0;
192 blank.r[0] = ' ';
193 blank.r[1] = 0;
194 pctl(FORKNS|NEWPGRP, nil);
195 parentpid = pctl(0, nil);
196 program = nil;
197 if(tl argv != nil)
198 program = tl argv;
199 name = nil;
200 if(program == nil){
201 # program = "-i" :: program;
202 program = "sh" :: program;
203 name = sysname();
204 }
205 if(name == nil){
206 prog := hd program;
207 for (n := len prog - 1; n >= 0; n--)
208 if (prog[n] == '/')
209 break;
210 if(n >= 0)
211 name = prog[n+1:];
212 else
213 name = prog;
214 argl := tl argv;
215 if (argl != nil) {
216 for(argl = tl argl; argl != nil && len(name)+1+len(hd argl)<16; argl = tl argl)
217 name += "_" + hd argl;
218 }
219 }
220 if(bind("#|", "/dev/acme", MREPL) < 0)
221 error("pipe");
222 ctlfd = open("/chan/new/ctl", ORDWR);
223 buf := array[12] of byte;
224 if(ctlfd==nil || read(ctlfd, buf, 12)!=12)
225 error("ctl");
226 id = int string buf;
227 buf = nil;
228 env->setenv("acmewin", string id);
229 b := sprint("/chan/%d/tag", id);
230 fd = open(b, OWRITE);
231 write(fd, array of byte " Send Delete", 12);
232 fd = nil;
233 b = sprint("/chan/%d/event", id);
234 eventfd = open(b, ORDWR);
235 b = sprint("/chan/%d/addr", id);
236 addrfd = open(b, ORDWR);
237 b = sprint("/chan/%d/data", id);
238 datafd = open(b, ORDWR); # OCEXEC
239 if(eventfd==nil || addrfd==nil || datafd==nil)
240 error("data files");
241 c = chan of int;
242 spawn run(program, id, c);
243 pid = <-c;
244 # b = sprint("/prog/%d/notepg", pid);
245 # pgrpfd = open(b, OWRITE); # OCEXEC
246 # if(pgrpfd == nil)
247 # fprint(stdout, "warning: win can't open notepg: %r\n");
248 c <-= 1;
249 fd = open("/dev/acme/data", ORDWR);
250 if(fd == nil)
251 error("/dev/acme/data");
252 wd := workdir->init();
253 # b = sprint("name %s/-%s\n0\n", wd, name);
254 b = sprint("name %s/-%s\n", wd, name);
255 ab := array of byte b;
256 write(ctlfd, ab, len ab);
257 b = sprint("dumpdir %s/\n", wd);
258 ab = array of byte b;
259 write(ctlfd, ab, len ab);
260 b = sprint("dump %s\n", onestring(argv));
261 ab = array of byte b;
262 write(ctlfd, ab, len ab);
263 ab = nil;
264 spawn stdinx(fd, ctlfd, eventfd, addrfd, datafd);
265 stdoutx(fd, addrfd, datafd);
266}
267
268run(argv : list of string, id : int, c : chan of int)
269{
270 fd0, fd1 : ref FD;
271
272 pctl(FORKENV|FORKFD|NEWPGRP, nil); # had RFMEM
273 c <-= pctl(0, nil);
274 <-c;
275 pctl(FORKNS, nil);
276 if(bind("/dev/acme/data1", "/dev/cons", MREPL) < 0){
277 fprint(stderr, "can't bind /dev/cons: %r\n");
278 exit;
279 }
280 fd0 = open("/dev/cons", OREAD);
281 fd1 = open("/dev/cons", OWRITE);
282 if(fd0==nil || fd1==nil){
283 fprint(stderr, "can't open /dev/cons: %r\n");
284 exit;
285 }
286 dup(fd0.fd, 0);
287 dup(fd1.fd, 1);
288 dup(fd1.fd, 2);
289 fd0 = fd1 = nil;
290 b := sprint("/chan/%d", id);
291 if(bind(b, "/dev/acme", MREPL) < 0)
292 error("bind /dev/acme");
293 if(bind(sprint("/chan/%d/consctl", id), "/dev/consctl", MREPL) < 0)
294 error("bind /dev/consctl");
295 exec(hd argv, argv);
296 exit;
297}
298
299killing : int = 0;
300
301error(s : string)
302{
303 if(s != nil)
304 fprint(stderr, "win: %s: %r\n", s);
305 if (killing)
306 return;
307 killing = 1;
308 s = "kill";
309 if(pid)
310 postnote(PNGROUP, pid, s);
311 # write(pgrpfd, array of byte "hangup", 6);
312 postnote(PNGROUP, parentpid, s);
313 finish <-= 1;
314 exit;
315}
316
317buff := array[8192] of byte;
318bufp : int;
319nbuf : int;
320
321onestring(argv : list of string) : string
322{
323 s : string;
324
325 if(argv == nil)
326 return "";
327 for( ; argv != nil; argv = tl argv){
328 s += hd argv;
329 if (tl argv != nil)
330 s += " ";
331 }
332 return s;
333}
334
335getec(efd : ref FD) : int
336{
337 if(nbuf == 0){
338 nbuf = read(efd, buff, len buff);
339 if(nbuf <= 0)
340 error(nil);
341 bufp = 0;
342 }
343 --nbuf;
344 return int buff[bufp++];
345}
346
347geten(efd : ref FD) : int
348{
349 n, c : int;
350
351 n = 0;
352 while('0'<=(c=getec(efd)) && c<='9')
353 n = n*10+(c-'0');
354 if(c != ' ')
355 error("event number syntax");
356 return n;
357}
358
359geter(efd : ref FD, buf : array of byte) : (int, int)
360{
361 r, m, n, ok : int;
362
363 r = getec(efd);
364 buf[0] = byte r;
365 n = 1;
366 if(r < Runeself)
367 return (r, n);
368 for (;;) {
369 (r, m, ok) = byte2char(buf[0:n], 0);
370 if (m > 0)
371 return (r, n);
372 buf[n++] = byte getec(efd);
373 }
374 return (0, 0);
375}
376
377gete(efd : ref FD, e : ref Event)
378{
379 i, nb : int;
380
381 e.c1 = getec(efd);
382 e.c2 = getec(efd);
383 e.q0 = geten(efd);
384 e.q1 = geten(efd);
385 e.flag = geten(efd);
386 e.nr = geten(efd);
387 if(e.nr > EVENTSIZE)
388 error("event string too long");
389 e.nb = 0;
390 for(i=0; i<e.nr; i++){
391 (e.r[i], nb) = geter(efd, e.b[e.nb:]);
392 e.nb += nb;
393 }
394 e.r[e.nr] = 0;
395 e.b[e.nb] = byte 0;
396 if(getec(efd) != '\n')
397 error("event syntax 2");
398}
399
400nrunes(s : array of byte, nb : int) : int
401{
402 i, n, r, b, ok : int;
403
404 n = 0;
405 for(i=0; i<nb; n++) {
406 (r, b, ok) = byte2char(s, i);
407 if (b == 0)
408 error("not full string in nrunes()");
409 i += b;
410 }
411 return n;
412}
413
414stdinx(fd0 : ref FD, cfd : ref FD, efd : ref FD, afd : ref FD, dfd : ref FD)
415{
416 e, e2, e3, e4 : ref Event;
417
418 e = newevent(EVENTSIZE);
419 e2 = newevent(EVENTSIZE);
420 e3 = newevent(EVENTSIZE);
421 e4 = newevent(EVENTSIZE);
422 for(;;){
423 gete(efd, e);
424 q.l.lock();
425 case(e.c1){
426 'E' => # write to body; can't affect us
427 break;
428 'F' => # generated by our actions; ignore
429 break;
430 'K' or 'M' =>
431 case(e.c2){
432 'R' =>
433 addtype(' ', ntyper, e.b, e.nb, e.nr);
434 sendtype(fd0, 1);
435 break;
436 'I' =>
437 if(e.q0 < q.p)
438 q.p += e.q1-e.q0;
439 else if(e.q0 <= q.p+ntyper)
440 typex(e, fd0, afd, dfd);
441 break;
442 'D' =>
443 q.p -= delete(e);
444 break;
445 'x' or 'X' =>
446 if(e.flag & 2)
447 gete(efd, e2);
448 if(e.flag & 8){
449 gete(efd, e3);
450 gete(efd, e4);
451 }
452 if(e.flag&1 || (e.c2=='x' && e.nr==0 && e2.nr==0)){
453 # send it straight back
454 fprint(efd, "%c%c%d %d\n", e.c1, e.c2, e.q0, e.q1);
455 break;
456 }
457 if(e.q0==e.q1 && (e.flag&2)){
458 e2.flag = e.flag;
459 *e = *e2;
460 }
461 if(e.flag & 8){
462 if(e.q1 != e.q0){
463 send(e, fd0, cfd, afd, dfd, 0);
464 send(blank, fd0, cfd, afd, dfd, 0);
465 }
466 send(e3, fd0, cfd, afd, dfd, 1);
467 }else if(e.q1 != e.q0)
468 send(e, fd0, cfd, afd, dfd, 1);
469 break;
470 'l' or 'L' =>
471 # just send it back
472 if(e.flag & 2)
473 gete(efd, e2);
474 fprint(efd, "%c%c%d %d\n", e.c1, e.c2, e.q0, e.q1);
475 break;
476 'd' or 'i' =>
477 break;
478 * =>
479 fprint(stdout, "unknown message %c%c\n", e.c1, e.c2);
480 break;
481 }
482 * =>
483 fprint(stdout, "unknown message %c%c\n", e.c1, e.c2);
484 break;
485 }
486 q.l.unlock();
487 }
488}
489
490stdoutx(fd1 : ref FD, afd : ref FD, dfd : ref FD)
491{
492 n, m, w, npart : int;
493 s, t : int;
494 buf, hold, x : array of byte;
495 r, ok : int;
496
497 buf = array[8192+UTFmax+1] of byte;
498 hold = array[UTFmax] of byte;
499 npart = 0;
500 for(;;){
501 n = read(fd1, buf[npart:], 8192);
502 if(n < 0)
503 error(nil);
504 if(n == 0)
505 continue;
506
507 # squash NULs
508 for (s = 0; s < n; s++)
509 if (buf[npart+s] == byte 0)
510 break;
511 if(s < n){
512 for(t=s; s<n; s++)
513 if(buf[npart+t] == buf[npart+s]) # assign =
514 t++;
515 n = t;
516 }
517
518 n += npart;
519
520 # hold on to final partial rune
521 npart = 0;
522 while(n>0 && (int buf[n-1]&16rC0)){
523 --n;
524 npart++;
525 if((int buf[n]&16rC0)!=16r80){
526 if(utfbytes(buf[n:], npart) > 0){
527 (r, w, ok) = byte2char(buf, n);
528 n += w;
529 npart -= w;
530 }
531 break;
532 }
533 }
534 if(n > 0){
535 hold[0:] = buf[n:n+npart];
536 buf[n] = byte 0;
537 q.l.lock();
538 str := sprint("#%d", q.p);
539 x = array of byte str;
540 m = len x;
541 if(write(afd, x, m) != m)
542 error("stdout writing address");
543 x = nil;
544 if(write(dfd, buf, n) != n)
545 error("stdout writing body");
546 q.p += nrunes(buf, n);
547 q.l.unlock();
548 buf[0:] = hold[0:npart];
549 }
550 }
551}
552
553delete(e : ref Event) : int
554{
555 q0, q1 : int;
556 deltap : int;
557
558 q0 = e.q0;
559 q1 = e.q1;
560 if(q1 <= q.p)
561 return e.q1-e.q0;
562 if(q0 >= q.p+ntyper)
563 return 0;
564 deltap = 0;
565 if(q0 < q.p){
566 deltap = q.p-q0;
567 q0 = 0;
568 }else
569 q0 -= q.p;
570 if(q1 > q.p+ntyper)
571 q1 = ntyper;
572 else
573 q1 -= q.p;
574 deltype(q0, q1);
575 return deltap;
576}
577
578addtype(c : int, p0 : int, b : array of byte, nb : int, nr : int)
579{
580 i, w : int;
581 r, ok : int;
582 p : int;
583 b0 : int;
584
585 for(i=0; i<nb; i+=w){
586 (r, w, ok) = byte2char(b, i);
587 if(r==16r7F && c=='K'){
588 if (pid)
589 postnote(PNGROUP, pid, "kill");
590 # write(pgrpfd, array of byte "interrupt", 9);
591 # toss all typing
592 q.p += ntyper+nr;
593 ntypebreak = 0;
594 ntypeb = 0;
595 ntyper = 0;
596 # buglet: more than one delete ignored
597 return;
598 }
599 if(r=='\n' || r==16r04)
600 ntypebreak++;
601 }
602 ot := typing;
603 typing = array[ntypeb+nb] of byte;
604 if(typing == nil)
605 error("realloc");
606 if (ot != nil)
607 typing[0:] = ot[0:ntypeb];
608 ot = nil;
609 if(p0 == ntyper)
610 typing[ntypeb:] = b[0:nb];
611 else{
612 b0 = 0;
613 for(p=0; p<p0 && b0<ntypeb; p++){
614 (r, w, ok) = byte2char(typing[b0:], i);
615 b0 += w;
616 }
617 if(p != p0)
618 error("typing: findrune");
619 typing[b0+nb:] = typing[b0:ntypeb];
620 typing[b0:] = b[0:nb];
621 }
622 ntypeb += nb;
623 ntyper += nr;
624}
625
626sendtype(fd0 : ref FD, raw : int)
627{
628 while(ntypebreak){
629 brkc := 0;
630 i := 0;
631 while(i<ntypeb){
632 if(typing[i]==byte '\n' || typing[i]==byte 16r04){
633 n := i + (typing[i] == byte '\n');
634 i++;
635 if(write(fd0, typing, n) != n)
636 error("sending to program");
637 nr := nrunes(typing, i);
638 if (!raw)
639 q.p += nr;
640 ntyper -= nr;
641 ntypeb -= i;
642 typing[0:] = typing[i:i+ntypeb];
643 i = 0;
644 ntypebreak--;
645 brkc = 1;
646 }else
647 i++;
648 }
649 if (!brkc) {
650 fprint(stdout, "no breakchar\n");
651 ntypebreak = 0;
652 }
653 }
654}
655
656deltype(p0 : int, p1 : int)
657{
658 w : int;
659 p, b0, b1 : int;
660 r, ok : int;
661
662 # advance to p0
663 b0 = 0;
664 for(p=0; p<p0 && b0<ntypeb; p++){
665 (r, w, ok) = byte2char(typing, b0);
666 b0 += w;
667 }
668 if(p != p0)
669 error("deltype 1");
670 # advance to p1
671 b1 = b0;
672 for(; p<p1 && b1<ntypeb; p++){
673 (r, w, ok) = byte2char(typing, b1);
674 b1 += w;
675 if(r=='\n' || r==16r04)
676 ntypebreak--;
677 }
678 if(p != p1)
679 error("deltype 2");
680 typing[b0:] = typing[b1:ntypeb];
681 ntypeb -= b1-b0;
682 ntyper -= p1-p0;
683}
684
685typex(e : ref Event, fd0 : ref FD, afd : ref FD, dfd : ref FD)
686{
687 m, n, nr : int;
688 buf : array of byte;
689
690 if(e.nr > 0)
691 addtype(e.c1, e.q0-q.p, e.b, e.nb, e.nr);
692 else{
693 buf = array[128] of byte;
694 m = e.q0;
695 while(m < e.q1){
696 str := sprint("#%d", m);
697 b := array of byte str;
698 n = len b;
699 write(afd, b, n);
700 b = nil;
701 n = read(dfd, buf, len buf);
702 nr = nrunes(buf, n);
703 while(m+nr > e.q1){
704 do; while(n>0 && (int buf[--n]&16rC0)==16r80);
705 --nr;
706 }
707 if(n == 0)
708 break;
709 addtype(e.c1, m-q.p, buf, n, nr);
710 m += nr;
711 }
712 }
713 buf = nil;
714 sendtype(fd0, 0);
715}
716
717send(e : ref Event, fd0 : ref FD, cfd : ref FD, afd : ref FD, dfd : ref FD, donl : int)
718{
719 l, m, n, nr, lastc, end : int;
720 abuf, buf : array of byte;
721
722 buf = array[128] of byte;
723 end = q.p+ntyper;
724 str := sprint("#%d", end);
725 abuf = array of byte str;
726 l = len abuf;
727 write(afd, abuf, l);
728 abuf = nil;
729 if(e.nr > 0){
730 write(dfd, e.b, e.nb);
731 addtype(e.c1, ntyper, e.b, e.nb, e.nr);
732 lastc = e.r[e.nr-1];
733 }else{
734 m = e.q0;
735 lastc = 0;
736 while(m < e.q1){
737 str = sprint("#%d", m);
738 abuf = array of byte str;
739 n = len abuf;
740 write(afd, abuf, n);
741 abuf = nil;
742 n = read(dfd, buf, len buf);
743 nr = nrunes(buf, n);
744 while(m+nr > e.q1){
745 do; while(n>0 && (int buf[--n]&16rC0)==16r80);
746 --nr;
747 }
748 if(n == 0)
749 break;
750 str = sprint("#%d", end);
751 abuf = array of byte str;
752 l = len abuf;
753 write(afd, abuf, l);
754 abuf = nil;
755 write(dfd, buf, n);
756 addtype(e.c1, ntyper, buf, n, nr);
757 lastc = int buf[n-1];
758 m += nr;
759 end += nr;
760 }
761 }
762 if(donl && lastc!='\n'){
763 write(dfd, array of byte "\n", 1);
764 addtype(e.c1, ntyper, array of byte "\n", 1, 1);
765 }
766 write(cfd, array of byte "dot=addr", 8);
767 sendtype(fd0, 0);
768 buf = nil;
769}
770
appl/acme/acme/bin/src/winm.b+791−0
@@ -0,0 +1,791 @@
1implement Win;
2
3include "sys.m";
4include "draw.m";
5include "workdir.m";
6include "sh.m";
7
8sys : Sys;
9workdir : Workdir;
10
11OREAD, OWRITE, ORDWR, FORKNS, FORKENV, FORKFD, NEWPGRP, MREPL, FD, UTFmax, pctl, open, read, write, fprint, sprint, fildes, bind, dup, byte2char, utfbytes : import sys;
12
13Win : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17Runeself : con 16r80;
18
19PNPROC, PNGROUP : con iota;
20
21stdout, stderr : ref FD;
22
23drawctxt : ref Draw->Context;
24
25Lock : adt {
26 cnt : int;
27 chann : chan of int;
28
29 init : fn() : ref Lock;
30 lock : fn(l : self ref Lock);
31 unlock : fn(l : self ref Lock);
32};
33
34lc, uc : chan of ref Lock;
35lockpid : int;
36
37init(ctxt : ref Draw->Context, argl : list of string)
38{
39 sys = load Sys Sys->PATH;
40 workdir = load Workdir Workdir->PATH;
41 drawctxt = ctxt;
42 stdout = fildes(1);
43 stderr = fildes(2);
44 lc = chan of ref Lock;
45 uc = chan of ref Lock;
46 spawn lockmgr();
47 debuginit();
48 main(argl);
49}
50
51lockmgr()
52{
53 l : ref Lock;
54
55 lockpid = pctl(0, nil);
56 for (;;) {
57 alt {
58 l = <- lc =>
59 if (l.cnt++ == 0)
60 l.chann <-= 1;
61 l = <- uc =>
62 if (--l.cnt > 0)
63 l.chann <-= 1;
64 }
65 }
66}
67
68Lock.init() : ref Lock
69{
70 return ref Lock(0, chan of int);
71}
72
73Lock.lock(l : self ref Lock)
74{
75 lc <-= l;
76 <- l.chann;
77}
78
79Lock.unlock(l : self ref Lock)
80{
81 uc <-= l;
82}
83
84dlock : ref Lock;
85debfd : ref Sys->FD;
86
87debuginit()
88{
89 # debfd = sys->create("./debugwin", Sys->OWRITE, 8r600);
90 # dlock = Lock.init();
91}
92
93debugpr(nil : string)
94{
95 # fprint(debfd, "%s", s);
96}
97
98debug(nil : string)
99{
100 # dlock.lock();
101 # fprint(debfd, "%s", s);
102 # dlock.unlock();
103}
104
105exec(cmd : string, argl : list of string)
106{
107 file := cmd;
108 if(len file<4 || file[len file-4:]!=".dis")
109 file += ".dis";
110
111 c := load Command file;
112 if(c == nil) {
113 err := sprint("%r");
114 if(file[0]!='/' && file[0:2]!="./"){
115 c = load Command "/dis/"+file;
116 if(c == nil)
117 err = sprint("%r");
118 }
119 if(c == nil){
120 fprint(stderr, "%s: %s\n", cmd, err);
121 return;
122 }
123 }
124 c->init(drawctxt, argl);
125}
126
127postnote(t : int, pid : int, note : string) : int
128{
129 # fd := open("/prog/" + string pid + "/ctl", OWRITE);
130 fd := open("#p/" + string pid + "/ctl", OWRITE);
131 if (fd == nil)
132 return -1;
133 if (t == PNGROUP)
134 note += "grp";
135 fprint(fd, "%s", note);
136
137 fd = nil;
138 return 0;
139}
140
141sysname(): string
142{
143 fd := sys->open("#c/sysname", sys->OREAD);
144 if(fd == nil)
145 return nil;
146 buf := array[128] of byte;
147 n := sys->read(fd, buf, len buf);
148 if(n < 0)
149 return nil;
150 return string buf[0:n];
151}
152
153EVENTSIZE : con 256;
154
155Event : adt {
156 c1 : int;
157 c2 : int;
158 q0 : int;
159 q1 : int;
160 flag : int;
161 nb : int;
162 nr : int;
163 b : array of byte;
164 r : array of int;
165};
166
167blank : ref Event;
168
169pid : int;
170# pgrpfd : ref FD;
171parentpid : int;
172
173typing : array of byte;
174ntypeb : int;
175ntyper : int;
176ntypebreak : int;
177
178Q : adt {
179 l : ref Lock;
180 p : int;
181 k : int;
182};
183
184q : Q;
185
186newevent(n : int) : ref Event
187{
188 e := ref Event;
189 e.b = array[n*UTFmax+1] of byte;
190 e.r = array[n+1] of int;
191 return e;
192}
193
194main(argv : list of string)
195{
196 spawn main1(argv);
197 exit;
198}
199
200main1(argv : list of string)
201{
202 program : list of string;
203 fd, ctlfd, eventfd, addrfd, datafd : ref FD;
204 id : int;
205 c : chan of int;
206 name : string;
207
208 q.l = Lock.init();
209 blank = newevent(2);
210 blank.c1 = 'M';
211 blank.c2 = 'X';
212 blank.q0 = blank.q1 = blank.flag = 0;
213 blank.nb = blank.nr = 1;
214 blank.b[0] = byte ' ';
215 blank.b[1] = byte 0;
216 blank.r[0] = ' ';
217 blank.r[1] = 0;
218 pctl(FORKNS|NEWPGRP, nil);
219 parentpid = pctl(0, nil);
220 program = nil;
221 if(tl argv != nil)
222 program = tl argv;
223 name = nil;
224 if(program == nil){
225 # program = "-i" :: program;
226 program = "sh" :: program;
227 name = sysname();
228 }
229 if(name == nil){
230 prog := hd program;
231 for (n := len prog - 1; n >= 0; n--)
232 if (prog[n] == '/')
233 break;
234 if(n >= 0)
235 name = prog[n+1:];
236 else
237 name = prog;
238 argl := tl argv;
239 if (argl != nil) {
240 for(argl = tl argl; argl != nil && len(name)+1+len(hd argl)<16; argl = tl argl)
241 name += "_" + hd argl;
242 }
243 }
244 if(bind("#|", "/dev/acme", MREPL) < 0)
245 error("pipe");
246 ctlfd = open("/chan/new/ctl", ORDWR);
247 buf := array[12] of byte;
248 if(ctlfd==nil || read(ctlfd, buf, 12)!=12)
249 error("ctl");
250 id = int string buf;
251 buf = nil;
252 b := sprint("/chan/%d/tag", id);
253 fd = open(b, OWRITE);
254 write(fd, array of byte " Send Delete", 12);
255 fd = nil;
256 b = sprint("/chan/%d/event", id);
257 eventfd = open(b, ORDWR);
258 b = sprint("/chan/%d/addr", id);
259 addrfd = open(b, ORDWR);
260 b = sprint("/chan/%d/data", id);
261 datafd = open(b, ORDWR); # OCEXEC
262 if(eventfd==nil || addrfd==nil || datafd==nil)
263 error("data files");
264 c = chan of int;
265 spawn run(program, id, c);
266 pid = <-c;
267 # b = sprint("/prog/%d/notepg", pid);
268 # pgrpfd = open(b, OWRITE); # OCEXEC
269 # if(pgrpfd == nil)
270 # fprint(stdout, "warning: win can't open notepg: %r\n");
271 c <-= 1;
272 fd = open("/dev/acme/data", ORDWR);
273 if(fd == nil)
274 error("/dev/acme/data");
275 wd := workdir->init();
276 # b = sprint("name %s/-%s\n0\n", wd, name);
277 b = sprint("name %s/-%s\n", wd, name);
278 ab := array of byte b;
279 write(ctlfd, ab, len ab);
280 b = sprint("dumpdir %s/\n", wd);
281 ab = array of byte b;
282 write(ctlfd, ab, len ab);
283 b = sprint("dump %s\n", onestring(argv));
284 ab = array of byte b;
285 write(ctlfd, ab, len ab);
286 ab = nil;
287 spawn stdinx(fd, ctlfd, eventfd, addrfd, datafd);
288 stdoutx(fd, addrfd, datafd);
289}
290
291run(argv : list of string, id : int, c : chan of int)
292{
293 fd0, fd1 : ref FD;
294
295 pctl(FORKENV|FORKFD|NEWPGRP, nil); # had RFMEM
296 c <-= pctl(0, nil);
297 <-c;
298 pctl(FORKNS, nil);
299 if(bind("/dev/acme/data1", "/dev/cons", MREPL) < 0){
300 fprint(stderr, "can't bind /dev/cons: %r\n");
301 exit;
302 }
303 fd0 = open("/dev/cons", OREAD);
304 fd1 = open("/dev/cons", OWRITE);
305 if(fd0==nil || fd1==nil){
306 fprint(stderr, "can't open /dev/cons: %r\n");
307 exit;
308 }
309 dup(fd0.fd, 0);
310 dup(fd1.fd, 1);
311 dup(fd1.fd, 2);
312 fd0 = fd1 = nil;
313 b := sprint("/chan/%d", id);
314 if(bind(b, "/dev/acme", MREPL) < 0)
315 error("bind /dev/acme");
316 if(bind(sprint("/chan/%d/consctl", id), "/dev/consctl", MREPL) < 0)
317 error("bind /dev/consctl");
318 exec(hd argv, argv);
319 exit;
320}
321
322killing : int = 0;
323
324error(s : string)
325{
326 if(s != nil)
327 fprint(stderr, "win: %s: %r\n", s);
328 if (killing)
329 return;
330 killing = 1;
331 s = "kill";
332 if(pid)
333 postnote(PNGROUP, pid, s);
334 # write(pgrpfd, array of byte "hangup", 6);
335 postnote(PNPROC, lockpid, s);
336 postnote(PNGROUP, parentpid, s);
337 exit;
338}
339
340buff := array[8192] of byte;
341bufp : int;
342nbuf : int;
343
344onestring(argv : list of string) : string
345{
346 s : string;
347
348 if(argv == nil)
349 return "";
350 for( ; argv != nil; argv = tl argv){
351 s += hd argv;
352 if (tl argv != nil)
353 s += " ";
354 }
355 return s;
356}
357
358getec(efd : ref FD) : int
359{
360 if(nbuf == 0){
361 nbuf = read(efd, buff, len buff);
362 if(nbuf <= 0)
363 error(nil);
364 bufp = 0;
365 }
366 --nbuf;
367 return int buff[bufp++];
368}
369
370geten(efd : ref FD) : int
371{
372 n, c : int;
373
374 n = 0;
375 while('0'<=(c=getec(efd)) && c<='9')
376 n = n*10+(c-'0');
377 if(c != ' ')
378 error("event number syntax");
379 return n;
380}
381
382geter(efd : ref FD, buf : array of byte) : (int, int)
383{
384 r, m, n, ok : int;
385
386 r = getec(efd);
387 buf[0] = byte r;
388 n = 1;
389 if(r < Runeself)
390 return (r, n);
391 for (;;) {
392 (r, m, ok) = byte2char(buf[0:n], 0);
393 if (m > 0)
394 return (r, n);
395 buf[n++] = byte getec(efd);
396 }
397 return (0, 0);
398}
399
400gete(efd : ref FD, e : ref Event)
401{
402 i, nb : int;
403
404 e.c1 = getec(efd);
405 e.c2 = getec(efd);
406 e.q0 = geten(efd);
407 e.q1 = geten(efd);
408 e.flag = geten(efd);
409 e.nr = geten(efd);
410 if(e.nr > EVENTSIZE)
411 error("event string too long");
412 e.nb = 0;
413 for(i=0; i<e.nr; i++){
414 (e.r[i], nb) = geter(efd, e.b[e.nb:]);
415 e.nb += nb;
416 }
417 e.r[e.nr] = 0;
418 e.b[e.nb] = byte 0;
419 if(getec(efd) != '\n')
420 error("event syntax 2");
421}
422
423nrunes(s : array of byte, nb : int) : int
424{
425 i, n, r, b, ok : int;
426
427 n = 0;
428 for(i=0; i<nb; n++) {
429 (r, b, ok) = byte2char(s, i);
430 if (b == 0)
431 error("not full string in nrunes()");
432 i += b;
433 }
434 return n;
435}
436
437stdinx(fd0 : ref FD, cfd : ref FD, efd : ref FD, afd : ref FD, dfd : ref FD)
438{
439 e, e2, e3, e4 : ref Event;
440
441 e = newevent(EVENTSIZE);
442 e2 = newevent(EVENTSIZE);
443 e3 = newevent(EVENTSIZE);
444 e4 = newevent(EVENTSIZE);
445 for(;;){
446 gete(efd, e);
447 q.l.lock();
448 case(e.c1){
449 'E' => # write to body; can't affect us
450 break;
451 'F' => # generated by our actions; ignore
452 break;
453 'K' or 'M' =>
454 case(e.c2){
455 'R' =>
456 addtype(' ', ntyper, e.b, e.nb, e.nr);
457 sendtype(fd0, 1);
458 break;
459 'I' =>
460 if(e.q0 < q.p)
461 q.p += e.q1-e.q0;
462 else if(e.q0 <= q.p+ntyper)
463 typex(e, fd0, afd, dfd);
464 break;
465 'D' =>
466 q.p -= delete(e);
467 break;
468 'x' or 'X' =>
469 if(e.flag & 2)
470 gete(efd, e2);
471 if(e.flag & 8){
472 gete(efd, e3);
473 gete(efd, e4);
474 }
475 if(e.flag&1 || (e.c2=='x' && e.nr==0 && e2.nr==0)){
476 # send it straight back
477 fprint(efd, "%c%c%d %d\n", e.c1, e.c2, e.q0, e.q1);
478 break;
479 }
480 if(e.q0==e.q1 && (e.flag&2)){
481 e2.flag = e.flag;
482 *e = *e2;
483 }
484 if(e.flag & 8){
485 if(e.q1 != e.q0){
486 send(e, fd0, cfd, afd, dfd, 0);
487 send(blank, fd0, cfd, afd, dfd, 0);
488 }
489 send(e3, fd0, cfd, afd, dfd, 1);
490 }else if(e.q1 != e.q0)
491 send(e, fd0, cfd, afd, dfd, 1);
492 break;
493 'l' or 'L' =>
494 # just send it back
495 if(e.flag & 2)
496 gete(efd, e2);
497 fprint(efd, "%c%c%d %d\n", e.c1, e.c2, e.q0, e.q1);
498 break;
499 'd' or 'i' =>
500 break;
501 * =>
502 fprint(stdout, "unknown message %c%c\n", e.c1, e.c2);
503 break;
504 }
505 * =>
506 fprint(stdout, "unknown message %c%c\n", e.c1, e.c2);
507 break;
508 }
509 q.l.unlock();
510 }
511}
512
513stdoutx(fd1 : ref FD, afd : ref FD, dfd : ref FD)
514{
515 n, m, w, npart : int;
516 s, t : int;
517 buf, hold, x : array of byte;
518 r, ok : int;
519
520 buf = array[8192+UTFmax+1] of byte;
521 hold = array[UTFmax] of byte;
522 npart = 0;
523 for(;;){
524 n = read(fd1, buf[npart:], 8192);
525 if(n < 0)
526 error(nil);
527 if(n == 0)
528 continue;
529
530 # squash NULs
531 for (s = 0; s < n; s++)
532 if (buf[npart+s] == byte 0)
533 break;
534 if(s < n){
535 for(t=s; s<n; s++)
536 if(buf[npart+t] == buf[npart+s]) # assign =
537 t++;
538 n = t;
539 }
540
541 n += npart;
542
543 # hold on to final partial rune
544 npart = 0;
545 while(n>0 && (int buf[n-1]&16rC0)){
546 --n;
547 npart++;
548 if((int buf[n]&16rC0)!=16r80){
549 if(utfbytes(buf[n:], npart) > 0){
550 (r, w, ok) = byte2char(buf, n);
551 n += w;
552 npart -= w;
553 }
554 break;
555 }
556 }
557 if(n > 0){
558 hold[0:] = buf[n:n+npart];
559 buf[n] = byte 0;
560 q.l.lock();
561 str := sprint("#%d", q.p);
562 x = array of byte str;
563 m = len x;
564 if(write(afd, x, m) != m)
565 error("stdout writing address");
566 x = nil;
567 if(write(dfd, buf, n) != n)
568 error("stdout writing body");
569 q.p += nrunes(buf, n);
570 q.l.unlock();
571 buf[0:] = hold[0:npart];
572 }
573 }
574}
575
576delete(e : ref Event) : int
577{
578 q0, q1 : int;
579 deltap : int;
580
581 q0 = e.q0;
582 q1 = e.q1;
583 if(q1 <= q.p)
584 return e.q1-e.q0;
585 if(q0 >= q.p+ntyper)
586 return 0;
587 deltap = 0;
588 if(q0 < q.p){
589 deltap = q.p-q0;
590 q0 = 0;
591 }else
592 q0 -= q.p;
593 if(q1 > q.p+ntyper)
594 q1 = ntyper;
595 else
596 q1 -= q.p;
597 deltype(q0, q1);
598 return deltap;
599}
600
601addtype(c : int, p0 : int, b : array of byte, nb : int, nr : int)
602{
603 i, w : int;
604 r, ok : int;
605 p : int;
606 b0 : int;
607
608 for(i=0; i<nb; i+=w){
609 (r, w, ok) = byte2char(b, i);
610 if(r==16r7F && c=='K'){
611 if (pid)
612 postnote(PNGROUP, pid, "kill");
613 # write(pgrpfd, array of byte "interrupt", 9);
614 # toss all typing
615 q.p += ntyper+nr;
616 ntypebreak = 0;
617 ntypeb = 0;
618 ntyper = 0;
619 # buglet: more than one delete ignored
620 return;
621 }
622 if(r=='\n' || r==16r04)
623 ntypebreak++;
624 }
625 ot := typing;
626 typing = array[ntypeb+nb] of byte;
627 if(typing == nil)
628 error("realloc");
629 if (ot != nil)
630 typing[0:] = ot[0:ntypeb];
631 ot = nil;
632 if(p0 == ntyper)
633 typing[ntypeb:] = b[0:nb];
634 else{
635 b0 = 0;
636 for(p=0; p<p0 && b0<ntypeb; p++){
637 (r, w, ok) = byte2char(typing[b0:], i);
638 b0 += w;
639 }
640 if(p != p0)
641 error("typing: findrune");
642 typing[b0+nb:] = typing[b0:ntypeb];
643 typing[b0:] = b[0:nb];
644 }
645 ntypeb += nb;
646 ntyper += nr;
647}
648
649sendtype(fd0 : ref FD, raw : int)
650{
651 i, n, nr : int;
652
653 while(ntypebreak){
654 brkc := 0;
655 for(i=0; i<ntypeb; i++)
656 if(typing[i]==byte '\n' || typing[i]==byte 16r04){
657 n = i + (typing[i] == byte '\n');
658 i++;
659 if(write(fd0, typing, n) != n)
660 error("sending to program");
661 nr = nrunes(typing, i);
662 if (!raw)
663 q.p += nr;
664 ntyper -= nr;
665 ntypeb -= i;
666 typing[0:] = typing[i:i+ntypeb];
667 ntypebreak--;
668 brkc = 1;
669 }
670 if (!brkc) {
671 fprint(stdout, "no breakchar\n");
672 ntypebreak = 0;
673 }
674 }
675}
676
677deltype(p0 : int, p1 : int)
678{
679 w : int;
680 p, b0, b1 : int;
681 r, ok : int;
682
683 # advance to p0
684 b0 = 0;
685 for(p=0; p<p0 && b0<ntypeb; p++){
686 (r, w, ok) = byte2char(typing, b0);
687 b0 += w;
688 }
689 if(p != p0)
690 error("deltype 1");
691 # advance to p1
692 b1 = b0;
693 for(; p<p1 && b1<ntypeb; p++){
694 (r, w, ok) = byte2char(typing, b1);
695 b1 += w;
696 if(r=='\n' || r==16r04)
697 ntypebreak--;
698 }
699 if(p != p1)
700 error("deltype 2");
701 typing[b0:] = typing[b1:ntypeb];
702 ntypeb -= b1-b0;
703 ntyper -= p1-p0;
704}
705
706typex(e : ref Event, fd0 : ref FD, afd : ref FD, dfd : ref FD)
707{
708 m, n, nr : int;
709 buf : array of byte;
710
711 if(e.nr > 0)
712 addtype(e.c1, e.q0-q.p, e.b, e.nb, e.nr);
713 else{
714 buf = array[128] of byte;
715 m = e.q0;
716 while(m < e.q1){
717 str := sprint("#%d", m);
718 b := array of byte str;
719 n = len b;
720 write(afd, b, n);
721 b = nil;
722 n = read(dfd, buf, len buf);
723 nr = nrunes(buf, n);
724 while(m+nr > e.q1){
725 do; while(n>0 && (int buf[--n]&16rC0)==16r80);
726 --nr;
727 }
728 if(n == 0)
729 break;
730 addtype(e.c1, m-q.p, buf, n, nr);
731 m += nr;
732 }
733 }
734 buf = nil;
735 sendtype(fd0, 0);
736}
737
738send(e : ref Event, fd0 : ref FD, cfd : ref FD, afd : ref FD, dfd : ref FD, donl : int)
739{
740 l, m, n, nr, lastc, end : int;
741 abuf, buf : array of byte;
742
743 buf = array[128] of byte;
744 end = q.p+ntyper;
745 str := sprint("#%d", end);
746 abuf = array of byte str;
747 l = len abuf;
748 write(afd, abuf, l);
749 abuf = nil;
750 if(e.nr > 0){
751 write(dfd, e.b, e.nb);
752 addtype(e.c1, ntyper, e.b, e.nb, e.nr);
753 lastc = e.r[e.nr-1];
754 }else{
755 m = e.q0;
756 lastc = 0;
757 while(m < e.q1){
758 str = sprint("#%d", m);
759 abuf = array of byte str;
760 n = len abuf;
761 write(afd, abuf, n);
762 abuf = nil;
763 n = read(dfd, buf, len buf);
764 nr = nrunes(buf, n);
765 while(m+nr > e.q1){
766 do; while(n>0 && (int buf[--n]&16rC0)==16r80);
767 --nr;
768 }
769 if(n == 0)
770 break;
771 str = sprint("#%d", end);
772 abuf = array of byte str;
773 l = len abuf;
774 write(afd, abuf, l);
775 abuf = nil;
776 write(dfd, buf, n);
777 addtype(e.c1, ntyper, buf, n, nr);
778 lastc = int buf[n-1];
779 m += nr;
780 end += nr;
781 }
782 }
783 if(donl && lastc!='\n'){
784 write(dfd, array of byte "\n", 1);
785 addtype(e.c1, ntyper, array of byte "\n", 1, 1);
786 }
787 write(cfd, array of byte "dot=addr", 8);
788 sendtype(fd0, 0);
789 buf = nil;
790}
791
appl/acme/acme/edit/guide+4−0
@@ -0,0 +1,4 @@
1e file | x '/regexp/' | c 'replacement'
2e 'file:0,$' | x '/.*word.*\n/' | p -n
3e file | pipe command args ...
4New /absolute/file/name
appl/acme/acme/edit/mkfile+24−0
@@ -0,0 +1,24 @@
1<../../../../mkconfig
2
3BIN=$ROOT/acme/edit
4
5DIRS=\
6 src\
7
8TARG=\
9 guide\
10 readme\
11
12BINTARG=${TARG:%=$BIN/%}
13
14all:V: $TARG
15
16install:V: $BINTARG
17
18$BIN/guide : guide
19 rm -f $BIN/guide && cp guide $BIN/guide
20
21$BIN/readme : readme
22 rm -f $BIN/readme && cp readme $BIN/readme
23
24<$ROOT/mkfiles/mksubdirs
appl/acme/acme/edit/readme+31−0
@@ -0,0 +1,31 @@
1The programs collected in /acme/edit offer a sam-like command interface
2to acme windows. The guide file
3 /acme/edit/guide
4holds templates for several editing operations implemented
5by external programs. These programs, composed in
6a pipeline, refine the sections of a file to be modified.
7Thus in sam when one says
8 x/.*\n/ g/foo/ p
9in /acme/edit one runs
10 x '/.*\n/' | g '/foo/' | p
11The e command, unrelated to e in sam, disambiguates file names, collects
12lists of names, etc., and produces input suitable for the other tools.
13For example:
14 e '/usr/rob/acme:0,$' | x /oldname/ | c /newname/
15changes oldname to newname in all the files loaded in acme whose names match
16the literal text /usr/rob/acme.
17
18The commands in /acme/edit are
19 e
20 x
21 g
22 c
23 d
24 p
25 pipe (like sam's | , which can't be used for syntactic reasons)
26
27p takes a -n flag analogous to grep's -n. There is no s command.
28e has a -l flag to produce line numbers instead of the default character numbers.
29Its implementation is poor but sufficient for the mundane job of recreating
30the occasional line number for tools like acid; its use with the other commands
31in this directory is discouraged.
appl/acme/acme/edit/src/a.b+89−0
@@ -0,0 +1,89 @@
1implement Aa;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Aa : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stderr = fildes(2);
25 main(argl);
26}
27
28include "findfile.b";
29
30prog := "a";
31bin : ref Iobuf;
32
33main(argv : list of string)
34{
35 afd, cfd, dfd : ref FD;
36 i, id : int;
37 nf, n, seq, rlen : int;
38 f, tf : array of File;
39 buf, s : string;
40
41 if(len argv != 2){
42 fprint(stderr, "usage: %s 'replacement'\n", prog);
43 exit;
44 }
45
46include "input.b";
47
48 # sort back to original order, backwards
49 qsort(f, nf, BSCMP);
50
51 # change
52 id = -1;
53 afd = nil;
54 cfd = nil;
55 dfd = nil;
56 ab := array of byte hd tl argv;
57 rlen = len ab;
58 for(i=0; i<nf; i++){
59 if(f[i].ok == 0)
60 continue;
61 if(f[i].id != id){
62 if(id > 0){
63 afd = nil;
64 cfd = nil;
65 dfd = nil;
66 }
67 id = f[i].id;
68 buf = sprint("/mnt/acme/%d/addr", id);
69 afd = open(buf, ORDWR);
70 if(afd == nil)
71 rerror(buf);
72 buf = sprint("/mnt/acme/%d/data", id);
73 dfd = open(buf, ORDWR);
74 if(dfd == nil)
75 rerror(buf);
76 buf = sprint("/mnt/acme/%d/ctl", id);
77 cfd = open(buf, ORDWR);
78 if(cfd == nil)
79 rerror(buf);
80 if(write(cfd, array of byte "mark\nnomark\n", 12) != 12)
81 rerror("setting nomark");
82 }
83 if(fprint(afd, "#%d", f[i].q1) < 0)
84 rerror("writing address");
85 if(write(dfd, ab, rlen) != rlen)
86 rerror("writing replacement");
87 }
88 exit;
89}
appl/acme/acme/edit/src/c.b+104−0
@@ -0,0 +1,104 @@
1implement Cc;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Cc : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stderr = fildes(2);
25 main(argl);
26}
27
28prog := "c";
29
30include "findfile.b";
31
32bin : ref Iobuf;
33
34main(argv : list of string)
35{
36 afd, cfd, dfd : ref FD;
37 i, j, id : int;
38 r : string;
39 nf, n, seq, rlen : int;
40 f, tf : array of File;
41 buf, s : string;
42
43 if(len argv != 2){
44 fprint(stderr, "usage: %s 'replacement'\n", prog);
45 exit;
46 }
47
48include "input.b";
49
50 # sort back to original order, backwards
51 qsort(f, nf, BSCMP);
52
53 # change
54 id = -1;
55 afd = nil;
56 cfd = nil;
57 dfd = nil;
58 argv1 := hd tl argv;
59 rlen = len argv1;
60 r = argv1;
61 i = 0;
62 for(j=0; j<rlen; j++){
63 r[i] = argv1[j];
64 if(i>0 && r[i-1]=='\\'){
65 if(r[i] == 'n')
66 r[--i] = '\n';
67 else if(r[i]=='\\')
68 r[--i] = '\\';
69 }
70 i++;
71 }
72 rlen = i;
73 ab := array of byte r[0:rlen];
74 rlen = len ab;
75 for(i=0; i<nf; i++){
76 if(f[i].ok == 0)
77 continue;
78 if(f[i].id != id){
79 if(id > 0){
80 afd = cfd = dfd = nil;
81 }
82 id = f[i].id;
83 buf = sprint("/mnt/acme/%d/addr", id);
84 afd = open(buf, ORDWR);
85 if(afd == nil)
86 rerror(buf);
87 buf = sprint("/mnt/acme/%d/data", id);
88 dfd = open(buf, ORDWR);
89 if(dfd == nil)
90 rerror(buf);
91 buf = sprint("/mnt/acme/%d/ctl", id);
92 cfd = open(buf, ORDWR);
93 if(cfd == nil)
94 rerror(buf);
95 if(write(cfd, array of byte "mark\nnomark\n", 12) != 12)
96 rerror("setting nomark");
97 }
98 if(fprint(afd, "#%d,#%d", f[i].q0, f[i].q1) < 0)
99 rerror("writing address");
100 if(write(dfd, ab, rlen) != rlen)
101 rerror("writing replacement");
102 }
103 exit;
104}
appl/acme/acme/edit/src/d.b+30−0
@@ -0,0 +1,30 @@
1implement Dd;
2
3include "sys.m";
4include "draw.m";
5include "sh.m";
6
7Dd : module {
8 init : fn(ctxt : ref Draw->Context, argl : list of string);
9};
10
11init(ctxt : ref Draw->Context, argl : list of string)
12{
13 sys := load Sys Sys->PATH;
14 stderr := sys->fildes(2);
15 if (len argl != 1) {
16 sys->fprint(stderr, "usage : d\n");
17 return;
18 }
19 cmd := "/acme/edit/c";
20 file := cmd + ".dis";
21 c := load Command file;
22 if(c == nil) {
23 sys->fprint(stderr, "%s: %r\n", cmd);
24 return;
25 }
26 argl = nil;
27 argl = "" :: argl;
28 argl = cmd :: argl;
29 c->init(ctxt, argl);
30}
appl/acme/acme/edit/src/e.b+154−0
@@ -0,0 +1,154 @@
1implement Ee;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Ee : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stdout, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29include "findfile.b";
30
31prog := "e";
32
33main(argv : list of string)
34{
35 afd, cfd : ref FD;
36 i, id : int;
37 buf : string;
38 nf, n, lines, l0, l1 : int;
39 f, tf : array of File;
40
41 lines = 0;
42 if(len argv>1 && hd tl argv == "-l"){
43 lines = 1;
44 argv = tl argv;
45 }
46 if(len argv < 2){
47 fprint(stderr, "usage: %s 'file[:address]' ...\n", prog);
48 exit;
49 }
50 nf = 0;
51 f = nil;
52 for(argv = tl argv; argv != nil; argv = tl argv){
53 (n, tf) = findfile(hd argv);
54 if(n == 0)
55 errors("no files match pattern", hd argv);
56 oldf := f;
57 f = array[n+nf] of File;
58 if(f == nil)
59 rerror("out of memory");
60 if (oldf != nil) {
61 f[0:] = oldf[0:nf];
62 oldf = nil;
63 }
64 f[nf:] = tf[0:n];
65 nf += n;
66 tf = nil;
67 }
68
69 # convert to character positions
70 for(i=0; i<nf; i++){
71 id = f[i].id;
72 buf = sprint("/mnt/acme/%d/addr", id);
73 afd = open(buf, ORDWR);
74 if(afd == nil)
75 rerror(buf);
76 buf = sprint("/mnt/acme/%d/ctl", id);
77 cfd = open(buf, ORDWR);
78 if(cfd == nil)
79 rerror(buf);
80 if(write(cfd, array of byte "addr=dot\n", 9) != 9)
81 rerror("setting address to dot");
82 ab := array of byte f[i].addr;
83 if(write(afd, ab, len ab) != len ab){
84 fprint(stderr, "%s: %s:%s is invalid address\n", prog, f[i].name, f[i].addr);
85 f[i].ok = 0;
86 afd = nil;
87 cfd = nil;
88 continue;
89 }
90 seek(afd, big 0, 0);
91 ab = array[24] of byte;
92 if(read(afd, ab, len ab) != 2*12)
93 rerror("reading address");
94 afd = nil;
95 cfd = nil;
96 buf = string ab;
97 ab = nil;
98 f[i].q0 = int buf;
99 f[i].q1 = int buf[12:];
100 f[i].ok = 1;
101 }
102
103 # sort
104 qsort(f, nf, FCMP);
105
106 # print
107 for(i=0; i<nf; i++){
108 if(f[i].ok)
109 if(lines){
110 (l0, l1) = lineno(f[i]);
111 if(l1 > l0)
112 fprint(stdout, "%s:%d,%d\n", f[i].name, l0, l1);
113 else
114 fprint(stdout, "%s:%d\n", f[i].name, l0);
115 }else{
116 if(f[i].q1 > f[i].q0)
117 fprint(stdout, "%s:#%d,#%d\n", f[i].name, f[i].q0, f[i].q1);
118 else
119 fprint(stdout, "%s:#%d\n", f[i].name, f[i].q0);
120 }
121 }
122 exit;
123}
124
125lineno(f : File) : (int, int)
126{
127 b : ref Iobuf;
128 n0, n1, q, r : int;
129 buf : string;
130
131 buf = sprint("/mnt/acme/%d/body", f.id);
132 b = bufio->open(buf, bufio->OREAD);
133 if(b == nil){
134 fprint(stderr, "%s: can't open %s: %r\n", prog, buf);
135 exit;
136 }
137 n0 = 1;
138 n1 = 1;
139 for(q=0; q<f.q1; q++){
140 r = b.getc();
141 if(r == bufio->EOF){
142 fprint(stderr, "%s: early EOF on %s\n", prog, buf);
143 exit;
144 }
145 if(r=='\n'){
146 if(q < f.q0)
147 n0++;
148 if(q+1 < f.q1)
149 n1++;
150 }
151 }
152 b.close();
153 return (n0, n1);
154}
appl/acme/acme/edit/src/findfile.b+210−0
@@ -0,0 +1,210 @@
1File : adt {
2 id : int;
3 seq : int;
4 ok : int;
5 q0, q1 : int;
6 name : string;
7 addr : string;
8};
9
10BSCMP, SCMP, NCMP, FCMP : con iota;
11
12indexfile := "/mnt/acme/index";
13
14dfd: ref Sys->FD;
15debug(s : string)
16{
17 if (dfd == nil)
18 dfd = sys->create("/usr/jrf/acme/debugedit", Sys->OWRITE, 8r600);
19 sys->fprint(dfd, "%s", s);
20}
21
22error(s : string)
23{
24 fprint(stderr, "%s: %s\n", prog, s);
25 exit;
26}
27
28errors(s, t : string)
29{
30 fprint(stderr, "%s: %s %s\n", prog, s, t);
31 exit;
32}
33
34rerror(s : string)
35{
36 fprint(stderr, "%s: %s: %r\n", prog, s);
37 exit;
38}
39
40strcmp(s, t : string) : int
41{
42 if (s < t) return -1;
43 if (s > t) return 1;
44 return 0;
45}
46
47strstr(s, t : string) : int
48{
49 if (t == nil)
50 return 0;
51 n := len t;
52 if (n > len s)
53 return -1;
54 e := len s - n;
55 for (p := 0; p <= e; p++)
56 if (s[p:p+n] == t)
57 return p;
58 return -1;
59}
60
61nrunes(s : array of byte, nb : int) : int
62{
63 i, n, r, b, ok : int;
64
65 n = 0;
66 for(i=0; i<nb; n++) {
67 (r, b, ok) = byte2char(s, i);
68 i += b;
69 }
70 return n;
71}
72
73index : ref Iobuf;
74
75findfile(pat : string) : (int, array of File)
76{
77 line, pat1, pat2 : string;
78 colon, blank : int;
79 n : int;
80 f : array of File;
81
82 if(index == nil)
83 index = bufio->open(indexfile, bufio->OREAD);
84 else
85 index.seek(big 0, 0);
86 if(index == nil)
87 rerror(indexfile);
88 for(colon=0; colon < len pat && pat[colon]!=':'; colon++)
89 ;
90 if (colon == len pat) {
91 pat1 = pat;
92 pat2 = ".";
93 }
94 else {
95 pat1 = pat[0:colon];
96 pat2 = pat[colon+1:];
97 }
98 n = 0;
99 f = nil;
100 while((line=index.gets('\n')) != nil){
101 if(len line < 5*12)
102 rerror("bad index file format");
103 line = line[0:len line - 1];
104 for(blank=5*12; blank < len line && line[blank]!=' '; blank++)
105 ;
106 if (blank < len line)
107 line = line[0:blank];
108 if(strcmp(line[5*12:], pat1) == 0){
109 # exact match: take that
110 f = nil; # should also free t->addr's
111 f = array[1] of File;
112 if(f == nil)
113 rerror("out of memory");
114 f[0].id = int line;
115 f[0].name = line[5*12:];
116 f[0].addr = pat2;
117 n = 1;
118 break;
119 }
120 if(strstr(line[5*12:], pat1) >= 0){
121 # partial match: add to list
122 off := f;
123 f = array[n+1] of File;
124 if(f == nil)
125 rerror("out of memory");
126 f[0:] = off[0:n];
127 off = nil;
128 f[n].id = int line;
129 f[n].name = line[5*12:];
130 f[n].addr = pat2;
131 n++;
132 }
133 }
134 return (n, f);
135}
136
137bscmp(a : File, b : File) : int
138{
139 return b.seq - a.seq;
140}
141
142scmp(a : File, b : File) : int
143{
144 return a.seq - b.seq;
145}
146
147ncmp(a : File, b : File) : int
148{
149 return strcmp(a.name, b.name);
150}
151
152fcmp(a : File, b : File) : int
153{
154 x : int;
155
156 if (a.name < b.name)
157 return -1;
158 if (a.name > b.name)
159 return 1;
160 x = a.q0 - b.q0;
161 if(x != 0)
162 return x;
163 return a.q1-b.q1;
164}
165
166gencmp(a : File, b : File, c : int) : int
167{
168 if (c == BSCMP)
169 return bscmp(a, b);
170 if (c == SCMP)
171 return scmp(a, b);
172 if (c == NCMP)
173 return ncmp(a, b);
174 if (c == FCMP)
175 return fcmp(a, b);
176 return 0;
177}
178
179qsort(a : array of File, n : int, c : int)
180{
181 i, j : int;
182 t : File;
183
184 while(n > 1) {
185 i = n>>1;
186 t = a[0]; a[0] = a[i]; a[i] = t;
187 i = 0;
188 j = n;
189 for(;;) {
190 do
191 i++;
192 while(i < n && gencmp(a[i], a[0], c) < 0);
193 do
194 j--;
195 while(j > 0 && gencmp(a[j], a[0], c) > 0);
196 if(j < i)
197 break;
198 t = a[i]; a[i] = a[j]; a[j] = t;
199 }
200 t = a[0]; a[0] = a[j]; a[j] = t;
201 n = n-j-1;
202 if(j >= n) {
203 qsort(a, j, c);
204 a = a[j+1:];
205 } else {
206 qsort(a[j+1:], n, c);
207 n = j;
208 }
209 }
210}
appl/acme/acme/edit/src/g.b+95−0
@@ -0,0 +1,95 @@
1implement Gg;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Gg : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stdout, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29prog := "g";
30
31include "findfile.b";
32
33bin : ref Iobuf;
34
35main(argv : list of string)
36{
37 afd, cfd, dfd : ref FD;
38 i, id, seq : int;
39 nf, n, plen : int;
40 f, tf : array of File;
41 buf, s : string;
42
43 if(len argv!=2 || len hd tl argv==0 || (hd tl argv)[0]!='/'){
44 fprint(stderr, "usage: %s '/regexp/'\n", prog);
45 exit;
46 }
47
48include "input.b";
49
50 # execute regexp
51 id = -1;
52 afd = nil;
53 dfd = nil;
54 cfd = nil;
55 bufb := array of byte hd tl argv;
56 plen = len bufb;
57 for(i=0; i<nf; i++){
58 if(f[i].ok == 0)
59 continue;
60 if(f[i].id != id){
61 if(id > 0){
62 afd = cfd = dfd = nil;
63 }
64 id = f[i].id;
65 buf = sprint("/mnt/acme/%d/addr", id);
66 afd = open(buf, ORDWR);
67 if(afd == nil)
68 rerror(buf);
69 buf = sprint("/mnt/acme/%d/ctl", id);
70 cfd = open(buf, ORDWR);
71 if(cfd == nil)
72 rerror(buf);
73 buf = sprint("/mnt/acme/%d/data", id);
74 dfd = open(buf, ORDWR);
75 if(dfd == nil)
76 rerror(buf);
77 }
78 ab := array of byte f[i].addr;
79 n = len ab;
80 if(write(afd, ab, n)!=n || fprint(cfd, "limit=addr\n")<0){
81 buf = sprint("%s:%s is invalid limit", f[i].name, f[i].addr);
82 rerror(buf);
83 }
84 if(fprint(afd, "#%d", f[i].q0) < 0)
85 rerror("can't set dot");
86 # look for match
87 if(write(afd, bufb, plen) == plen){
88 if(f[i].q0 == f[i].q1)
89 fprint(stdout, "%s:#%d\n", f[i].name, f[i].q0);
90 else
91 fprint(stdout, "%s:#%d,#%d\n", f[i].name, f[i].q0, f[i].q1);
92 }
93 }
94 exit;
95}
appl/acme/acme/edit/src/i.b+88−0
@@ -0,0 +1,88 @@
1implement Ii;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Ii : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stderr = fildes(2);
25 main(argl);
26}
27
28prog := "i";
29
30include "findfile.b";
31
32bin : ref Iobuf;
33
34main(argv : list of string)
35{
36 afd, cfd, dfd : ref FD;
37 i, id : int;
38 nf, n, seq, rlen : int;
39 f, tf : array of File;
40 s, buf : string;
41
42 if(len argv != 2){
43 fprint(stderr, "usage: %s 'replacement'\n", prog);
44 exit;
45 }
46
47include "input.b";
48
49 # sort back to original order, backwards
50 qsort(f, nf, BSCMP);
51
52 # change
53 id = -1;
54 afd = nil;
55 cfd = nil;
56 dfd = nil;
57 ab := array of byte hd tl argv;
58 rlen = len ab;
59 for(i=0; i<nf; i++){
60 if(f[i].ok == 0)
61 continue;
62 if(f[i].id != id){
63 if(id > 0){
64 afd = cfd = dfd = nil;
65 }
66 id = f[i].id;
67 buf = sprint("/mnt/acme/%d/addr", id);
68 afd = open(buf, ORDWR);
69 if(afd == nil)
70 rerror(buf);
71 buf = sprint("/mnt/acme/%d/data", id);
72 dfd = open(buf, ORDWR);
73 if(dfd == nil)
74 rerror(buf);
75 buf = sprint("/mnt/acme/%d/ctl", id);
76 cfd = open(buf, ORDWR);
77 if(cfd == nil)
78 rerror(buf);
79 if(write(cfd, array of byte "mark\nnomark\n", 12) != 12)
80 rerror("setting nomark");
81 }
82 if(fprint(afd, "#%d", f[i].q0) < 0)
83 rerror("writing address");
84 if(write(dfd, ab, rlen) != rlen)
85 rerror("writing replacement");
86 }
87 exit;
88}
appl/acme/acme/edit/src/input.b+84−0
@@ -0,0 +1,84 @@
1 bin = bufio->fopen(stdin, bufio->OREAD);
2 seq = 0;
3 nf = 0;
4 f = nil;
5 while((s=bin.gets('\n')) != nil){
6 s = s[0:len s - 1];
7 (n, tf) = findfile(s);
8 if(n == 0)
9 errors("no files match input", s);
10 for(i=0; i<n; i++)
11 tf[i].seq = seq++;
12 off := f;
13 f = array[n+nf] of File;
14 if(f == nil)
15 rerror("out of memory");
16 if (off != nil) {
17 f[0:] = off[0:nf];
18 off = nil;
19 }
20 f[nf:] = tf[0:n];
21 nf += n;
22 tf = nil;
23 }
24
25 # sort by file name
26 qsort(f, nf, NCMP);
27
28 # convert to character positions if necessary
29 for(i=0; i<nf; i++){
30 f[i].ok = 1;
31 # see if it's easy
32 s = f[i].addr;
33 if(s[0]=='#'){
34 s = s[1:];
35 n = 0;
36 while(len s > 0 && '0'<=s[0] && s[0]<='9'){
37 n = n*10+(s[0]-'0');
38 s = s[1:];
39 }
40 f[i].q0 = n;
41 if(len s == 0){
42 f[i].q1 = n;
43 continue;
44 }
45 if(s[0] == ',') {
46 s = s[1:];
47 n = 0;
48 while(len s > 0 && '0'<=s[0] && s[0]<='9'){
49 n = n*10+(s[0]-'0');
50 s = s[1:];
51 }
52 f[i].q1 = n;
53 if(len s == 0)
54 continue;
55 }
56 }
57 id = f[i].id;
58 buf = sprint("/chan/%d/addr", id);
59 afd = open(buf, ORDWR);
60 if(afd == nil)
61 rerror(buf);
62 buf = sprint("/chan/%d/ctl", id);
63 cfd = open(buf, ORDWR);
64 if(cfd == nil)
65 rerror(buf);
66 if(write(cfd, array of byte "addr=dot\n", 9) != 9)
67 rerror("setting address to dot");
68 ab := array of byte f[i].addr;
69 if(write(afd, ab, len ab) != len ab){
70 fprint(stderr, "%s: %s:%s is invalid address\n", prog, f[i].name, f[i].addr);
71 f[i].ok = 0;
72 afd = cfd = nil;
73 continue;
74 }
75 seek(afd, big 0, 0);
76 bbuf := array[2*12] of byte;
77 if(read(afd, bbuf, len bbuf) != 2*12)
78 rerror("reading address");
79 afd = cfd = nil;
80 buf = string bbuf;
81 bbuf = nil;
82 f[i].q0 = int buf;
83 f[i].q1 = int buf[12:];
84 }
appl/acme/acme/edit/src/mkfile+23−0
@@ -0,0 +1,23 @@
1<../../../../../mkconfig
2
3TARG=\
4 a.dis\
5 c.dis\
6 d.dis\
7 e.dis\
8 g.dis\
9 i.dis\
10 p.dis\
11 x.dis\
12 pipe.dis\
13
14MODULES=\
15
16SYSMODULES=\
17 sh.m\
18 sys.m\
19 draw.m\
20
21DISBIN=$ROOT/acme/edit
22
23<$ROOT/mkfiles/mkdis
appl/acme/acme/edit/src/p.b+109−0
@@ -0,0 +1,109 @@
1implement Pp;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Pp : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stdout, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29include "findfile.b";
30
31prog := "p";
32bin : ref Iobuf;
33
34main(argv : list of string)
35{
36 afd, cfd, dfd : ref FD;
37 i, id : int;
38 m, nr, nf, n, nflag, seq : int;
39 f, tf : array of File;
40 buf, s : string;
41
42 nflag = 0;
43 if(len argv==2 && hd tl argv == "-n"){
44 argv = tl argv;
45 nflag = 1;
46 }
47 if(len argv != 1){
48 fprint(stderr, "usage: %s [-n]\n", prog);
49 exit;
50 }
51
52include "input.b";
53
54 # sort back to original order
55 qsort(f, nf, SCMP);
56
57 # print
58 id = -1;
59 afd = nil;
60 cfd = nil;
61 dfd = nil;
62 for(i=0; i<nf; i++){
63 if(f[i].ok == 0)
64 continue;
65 if(f[i].id != id){
66 if(id > 0){
67 afd = cfd = dfd = nil;
68 }
69 id = f[i].id;
70 buf = sprint("/mnt/acme/%d/addr", id);
71 afd = open(buf, ORDWR);
72 if(afd == nil)
73 rerror(buf);
74 buf = sprint("/mnt/acme/%d/data", id);
75 dfd = open(buf, ORDWR);
76 if(dfd == nil)
77 rerror(buf);
78 buf = sprint("/mnt/acme/%d/ctl", id);
79 cfd = open(buf, ORDWR);
80 if(cfd == nil)
81 rerror(buf);
82 }
83 if(nflag){
84 if(f[i].q1 > f[i].q0)
85 fprint(stdout, "%s:#%d,#%d: ", f[i].name, f[i].q0, f[i].q1);
86 else
87 fprint(stdout, "%s:#%d: ", f[i].name, f[i].q0);
88 }
89 m = f[i].q0;
90 while(m < f[i].q1){
91 if(fprint(afd, "#%d", m) < 0){
92 fprint(stderr, "%s: %s:%s is invalid address\n", prog, f[i].name, f[i].addr);
93 continue;
94 }
95 bbuf := array[512] of byte;
96 n = read(dfd, bbuf, len buf);
97 nr = nrunes(bbuf, n);
98 while(m+nr > f[i].q1){
99 do; while(n>0 && (int bbuf[--n]&16rC0)==16r80);
100 --nr;
101 }
102 if(n == 0)
103 break;
104 write(stdout, bbuf, n);
105 m += nr;
106 }
107 }
108 exit;
109}
appl/acme/acme/edit/src/pipe.b+212−0
@@ -0,0 +1,212 @@
1implement Pipe;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6include "sh.m";
7
8sys : Sys;
9bufio : Bufio;
10
11UTFmax, ORDWR, NEWFD, FD, open, read, write, seek, sprint, fprint, fildes, byte2char, pipe, dup, pctl : import sys;
12Iobuf : import bufio;
13
14Pipe : module {
15 init : fn(ctxt : ref Draw->Context, argl : list of string);
16};
17
18stdin, stderr : ref FD;
19pipectxt : ref Draw->Context;
20
21init(ctxt : ref Draw->Context, argl : list of string)
22{
23 pipectxt = ctxt;
24 sys = load Sys Sys->PATH;
25 bufio = load Bufio Bufio->PATH;
26 stdin = fildes(0);
27 stderr = fildes(2);
28 main(argl);
29}
30
31include "findfile.b";
32
33prog := "pipe";
34bin : ref Iobuf;
35
36main(argv : list of string)
37{
38 afd, dfd, cfd : ref FD;
39 nf, nc, nr, npart : int;
40 p1, p2 : array of ref FD;
41 i, n, id, seq : int;
42 buf : string;
43 tmp, data : array of byte;
44 s : string;
45 r, s0 : int;
46 f, tf : array of File;
47 q, q0, q1 : int;
48 cpid : chan of int;
49 w, ok : int;
50
51 if(len argv < 2){
52 fprint(stderr, "usage: pipe command\n");
53 exit;
54 }
55
56include "input.b";
57
58 # sort back to original order
59 qsort(f, nf, SCMP);
60
61 # pipe
62 id = -1;
63 afd = nil;
64 cfd = nil;
65 dfd = nil;
66 tmp = array[8192+UTFmax] of byte;
67 if(tmp == nil)
68 error("malloc");
69 cpid = chan of int;
70 for(i=0; i<nf; i++){
71 if(f[i].id != id){
72 if(id > 0){
73 afd = cfd = dfd = nil;
74 }
75 id = f[i].id;
76 buf = sprint("/mnt/acme/%d/addr", id);
77 afd = open(buf, ORDWR);
78 if(afd == nil)
79 rerror(buf);
80 buf = sprint("/mnt/acme/%d/data", id);
81 dfd = open(buf, ORDWR);
82 if(dfd == nil)
83 rerror(buf);
84 buf = sprint("/mnt/acme/%d/ctl", id);
85 cfd = open(buf, ORDWR);
86 if(cfd == nil)
87 rerror(buf);
88 if(write(cfd, array of byte "mark\nnomark\n", 12) != 12)
89 rerror("setting nomark");
90 }
91
92 if(fprint(afd, "#%ud", f[i].q0) < 0)
93 rerror("writing address");
94
95 q0 = f[i].q0;
96 q1 = f[i].q1;
97 # suck up data
98 data = array[(q1-q0)*UTFmax+1] of byte;
99 if(data == nil)
100 error("malloc failed\n");
101 s0 = 0;
102 q = q0;
103 bbuf := array[12] of byte;
104 while(q < q1){
105 nc = read(dfd, data[s0:], (q1-q)*UTFmax);
106 if(nc <= 0)
107 error("read error from acme");
108 seek(afd, big 0, 0);
109 if(read(afd, bbuf, 12) != 12)
110 rerror("reading address");
111 q = int string bbuf;
112 s0 += nc;
113 }
114 bbuf = nil;
115 s0 = 0;
116 for(nr=0; nr<q1-q0; nr++) {
117 (r, w, ok) = byte2char(data, s0);
118 s0 += w;
119 }
120
121 p1 = array[2] of ref FD;
122 p2 = array[2] of ref FD;
123 if(pipe(p1)<0 || pipe(p2)<0)
124 error("pipe");
125
126 spawn run(tl argv, p1[0], p2[1], cpid);
127 <-cpid;
128 p1[0] = nil;
129 p2[1] = nil;
130
131 spawn send(data, s0, p1[1]);
132 p1[1] = nil;
133
134 # put back data
135 if(fprint(afd, "#%d,#%d", q0, q1) < 0)
136 rerror("writing address");
137
138 npart = 0;
139 q1 = q0;
140 while((nc = read(p2[0], tmp[npart:], 8192)) > 0){
141 nc += npart;
142 s0 = 0;
143 while(s0 <= nc-UTFmax){
144 (r, w, ok) = byte2char(tmp, s0);
145 s0 += w;
146 q1++;
147 }
148 if(s0 > 0)
149 if(write(dfd, tmp, s0) != s0)
150 error("write error to acme");
151 npart = nc - s0;
152 tmp[0:] = tmp[s0:s0+npart];
153 }
154 p2[0] = nil;
155 if(npart){
156 s0 = 0;
157 while(s0 < npart){
158 (r, w, ok) = byte2char(tmp, s0);
159 s0 += w;
160 q1++;
161 }
162 if(write(dfd, tmp, npart) != npart)
163 error("write error to acme");
164 }
165 if(fprint(afd, "#%d,#%d", q0, q1) < 0)
166 rerror("writing address");
167 if(fprint(cfd, "dot=addr\n") < 0)
168 rerror("writing dot");
169 data = nil;
170 }
171}
172
173run(argv : list of string, p1, p2 : ref FD, c : chan of int)
174{
175 pctl(NEWFD, 0::1::2::p1.fd::p2.fd::nil);
176 dup(p1.fd, 0);
177 dup(p2.fd, 1);
178 c <-= pctl(0, nil);
179 exec(hd argv, argv);
180 fprint(stderr, "can't exec");
181 exit;
182}
183
184send(buf : array of byte, nbuf : int, fd : ref FD)
185{
186 if(write(fd, buf, nbuf) != nbuf)
187 error("write error to process");
188 fd = nil;
189}
190
191exec(cmd : string, argl : list of string)
192{
193 file := cmd;
194 if(len file<4 || file[len file-4:]!=".dis")
195 file += ".dis";
196
197 c := load Command file;
198 if(c == nil) {
199 err := sys->sprint("%r");
200 if(file[0]!='/' && file[0:2]!="./"){
201 c = load Command "/dis/"+file;
202 if(c == nil)
203 err = sys->sprint("%r");
204 }
205 if(c == nil){
206 sys->fprint(stderr, "%s: %s\n", cmd, err);
207 return;
208 }
209 }
210
211 c->init(pipectxt, argl);
212}
appl/acme/acme/edit/src/x.b+123−0
@@ -0,0 +1,123 @@
1implement Xx;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Xx : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stdout, stderr : ref FD;
18
19init(nil : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29include "findfile.b";
30
31prog := "x";
32bin : ref Iobuf;
33
34main(argv : list of string)
35{
36 afd, cfd, dfd : ref FD;
37 i, id, seq : int;
38 nf, n, plen : int;
39 addr, aq0, aq1, matched : int;
40 f, tf : array of File;
41 buf, s : string;
42 bbuf0 : array of byte;
43
44 if(len argv!=2 || len hd tl argv==0 || (hd tl argv)[0]!='/'){
45 fprint(stderr, "usage: %s '/regexp/'\n", prog);
46 exit;
47 }
48
49include "input.b";
50
51 # execute regexp
52 id = -1;
53 afd = nil;
54 dfd = nil;
55 cfd = nil;
56 for(i=0; i<nf; i++){
57 if(f[i].ok == 0)
58 continue;
59 if(f[i].id != id){
60 if(id > 0){
61 afd = cfd = dfd = nil;
62 }
63 id = f[i].id;
64 buf = sprint("/mnt/acme/%d/addr", id);
65 afd = open(buf, ORDWR);
66 if(afd == nil)
67 rerror(buf);
68 buf = sprint("/mnt/acme/%d/ctl", id);
69 cfd = open(buf, ORDWR);
70 if(cfd == nil)
71 rerror(buf);
72 buf = sprint("/mnt/acme/%d/data", id);
73 dfd = open(buf, ORDWR);
74 if(dfd == nil)
75 rerror(buf);
76 }
77 bbuf0 = array of byte f[i].addr;
78 n = len bbuf0;
79 if(write(afd, bbuf0, n)!=n || fprint(cfd, "limit=addr\n")<0){
80 buf = sprint("%s:%s is invalid limit", f[i].name, f[i].addr);
81 rerror(buf);
82 }
83 if(fprint(afd, "#%d", f[i].q0) < 0)
84 rerror("can't set address");
85 if(fprint(cfd, "dot=addr") < 0)
86 rerror("can't unset dot");
87 addr = f[i].q0-1;
88 bbuf := array of byte hd tl argv;
89 plen = len bbuf;
90 matched = 0;
91 # scan for matches
92 for(;;){
93 if(write(afd, bbuf, plen) != plen)
94 break;
95 seek(afd, big 0, 0);
96 bbuf0 = array[2*12] of byte;
97 if(read(afd, bbuf0, len bbuf0) != 2*12)
98 rerror("reading address");
99 buf = string bbuf0;
100 bbuf0 = nil;
101 aq0 = int buf;
102 aq1 = int buf[12:];
103 if(matched && aq1==aq0 && addr==aq1){ # repeated null match; advance
104 matched = 0;
105 addr++;
106 if(addr > f[i].q1)
107 break;
108 if(fprint(afd, "#%d", addr) < 0)
109 rerror("writing address");
110 continue;
111 }
112 matched = 1;
113 if(aq0<addr || aq0>=f[i].q1 || aq1>f[i].q1)
114 break;
115 addr = aq1;
116 if(aq0 == aq1)
117 fprint(stdout, "%s:#%d\n", f[i].name, aq0);
118 else
119 fprint(stdout, "%s:#%d,#%d\n", f[i].name, aq0, aq1);
120 }
121 }
122 exit;
123}
appl/acme/acme/edit/src/xxx.b+327−0
@@ -0,0 +1,327 @@
1implement Ee;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6
7sys : Sys;
8bufio : Bufio;
9
10ORDWR, FD, open, read, write, seek, sprint, fprint, fildes, byte2char : import sys;
11Iobuf : import bufio;
12
13Ee : module {
14 init : fn(ctxt : ref Draw->Context, argl : list of string);
15};
16
17stdin, stdout, stderr : ref FD;
18
19init(ctxt : ref Draw->Context, argl : list of string)
20{
21 sys = load Sys Sys->PATH;
22 bufio = load Bufio Bufio->PATH;
23 stdin = fildes(0);
24 stdout = fildes(1);
25 stderr = fildes(2);
26 main(argl);
27}
28
29File : adt {
30 id : int;
31 seq : int;
32 ok : int;
33 q0, q1 : int;
34 name : string;
35 addr : string;
36};
37
38BSCMP, SCMP, NCMP, FCMP : con iota;
39
40indexfile := "/usr/jrf/tmp/index";
41
42dfd: ref Sys->FD;
43debug(s : string)
44{
45 if (dfd == nil)
46 dfd = sys->create("/usr/jrf/acme/debugedit", Sys->OWRITE, 8r600);
47 sys->fprint(dfd, "%s", s);
48}
49
50error(s : string)
51{
52debug(sys->sprint("error %s\n", s));
53 fprint(stderr, "%s: %s\n", prog, s);
54 exit;
55}
56
57errors(s, t : string)
58{
59debug(sys->sprint("errors %s %s\n", s, t));
60 fprint(stderr, "%s: %s %s\n", prog, s, t);
61 exit;
62}
63
64rerror(s : string)
65{
66debug(sys->sprint("rerror %s\n", s));
67 fprint(stderr, "%s: %s: %r\n", prog, s);
68 exit;
69}
70
71strcmp(s, t : string) : int
72{
73 if (s < t) return -1;
74 if (s > t) return 1;
75 return 0;
76}
77
78strstr(s, t : string) : int
79{
80 if (t == nil)
81 return 0;
82 n := len t;
83 if (n > len s)
84 return -1;
85 e := len s - n;
86 for (p := 0; p <= e; p++)
87 if (s[p:p+n] == t)
88 return p;
89 return -1;
90}
91
92nrunes(s : array of byte, nb : int) : int
93{
94 i, n, r, b, ok : int;
95
96 n = 0;
97 for(i=0; i<nb; n++) {
98 (r, b, ok) = byte2char(s, i);
99 i += b;
100 }
101 return n;
102}
103
104index : ref Iobuf;
105
106findfile(pat : string) : (int, array of File)
107{
108 line, pat1, pat2 : string;
109 colon, blank : int;
110 n : int;
111 f : array of File;
112
113 if(index == nil)
114 index = bufio->open(indexfile, bufio->OREAD);
115 else
116 index.seek(0, 0);
117 if(index == nil)
118 rerror(indexfile);
119 for(colon=0; colon < len pat && pat[colon]!=':'; colon++)
120 ;
121 if (colon == len pat) {
122 pat1 = pat;
123 pat2 = ".";
124 }
125 else {
126 pat1 = pat[0:colon];
127 pat2 = pat[colon+1:];
128 }
129 n = 0;
130 f = nil;
131 while((line=index.gets('\n')) != nil){
132 if(len line < 5*12)
133 rerror("bad index file format");
134 line = line[0:len line - 1];
135 for(blank=5*12; blank < len line && line[blank]!=' '; blank++)
136 ;
137 if (blank < len line)
138 line = line[0:blank];
139 if(strcmp(line[5*12:], pat1) == 0){
140 # exact match: take that
141 f = nil; # should also free t->addr's
142 f = array[1] of File;
143 if(f == nil)
144 rerror("out of memory");
145 f[0].id = int line;
146 f[0].name = line[5*12:];
147 f[0].addr = pat2;
148 n = 1;
149 break;
150 }
151 if(strstr(line[5*12:], pat1) >= 0){
152 # partial match: add to list
153 off := f;
154 f = array[n+1] of File;
155 if(f == nil)
156 rerror("out of memory");
157 f[0:] = off[0:n];
158 off = nil;
159 f[n].id = int line;
160 f[n].name = line[5*12:];
161 f[n].addr = pat2;
162 n++;
163 }
164 }
165 return (n, f);
166}
167
168bscmp(a : File, b : File) : int
169{
170 return b.seq - a.seq;
171}
172
173scmp(a : File, b : File) : int
174{
175 return a.seq - b.seq;
176}
177
178ncmp(a : File, b : File) : int
179{
180 return strcmp(a.name, b.name);
181}
182
183fcmp(a : File, b : File) : int
184{
185 x : int;
186
187 if (a.name < b.name)
188 return -1;
189 if (a.name > b.name)
190 return 1;
191 x = a.q0 - b.q0;
192 if(x != 0)
193 return x;
194 return a.q1-b.q1;
195}
196
197gencmp(a : File, b : File, c : int) : int
198{
199 if (c == BSCMP)
200 return bscmp(a, b);
201 if (c == SCMP)
202 return scmp(a, b);
203 if (c == NCMP)
204 return ncmp(a, b);
205 if (c == FCMP)
206 return fcmp(a, b);
207 return 0;
208}
209
210qsort(a : array of File, n : int, c : int)
211{
212 i, j : int;
213 t : File;
214
215 while(n > 1) {
216 i = n>>1;
217 t = a[0]; a[0] = a[i]; a[i] = t;
218 i = 0;
219 j = n;
220 for(;;) {
221 do
222 i++;
223 while(i < n && gencmp(a[i], a[0], c) < 0);
224 do
225 j--;
226 while(j > 0 && gencmp(a[j], a[0], c) > 0);
227 if(j < i)
228 break;
229 t = a[i]; a[i] = a[j]; a[j] = t;
230 }
231 t = a[0]; a[0] = a[j]; a[j] = t;
232 n = n-j-1;
233 if(j >= n) {
234 qsort(a, j, c);
235 a = a[j+1:];
236 } else {
237 qsort(a[j+1:], n, c);
238 n = j;
239 }
240 }
241}
242
243prog := "e";
244
245main(argv : list of string)
246{
247 afd, cfd : ref FD;
248 i, id : int;
249 buf : string;
250 nf, n, lines, l0, l1 : int;
251 f, tf : array of File;
252
253 if(len argv < 2){
254debug(sys->sprint("usage\n"));
255 fprint(stderr, "usage: %s 'file[:address]' ...\n", prog);
256 exit;
257 }
258 nf = 0;
259 f = nil;
260 for(argv = tl argv; argv != nil; argv = tl argv){
261 (n, tf) = findfile(hd argv);
262 if(n == 0)
263 errors("no files match pattern", hd argv);
264 oldf := f;
265 f = array[n+nf] of File;
266 if(f == nil)
267 rerror("out of memory");
268 if (oldf != nil) {
269 f[0:] = oldf[0:nf];
270 oldf = nil;
271 }
272 f[nf:] = tf[0:n];
273 nf += n;
274 tf = nil;
275 }
276debug(sys->sprint("nf=%d\n", nf));
277 # convert to character positions
278 for(i=0; i<nf; i++){
279 id = f[i].id;
280 buf = sprint("/mnt/acme/%d/addr", id);
281 # afd = open(buf, ORDWR);
282 # if(afd == nil)
283 # rerror(buf);
284 buf = sprint("/mnt/acme/%d/ctl", id);
285 # cfd = open(buf, ORDWR);
286 # if(cfd == nil)
287 # rerror(buf);
288 if(0 && write(cfd, array of byte "addr=dot\n", 9) != 9)
289 rerror("setting address to dot");
290 ab := array of byte f[i].addr;
291 if(0 && write(afd, ab, len ab) != len ab){
292 fprint(stderr, "%s: %s:%s is invalid address\n", prog, f[i].name, f[i].addr);
293 f[i].ok = 0;
294 afd = nil;
295 cfd = nil;
296 continue;
297 }
298 # seek(afd, 0, 0);
299 ab = array[24] of byte;
300 if(0 && read(afd, ab, len ab) != 2*12)
301 rerror("reading address");
302 afd = nil;
303 cfd = nil;
304 # buf = string ab;
305 ab = nil;
306 f[i].q0 = 0; # int buf;
307 f[i].q1 = 5; # int buf[12:];
308 f[i].ok = 1;
309debug(sys->sprint("q0=%d q1=%d\n", f[i].q0, f[i].q1));
310 }
311
312 # sort
313 # qsort(f, nf, FCMP);
314
315 # print
316 for(i=0; i<nf; i++){
317 if(f[i].ok)
318 {
319 if(f[i].q1 > f[i].q0)
320 fprint(stdout, "%s:#%d,#%d\n", f[i].name, f[i].q0, f[i].q1);
321 else
322 fprint(stdout, "%s:#%d\n", f[i].name, f[i].q0);
323 }
324 }
325debug("e exiting\n");
326 exit;
327}
appl/acme/acme/mail/guide+5−0
@@ -0,0 +1,5 @@
1Mail /mail/box/$user/stored
2Mail
3Mailpop3
4mkbox /mail/box/$user/new_box
5mail -'x' someaddress
appl/acme/acme/mail/mkbox.b+25−0
@@ -0,0 +1,25 @@
1implement Mkbox;
2
3include "sys.m";
4include "draw.m";
5
6sys : Sys;
7
8FD : import sys;
9
10Mkbox : module {
11 init : fn(ctxt : ref Draw->Context, argl : list of string);
12};
13
14init(nil : ref Draw->Context, argl : list of string)
15{
16 sys = load Sys Sys->PATH;
17 for (argl = tl argl; argl != nil; argl = tl argl) {
18 nm := hd argl;
19 (ok, dir) := sys->stat(nm);
20 if (ok < 0) {
21 fd := sys->create(nm, Sys->OREAD, 8r600);
22 fd = nil;
23 }
24 }
25}
appl/acme/acme/mail/mkfile+34−0
@@ -0,0 +1,34 @@
1<../../../../mkconfig
2
3BIN=$ROOT/acme/mail
4
5DIRS=\
6 src\
7
8TARG=\
9 guide\
10 readme\
11 mkbox.dis\
12
13MODULES=\
14
15SYSMODULES=\
16 sys.m\
17 draw.m\
18
19BINTARG=${TARG:%=$BIN/%}
20
21DISBIN=$ROOT/acme/mail
22
23all:V: $TARG
24
25install:V: $BINTARG
26
27$BIN/guide : guide
28 rm -f $BIN/guide && cp guide $BIN/guide
29
30$BIN/readme : readme
31 rm -f $BIN/readme && cp readme $BIN/readme
32
33<$ROOT/mkfiles/mkdis
34<$ROOT/mkfiles/mksubdirs
appl/acme/acme/mail/readme+29−0
@@ -0,0 +1,29 @@
1Mail is the single program in this directory. Its argument specifies
2the mail box to read, default /mail/box/$user/mbox.
3For example, running
4 Mail /mail/box/$user/stored
5(a line in the guide file) looks at saved mail.
6
7Mail maintains a window containing headers for all the
8messages in the mailbox and monitors the mailbox for new messages.
9Using button 3 to indicate a message number opens
10a window on that message. commands in the mailbox window are
11 Put Write the mailbox back to the file (never done automatically)
12 Mail Make a new message window ready to mail someone.
13 Takes argument names analogously to acme's New.
14 Del Exit Mail, after checking that mailbox isn't modified.
15New messages appear at the top of the window and are highlighted upon arrival.
16(The messages are numbered oldest to newest, the opposite of regular mail.)
17
18Message windows have a simple format: the first line, up to the first tab or newline,
19holds the sender or, when sending, the addressee. Edit the line to change who the
20message goes to. Message windows contain the commands
21 Reply Make a new window to compose a reply to this message
22 Delmesg Delete the message from the screen and from the mailbox
23 Del Delete the window, leaving the message in the mailbox
24 Post Send the message to the addressee
25 Save Save to the named mailbox, default/mail/box/$user/stored
26Save takes a full file name; if that name has no slashes, the file is taken
27to be in /mail/box/$user and must already exist. Use mkbox in the guide to
28create target mailboxes in /mail/box/$user.
29Reply and mail windows contain an obvious subset of the commands.
appl/acme/acme/mail/src/Mail.b+1715−0
@@ -0,0 +1,1715 @@
1implement mail;
2
3include "sys.m";
4include "draw.m";
5include "bufio.m";
6include "daytime.m";
7include "sh.m";
8
9mail : module {
10 init : fn(ctxt : ref Draw->Context, argl : list of string);
11};
12
13sys : Sys;
14bufio : Bufio;
15daytime : Daytime;
16
17OREAD, OWRITE, ORDWR, NEWFD, FORKFD, FORKENV, NEWPGRP, UTFmax : import Sys;
18FD, Dir : import sys;
19fprint, sprint, sleep, create, open, read, write, remove, stat, fstat, fwstat, fildes, pctl, pipe, dup, byte2char : import sys;
20Context : import Draw;
21EOF : import Bufio;
22Iobuf : import bufio;
23time : import daytime;
24
25DIRLEN : con 116;
26PNPROC, PNGROUP : con iota;
27False : con 0;
28True : con 1;
29EVENTSIZE : con 256;
30Runeself : con 16r80;
31OCEXEC : con 0;
32CHEXCL : con 0; # 16r20000000; # for the moment
33CHAPPEND : con 0; # 16r40000000;
34
35MAILDIR : con "/mail";
36
37Win : adt {
38 winid : int;
39 addr : ref FD;
40 body : ref Iobuf;
41 ctl : ref FD;
42 data : ref FD;
43 event : ref FD;
44 buf : array of byte;
45 bufp : int;
46 nbuf : int;
47
48 wnew : fn() : ref Win;
49 wwritebody : fn(w : self ref Win, s : string);
50 wread : fn(w : self ref Win, m : int, n : int) : string;
51 wclean : fn(w : self ref Win);
52 wname : fn(w : self ref Win, s : string);
53 wdormant : fn(w : self ref Win);
54 wevent : fn(w : self ref Win, e : ref Event);
55 wshow : fn(w : self ref Win);
56 wtagwrite : fn(w : self ref Win, s : string);
57 wwriteevent : fn(w : self ref Win, e : ref Event);
58 wslave : fn(w : self ref Win, c : chan of Event);
59 wreplace : fn(w : self ref Win, s : string, t : string);
60 wselect : fn(w : self ref Win, s : string);
61 wsetdump : fn(w : self ref Win, s : string, t : string);
62 wdel : fn(w : self ref Win, n : int) : int;
63 wreadall : fn(w : self ref Win) : string;
64
65 ctlwrite : fn(w : self ref Win, s : string);
66 getec : fn(w : self ref Win) : int;
67 geten : fn(w : self ref Win) : int;
68 geter : fn(w : self ref Win, s : array of byte) : (int, int);
69 openfile : fn(w : self ref Win, s : string) : ref FD;
70 openbody : fn(w : self ref Win, n : int);
71};
72
73Mesg : adt {
74 w : ref Win;
75 id : int;
76 hdr : string;
77 realhdr : string;
78 replyto : string;
79 text : string;
80 subj : string;
81 next : cyclic ref Mesg;
82 lline1 : int;
83 box : cyclic ref Box;
84 isopen : int;
85 posted : int;
86
87 read : fn(b : ref Box) : ref Mesg;
88 open : fn(m : self ref Mesg);
89 slave : fn(m : self ref Mesg);
90 free : fn(m : self ref Mesg);
91 save : fn(m : self ref Mesg, s : string);
92 mkreply : fn(m : self ref Mesg);
93 mkmail : fn(b : ref Box, s : string);
94 putpost : fn(m : self ref Mesg, e : ref Event);
95
96 command : fn(m : self ref Mesg, s : string) : int;
97 send : fn(m : self ref Mesg);
98};
99
100Box : adt {
101 w : ref Win;
102 nm : int;
103 readonly : int;
104 m : cyclic ref Mesg;
105 file : string;
106 io : ref Iobuf;
107 clean : int;
108 leng : big;
109 cdel : chan of ref Mesg;
110 cevent : chan of Event;
111 cmore : chan of int;
112
113 line : string;
114 peekline : string;
115
116 read : fn(s : string, n : int) : ref Box;
117 readmore : fn(b : self ref Box);
118 readline : fn(b : self ref Box) : string;
119 unreadline : fn(b : self ref Box);
120 slave : fn(b : self ref Box);
121 mopen : fn(b : self ref Box, n : int);
122 rewrite : fn(b : self ref Box);
123 mdel : fn(b : self ref Box, m : ref Mesg);
124 event : fn(b : self ref Box, e : ref Event);
125
126 command : fn(b : self ref Box, s : string) : int;
127};
128
129Event : adt {
130 c1 : int;
131 c2 : int;
132 q0 : int;
133 q1 : int;
134 flag : int;
135 nb : int;
136 nr : int;
137 b : array of byte;
138 r : array of int;
139};
140
141Lock : adt {
142 cnt : int;
143 chann : chan of int;
144
145 init : fn() : ref Lock;
146 lock : fn(l : self ref Lock);
147 unlock : fn(l : self ref Lock);
148};
149
150Ref : adt {
151 l : ref Lock;
152 cnt : int;
153
154 init : fn() : ref Ref;
155 inc : fn(r : self ref Ref) : int;
156};
157
158mbox : ref Box;
159mboxfile : string;
160usermboxfile : string;
161usermboxdir : string;
162lockfile : string;
163user : string;
164date : string;
165mailctxt : ref Context;
166stdout, stderr : ref FD;
167
168killing : int = 0;
169
170init(ctxt : ref Context, argl : list of string)
171{
172 mailctxt = ctxt;
173 sys = load Sys Sys->PATH;
174 bufio = load Bufio Bufio->PATH;
175 daytime = load Daytime Daytime->PATH;
176 stdout = fildes(1);
177 stderr = fildes(2);
178 main(argl);
179}
180
181dlock : ref Lock;
182dfd : ref Sys->FD;
183
184debug(s : string)
185{
186 if (dfd == nil) {
187 dfd = sys->create("/usr/jrf/acme/debugmail", Sys->OWRITE, 8r600);
188 dlock = Lock.init();
189 }
190 if (dfd == nil)
191 return;
192 dlock.lock();
193 sys->fprint(dfd, "%s", s);
194 dlock.unlock();
195}
196
197postnote(t : int, pid : int, note : string) : int
198{
199 fd := open("#p/" + string pid + "/ctl", OWRITE);
200 if (fd == nil)
201 return -1;
202 if (t == PNGROUP)
203 note += "grp";
204 fprint(fd, "%s", note);
205 fd = nil;
206 return 0;
207}
208
209exec(cmd : string, argl : list of string)
210{
211 file := cmd;
212 if(len file<4 || file[len file-4:]!=".dis")
213 file += ".dis";
214
215 c := load Command file;
216 if(c == nil) {
217 err := sprint("%r");
218 if(file[0]!='/' && file[0:2]!="./"){
219 c = load Command "/dis/"+file;
220 if(c == nil)
221 err = sprint("%r");
222 }
223 if(c == nil){
224 fprint(stderr, "%s: %s\n", cmd, err);
225 return;
226 }
227 }
228 c->init(mailctxt, argl);
229}
230
231swrite(fd : ref FD, s : string) : int
232{
233 ab := array of byte s;
234 m := len ab;
235 p := write(fd, ab, m);
236 if (p == m)
237 return len s;
238 if (p <= 0)
239 return p;
240 return 0;
241}
242
243strchr(s : string, c : int) : int
244{
245 for (i := 0; i < len s; i++)
246 if (s[i] == c)
247 return i;
248 return -1;
249}
250
251strrchr(s : string, c : int) : int
252{
253 for (i := len s - 1; i >= 0; i--)
254 if (s[i] == c)
255 return i;
256 return -1;
257}
258
259strtoi(s : string) : (int, int)
260{
261 m := 0;
262 neg := 0;
263 t := 0;
264 ls := len s;
265 while (t < ls && (s[t] == ' ' || s[t] == '\t'))
266 t++;
267 if (t < ls && s[t] == '+')
268 t++;
269 else if (t < ls && s[t] == '-') {
270 neg = 1;
271 t++;
272 }
273 while (t < ls && (s[t] >= '0' && s[t] <= '9')) {
274 m = 10*m + s[t]-'0';
275 t++;
276 }
277 if (neg)
278 m = -m;
279 return (m, t);
280}
281
282access(s : string) : int
283{
284 fd := open(s, 0);
285 if (fd == nil)
286 return -1;
287 fd = nil;
288 return 0;
289}
290
291newevent() : ref Event
292{
293 e := ref Event;
294 e.b = array[EVENTSIZE*UTFmax+1] of byte;
295 e.r = array[EVENTSIZE+1] of int;
296 return e;
297}
298
299newmesg() : ref Mesg
300{
301 m := ref Mesg;
302 m.id = m.lline1 = m.isopen = m.posted = 0;
303 return m;
304}
305
306lc, uc : chan of ref Lock;
307
308initlock()
309{
310 lc = chan of ref Lock;
311 uc = chan of ref Lock;
312 spawn lockmgr();
313}
314
315lockmgr()
316{
317 l : ref Lock;
318
319 for (;;) {
320 alt {
321 l = <- lc =>
322 if (l.cnt++ == 0)
323 l.chann <-= 1;
324 l = <- uc =>
325 if (--l.cnt > 0)
326 l.chann <-= 1;
327 }
328 }
329}
330
331Lock.init() : ref Lock
332{
333 return ref Lock(0, chan of int);
334}
335
336Lock.lock(l : self ref Lock)
337{
338 lc <-= l;
339 <- l.chann;
340}
341
342Lock.unlock(l : self ref Lock)
343{
344 uc <-= l;
345}
346
347Ref.init() : ref Ref
348{
349 r := ref Ref;
350 r.l = Lock.init();
351 r.cnt = 0;
352 return r;
353}
354
355Ref.inc(r : self ref Ref) : int
356{
357 r.l.lock();
358 i := r.cnt;
359 r.cnt++;
360 r.l.unlock();
361 return i;
362}
363
364error(s : string)
365{
366 if(s != nil)
367 fprint(stderr, "mail: %s\n", s);
368 rmlockfile();
369# debug(sprint("error %s\n", s));
370 postnote(PNGROUP, pctl(0, nil), "kill");
371 killing = 1;
372 exit;
373}
374
375rmlockfile()
376{
377 if (lockfile != nil) {
378 remove(lockfile);
379 lockfile = nil;
380 }
381}
382
383#
384# try opening a lock file. If it doesn't exist try creating it.
385#
386openlockfile(path : string) : ref FD
387{
388 try : int;
389 fd : ref FD;
390
391 try = 0;
392 for(;;){
393 # fd = open(path, OWRITE);
394 # if(fd!=nil || ++try>3)
395 # return fd;
396 if(++try > 3)
397 return fd;
398 (ok, d) := stat(path);
399 if(ok >= 0)
400 sleep(1000);
401 else{
402 fd = create(path, OWRITE, CHEXCL|8r666);
403 if(fd != nil){
404 (ok, d) = fstat(fd);
405 if(ok >= 0){
406 d.mode |= CHEXCL|8r666;
407 fwstat(fd, d);
408 }
409 return fd;
410 }
411 break;
412 }
413 }
414 return nil;
415}
416
417tryopen(s : string, mode : int) : ref FD
418{
419 fd : ref FD;
420 try : int;
421
422 for(try=0; try<3; try++){
423 fd = open(s, mode);
424 if(fd != nil)
425 return fd;
426 sleep(1000);
427 }
428 return nil;
429}
430
431run(argv : list of string, c : chan of int, p0 : ref FD)
432{
433 # pctl(FORKFD|NEWPGRP, nil); # had RFMEM
434 pctl(FORKENV|NEWFD|NEWPGRP, 0::1::2::p0.fd::nil);
435 c <-= pctl(0, nil);
436 dup(p0.fd, 0);
437 p0 = nil;
438 exec(hd argv, argv);
439 exit;
440}
441
442getuser() : string
443{
444 fd := open("/dev/user", OREAD);
445 if(fd == nil)
446 return "";
447 buf := array[128] of byte;
448 n := read(fd, buf, len buf);
449 if(n < 0)
450 return "";
451 return string buf[0:n];
452}
453
454main(argv : list of string)
455{
456 fd : ref FD;
457 readonly : int;
458 buf : string;
459
460 initlock();
461 initreply();
462 date = time();
463 if(date==nil)
464 error("can't get current time");
465 user = getuser();
466 if(user == nil)
467 user = "Wile.E.Coyote";
468 usermboxdir = MAILDIR + "/box/" + user + "/";
469 usermboxfile = MAILDIR + "/box/" + user + "/mbox";
470 if(len argv > 1)
471 mboxfile = hd tl argv;
472 else
473 mboxfile = usermboxfile;
474
475 fd = nil;
476 readonly = False;
477 if(mboxfile == usermboxfile){
478 buf = MAILDIR + "/box/" + user + "/L.reading";
479 fd = openlockfile(buf);
480 if(fd == nil){
481 fprint(stderr, "Mail: %s in use; opened read-only\n", mboxfile);
482 readonly = True;
483 }
484 else
485 lockfile = buf;
486 }
487 mbox = mbox.read(mboxfile, readonly);
488 spawn timeslave(fd, mbox, mbox.cmore);
489 mbox.slave();
490 error(nil);
491}
492
493timeslave(rlock : ref FD, b : ref Box, c : chan of int)
494{
495 buf := array[DIRLEN] of byte;
496 for(;;){
497 sleep(30*1000);
498 if(rlock != nil && write(rlock, buf, 0)<0)
499 error("can't maintain L.reading: %r");
500 (ok, d) := stat(mboxfile);
501 if (ok >= 0 && d.length > b.leng)
502 c <-= 0;
503 }
504}
505
506Win.wnew() : ref Win
507{
508 w := ref Win;
509 buf := array[12] of byte;
510 w.ctl = open("/chan/new/ctl", ORDWR);
511 if(w.ctl==nil || read(w.ctl, buf, 12)!=12)
512 error("can't open window ctl file: %r");
513 w.ctlwrite("noscroll\n");
514 w.winid = int string buf;
515 w.event = w.openfile("event");
516 w.addr = nil; # will be opened when needed
517 w.body = nil;
518 w.data = nil;
519 w.bufp = w.nbuf = 0;
520 w.buf = array[512] of byte;
521 return w;
522}
523
524Win.openfile(w : self ref Win, f : string) : ref FD
525{
526 buf := sprint("/chan/%d/%s", w.winid, f);
527 fd := open(buf, ORDWR|OCEXEC);
528 if(fd == nil)
529 error(sprint("can't open window %s file: %r", f));
530 return fd;
531}
532
533Win.openbody(w : self ref Win, mode : int)
534{
535 buf := sprint("/chan/%d/body", w.winid);
536 w.body = bufio->open(buf, mode|OCEXEC);
537 if(w.body == nil)
538 error("can't open window body file: %r");
539}
540
541Win.wwritebody(w : self ref Win, s : string)
542{
543 n := len s;
544 if(w.body == nil)
545 w.openbody(OWRITE);
546 if(w.body.puts(s) != n)
547 error("write error to window: %r");
548}
549
550Win.wreplace(w : self ref Win, addr : string, repl : string)
551{
552 if(w.addr == nil)
553 w.addr = w.openfile("addr");
554 if(w.data == nil)
555 w.data = w.openfile("data");
556 if(swrite(w.addr, addr) < 0){
557 fprint(stderr, "mail: warning: bad address %s:%r\n", addr);
558 return;
559 }
560 if(swrite(w.data, repl) != len repl)
561 error("writing data: %r");
562}
563
564nrunes(s : array of byte, nb : int) : int
565{
566 i, n : int;
567
568 n = 0;
569 for(i=0; i<nb; n++) {
570 (r, b, ok) := byte2char(s, i);
571 if (!ok)
572 error("help needed in nrunes()");
573 i += b;
574 }
575 return n;
576}
577
578Win.wread(w : self ref Win, q0 : int, q1 : int) : string
579{
580 m, n, nr : int;
581 s, buf : string;
582 b : array of byte;
583
584 b = array[256] of byte;
585 if(w.addr == nil)
586 w.addr = w.openfile("addr");
587 if(w.data == nil)
588 w.data = w.openfile("data");
589 s = nil;
590 m = q0;
591 while(m < q1){
592 buf = sprint("#%d", m);
593 if(swrite(w.addr, buf) != len buf)
594 error("writing addr: %r");
595 n = read(w.data, b, len b);
596 if(n <= 0)
597 error("reading data: %r");
598 nr = nrunes(b, n);
599 while(m+nr >q1){
600 do; while(n>0 && (int b[--n]&16rC0)==16r80);
601 --nr;
602 }
603 if(n == 0)
604 break;
605 s += string b[0:n];
606 m += nr;
607 }
608 return s;
609}
610
611Win.wshow(w : self ref Win)
612{
613 w.ctlwrite("show\n");
614}
615
616Win.wsetdump(w : self ref Win, dir : string, cmd : string)
617{
618 t : string;
619
620 if(dir != nil){
621 t = "dumpdir " + dir + "\n";
622 w.ctlwrite(t);
623 t = nil;
624 }
625 if(cmd != nil){
626 t = "dump " + cmd + "\n";
627 w.ctlwrite(t);
628 t = nil;
629 }
630}
631
632Win.wselect(w : self ref Win, addr : string)
633{
634 if(w.addr == nil)
635 w.addr = w.openfile("addr");
636 if(swrite(w.addr, addr) < 0)
637 error("writing addr");
638 w.ctlwrite("dot=addr\n");
639}
640
641Win.wtagwrite(w : self ref Win, s : string)
642{
643 fd : ref FD;
644
645 fd = w.openfile("tag");
646 if(swrite(fd, s) != len s)
647 error("tag write: %r");
648 fd = nil;
649}
650
651Win.ctlwrite(w : self ref Win, s : string)
652{
653 if(swrite(w.ctl, s) != len s)
654 error("write error to ctl file: %r");
655}
656
657Win.wdel(w : self ref Win, sure : int) : int
658{
659 if (w == nil)
660 return False;
661 if(sure)
662 swrite(w.ctl, "delete\n");
663 else if(swrite(w.ctl, "del\n") != 4)
664 return False;
665 w.wdormant();
666 w.ctl = nil;
667 w.event = nil;
668 return True;
669}
670
671Win.wname(w : self ref Win, s : string)
672{
673 w.ctlwrite("name " + s + "\n");
674}
675
676Win.wclean(w : self ref Win)
677{
678 if(w.body != nil)
679 w.body.flush();
680 w.ctlwrite("clean\n");
681}
682
683Win.wdormant(w : self ref Win)
684{
685 w.addr = nil;
686 if(w.body != nil){
687 w.body.close();
688 w.body = nil;
689 }
690 w.data = nil;
691}
692
693Win.getec(w : self ref Win) : int
694{
695 if(w.nbuf == 0){
696 w.nbuf = read(w.event, w.buf, len w.buf);
697 if(w.nbuf <= 0 && !killing) {
698 error("event read error: %r");
699 }
700 w.bufp = 0;
701 }
702 w.nbuf--;
703 return int w.buf[w.bufp++];
704}
705
706Win.geten(w : self ref Win) : int
707{
708 n, c : int;
709
710 n = 0;
711 while('0'<=(c=w.getec()) && c<='9')
712 n = n*10+(c-'0');
713 if(c != ' ')
714 error("event number syntax");
715 return n;
716}
717
718Win.geter(w : self ref Win, buf : array of byte) : (int, int)
719{
720 r, m, n, ok : int;
721
722 r = w.getec();
723 buf[0] = byte r;
724 n = 1;
725 if(r >= Runeself) {
726 for (;;) {
727 (r, m, ok) = byte2char(buf[0:n], 0);
728 if (m > 0)
729 return (r, n);
730 buf[n++] = byte w.getec();
731 }
732 }
733 return (r, n);
734}
735
736Win.wevent(w : self ref Win, e : ref Event)
737{
738 i, nb : int;
739
740 e.c1 = w.getec();
741 e.c2 = w.getec();
742 e.q0 = w.geten();
743 e.q1 = w.geten();
744 e.flag = w.geten();
745 e.nr = w.geten();
746 if(e.nr > EVENTSIZE)
747 error("event string too long");
748 e.nb = 0;
749 for(i=0; i<e.nr; i++){
750 (e.r[i], nb) = w.geter(e.b[e.nb:]);
751 e.nb += nb;
752 }
753 e.r[e.nr] = 0;
754 e.b[e.nb] = byte 0;
755 c := w.getec();
756 if(c != '\n')
757 error("event syntax 2");
758}
759
760Win.wslave(w : self ref Win, ce : chan of Event)
761{
762 e : ref Event;
763
764 e = newevent();
765 for(;;){
766 w.wevent(e);
767 ce <-= *e;
768 }
769}
770
771Win.wwriteevent(w : self ref Win, e : ref Event)
772{
773 fprint(w.event, "%c%c%d %d\n", e.c1, e.c2, e.q0, e.q1);
774}
775
776Win.wreadall(w : self ref Win) : string
777{
778 s, t : string;
779
780 if(w.body != nil)
781 w.body.close();
782 w.openbody(OREAD);
783 s = nil;
784 while ((t = w.body.gets('\n')) != nil)
785 s += t;
786 w.body.close();
787 w.body = nil;
788 return s;
789}
790
791ignored : int;
792
793None,Unknown,Ignore,CC,From,ReplyTo,Sender,Subject,Re,To, Date : con iota;
794NHeaders : con 200;
795
796Hdrs : adt {
797 name : string;
798 typex : int;
799};
800
801
802hdrs := array[NHeaders+1] of {
803 Hdrs ( "CC:", CC ),
804 Hdrs ( "From:", From ),
805 Hdrs ( "Reply-To:", ReplyTo ),
806 Hdrs ( "Sender:", Sender ),
807 Hdrs ( "Subject:", Subject ),
808 Hdrs ( "Re:", Re ),
809 Hdrs ( "To:", To ),
810 Hdrs ( "Date:", Date),
811 * => Hdrs ( "", 0 ),
812};
813
814StRnCmP(s : string, t : string, n : int) : int
815{
816 c, d, i, j : int;
817
818 i = j = 0;
819 if (len s < n || len t < n)
820 return -1;
821 while(n > 0){
822 c = s[i++];
823 d = t[j++];
824 --n;
825 if(c != d){
826 if('a'<=c && c<='z')
827 c -= 'a'-'A';
828 if('a'<=d && d<='z')
829 d -= 'a'-'A';
830 if(c != d)
831 return c-d;
832 }
833 }
834 return 0;
835}
836
837ignore()
838{
839 b : ref Iobuf;
840 s : string;
841 i : int;
842
843 ignored = True;
844 b = bufio->open(MAILDIR + "/lib/ignore", OREAD);
845 if(b == nil)
846 return;
847 for(i=0; hdrs[i].name != nil; i++)
848 ;
849 while((s = b.gets('\n')) != nil){
850 s = s[0:len s - 1];
851 hdrs[i].name = s;
852 hdrs[i].typex = Ignore;
853 if(++i >= NHeaders){
854 fprint(stderr, "%s/lib/ignore has more than %d headers\n", MAILDIR, NHeaders);
855 break;
856 }
857 }
858 b.close();
859}
860
861readhdr(b : ref Box) : (string, int)
862{
863 i, j, n, m, typex : int;
864 s, t : string;
865
866 {
867 if(!ignored)
868 ignore();
869 s = b.readline();
870 n = len s;
871 if(n <= 0)
872 raise("e");
873 for(i=0; i<n; i++){
874 j = s[i];
875 if(i>0 && j == ':')
876 break;
877 if(j<'!' || '~'<j){
878 b.unreadline();
879 raise("e");
880 }
881 }
882 typex = Unknown;
883 for(i=0; hdrs[i].name != nil; i++){
884 j = len hdrs[i].name;
885 if(StRnCmP(hdrs[i].name, s, j) == 0){
886 typex = hdrs[i].typex;
887 break;
888 }
889 }
890 # scan for multiple sublines
891 for(;;){
892 t = b.readline();
893 m = len t;
894 if(m<=0 || (t[0]!=' ' && t[0]!='\t')){
895 b.unreadline();
896 break;
897 }
898 # absorb
899 s += t;
900 }
901 return(s, typex);
902 }
903 exception{
904 "*" =>
905 return (nil, None);
906 }
907}
908
909Mesg.read(b : ref Box) : ref Mesg
910{
911 m : ref Mesg;
912 s : string;
913 n, typex : int;
914
915 s = b.readline();
916 n = len s;
917 if(n <= 0)
918 return nil;
919
920{
921 if(n < 5 || s[0:5] !="From ")
922 raise("e");
923 m = newmesg();
924 m.realhdr = s;
925 # toss 'From '
926 s = s[5:];
927 n -= 5;
928 # toss spaces/tabs
929 while (n > 0 && (s[0] == ' ' || s[0] == '\t')) {
930 s = s[1:];
931 n--;
932 }
933 m.hdr = s;
934 # convert first blank to tab
935 s0 := strchr(m.hdr, ' ');
936 if(s0 >= 0){
937 m.hdr[s0] = '\t';
938 # drop trailing seconds, time zone, and year if match local year
939 t := n-6;
940 if(t <= 0)
941 raise("e");
942 if(m.hdr[t:n-1] == date[23:]){
943 m.hdr = m.hdr[0:t] + "\n"; # drop year for sure
944 t = -1;
945 s1 := strchr(m.hdr[s0:], ':');
946 if(s1 >= 0)
947 t = strchr(m.hdr[s0+s1+1:], ':');
948 if(t >= 0) # drop seconds and time zone
949 m.hdr = m.hdr[0:s0+s1+t+1] + "\n";
950 else{ # drop time zone
951 t = strchr(m.hdr[s0+s1+1:], ' ');
952 if(t >= 0)
953 m.hdr = m.hdr[0:s0+s1+t+1] + "\n";
954 }
955 n = len m.hdr;
956 }
957 }
958 m.lline1 = n;
959 m.text = nil;
960 # read header
961loop:
962 for(;;){
963 (s, typex) = readhdr(b);
964 case(typex){
965 None =>
966 break loop;
967 ReplyTo =>
968 m.replyto = s[9:];
969 break;
970 From =>
971 if(m.replyto == nil)
972 m.replyto = s[5:];
973 break;
974 Subject =>
975 m.subj = s[8:];
976 break;
977 Re =>
978 m.subj = s[3:];
979 break;
980 Date =>
981 break;
982 }
983 m.realhdr += s;
984 if(typex != Ignore)
985 m.hdr += s;
986 }
987 # read body
988 for(;;){
989 s = b.readline();
990 n = len s;
991 if(n <= 0)
992 break;
993 if(len s >= 5 && s[0:5] == "From "){
994 b.unreadline();
995 break;
996 }
997 m.text += s;
998 }
999 # remove trailing "morF\n"
1000 l := len m.text;
1001 if(l>6 && m.text[l-6:] == "\nmorF\n")
1002 m.text = m.text[0:l-5];
1003 m.box = b;
1004 return m;
1005}
1006exception{
1007 "*" =>
1008 error("malformed header " + s);
1009 return nil;
1010}
1011}
1012
1013Mesg.mkmail(b : ref Box, hdr : string)
1014{
1015 r : ref Mesg;
1016
1017 r = newmesg();
1018 r.hdr = hdr + "\n";
1019 r.lline1 = len r.hdr;
1020 r.text = nil;
1021 r.box = b;
1022 r.open();
1023 r.w.wdormant();
1024}
1025
1026replyaddr(r : string) : string
1027{
1028 p, q, rr : int;
1029
1030 rr = 0;
1031 while(r[rr]==' ' || r[rr]=='\t')
1032 rr++;
1033 r = r[rr:];
1034 p = strchr(r, '<');
1035 if(p >= 0){
1036 q = strchr(r[p+1:], '>');
1037 if(q < 0)
1038 r = r[p+1:];
1039 else
1040 r = r[p+1:p+q] + "\n";
1041 return r;
1042 }
1043 p = strchr(r, '(');
1044 if(p >= 0){
1045 q = strchr(r[p:], ')');
1046 if(q < 0)
1047 r = r[0:p];
1048 else
1049 r = r[0:p] + r[p+q+1:];
1050 }
1051 return r;

664 more lines aren’t shown here.

appl/acme/acme/mail/src/Mailp.b+1684−0

This diff is large: its 1685 lines aren’t shown here.

appl/acme/acme/mail/src/Mailpop3.b+1720−0

This diff is large: its 1721 lines aren’t shown here.

appl/acme/acme/mail/src/mashfile+18−0

This diff is large: its 19 lines aren’t shown here.

appl/acme/acme/mail/src/mkfile+16−0

This diff is large: its 17 lines aren’t shown here.

appl/acme/acme/mkfile+9−0

This diff is large: its 10 lines aren’t shown here.

appl/acme/buff.b+380−0

This diff is large: its 381 lines aren’t shown here.

appl/acme/buff.m+34−0

This diff is large: its 35 lines aren’t shown here.

appl/acme/col.b+610−0

This diff is large: its 611 lines aren’t shown here.

appl/acme/col.m+26−0

This diff is large: its 27 lines aren’t shown here.

appl/acme/common.m+30−0

This diff is large: its 31 lines aren’t shown here.

appl/acme/dat.b+107−0

This diff is large: its 108 lines aren’t shown here.

appl/acme/dat.m+280−0

This diff is large: its 281 lines aren’t shown here.

appl/acme/disk.b+136−0

This diff is large: its 137 lines aren’t shown here.

appl/acme/disk.m+19−0

This diff is large: its 20 lines aren’t shown here.

appl/acme/ecmd.b+1350−0

This diff is large: its 1351 lines aren’t shown here.

appl/acme/ecmd.m+18−0

This diff is large: its 19 lines aren’t shown here.

appl/acme/edit.b+676−0

This diff is large: its 677 lines aren’t shown here.

appl/acme/edit.m+85−0

This diff is large: its 86 lines aren’t shown here.

appl/acme/elog.b+353−0

This diff is large: its 354 lines aren’t shown here.

appl/acme/elog.m+24−0

This diff is large: its 25 lines aren’t shown here.

appl/acme/exec.b+1350−0

This diff is large: its 1351 lines aren’t shown here.

appl/acme/exec.m+19−0

This diff is large: its 20 lines aren’t shown here.

appl/acme/file.b+331−0

This diff is large: its 332 lines aren’t shown here.

appl/acme/file.m+40−0

This diff is large: its 41 lines aren’t shown here.

appl/acme/frame.b+1189−0

This diff is large: its 1190 lines aren’t shown here.

appl/acme/frame.m+54−0

This diff is large: its 55 lines aren’t shown here.

appl/acme/fsys.b+866−0

This diff is large: its 867 lines aren’t shown here.

appl/acme/fsys.m+18−0

This diff is large: its 19 lines aren’t shown here.

appl/acme/graph.b+82−0

This diff is large: its 83 lines aren’t shown here.

appl/acme/graph.m+18−0

This diff is large: its 19 lines aren’t shown here.

appl/acme/gui.b+126−0

This diff is large: its 127 lines aren’t shown here.

appl/acme/gui.m+15−0

This diff is large: its 16 lines aren’t shown here.

appl/acme/look.b+743−0

This diff is large: its 744 lines aren’t shown here.

appl/acme/look.m+17−0

This diff is large: its 18 lines aren’t shown here.

appl/acme/mkfile+90−0

This diff is large: its 91 lines aren’t shown here.

appl/acme/regx.b+1050−0

This diff is large: its 1051 lines aren’t shown here.

appl/acme/regx.m+13−0

This diff is large: its 14 lines aren’t shown here.

appl/acme/row.b+767−0

This diff is large: its 768 lines aren’t shown here.

appl/acme/row.m+29−0

This diff is large: its 30 lines aren’t shown here.

appl/acme/scrl.b+187−0

This diff is large: its 188 lines aren’t shown here.

appl/acme/scrl.m+9−0

This diff is large: its 10 lines aren’t shown here.

appl/acme/styxaux.b+174−0

This diff is large: its 175 lines aren’t shown here.

appl/acme/styxaux.m+24−0

This diff is large: its 25 lines aren’t shown here.

appl/acme/text.b+1404−0

This diff is large: its 1405 lines aren’t shown here.

appl/acme/text.m+65−0

This diff is large: its 66 lines aren’t shown here.

appl/acme/time.b+129−0

This diff is large: its 130 lines aren’t shown here.

appl/acme/time.m+10−0

This diff is large: its 11 lines aren’t shown here.

appl/acme/util.b+574−0

This diff is large: its 575 lines aren’t shown here.

appl/acme/util.m+52−0

This diff is large: its 53 lines aren’t shown here.

appl/acme/wind.b+558−0

This diff is large: its 559 lines aren’t shown here.

appl/acme/wind.m+67−0

This diff is large: its 68 lines aren’t shown here.

appl/acme/xfid.b+1087−0

This diff is large: its 1088 lines aren’t shown here.

appl/acme/xfid.m+34−0

This diff is large: its 35 lines aren’t shown here.

appl/alphabet/abc/abc.b+53−0

This diff is large: its 54 lines aren’t shown here.

appl/alphabet/abc/autoconvert.b+80−0

This diff is large: its 81 lines aren’t shown here.

appl/alphabet/abc/autodeclare.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/alphabet/abc/declare.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/alphabet/abc/declares.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/alphabet/abc/define.b+52−0

This diff is large: its 53 lines aren’t shown here.

appl/alphabet/abc/eval.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/alphabet/abc/import.b+53−0

This diff is large: its 54 lines aren’t shown here.

appl/alphabet/abc/mkfile+29−0

This diff is large: its 30 lines aren’t shown here.

appl/alphabet/abc/newtypeset.b+147−0

This diff is large: its 148 lines aren’t shown here.

appl/alphabet/abc/rewrite.b+71−0

This diff is large: its 72 lines aren’t shown here.

appl/alphabet/abc/type.b+53−0

This diff is large: its 54 lines aren’t shown here.

appl/alphabet/abc/typeset.b+51−0

This diff is large: its 52 lines aren’t shown here.

appl/alphabet/abc/undeclare.b+48−0

This diff is large: its 49 lines aren’t shown here.

appl/alphabet/alphabet.b+1677−0

This diff is large: its 1678 lines aren’t shown here.

appl/alphabet/alphabet.proto+29−0

This diff is large: its 30 lines aren’t shown here.

appl/alphabet/alphabet.shmod.b+413−0

This diff is large: its 414 lines aren’t shown here.

appl/alphabet/auxi/endpoints.b+105−0

This diff is large: its 106 lines aren’t shown here.

appl/alphabet/auxi/endpointsrv.b+58−0

This diff is large: its 59 lines aren’t shown here.

appl/alphabet/auxi/fsfilter.b+62−0

This diff is large: its 63 lines aren’t shown here.

appl/alphabet/auxi/mkfile+21−0

This diff is large: its 22 lines aren’t shown here.

appl/alphabet/auxi/rexecsrv.b+301−0

This diff is large: its 302 lines aren’t shown here.

appl/alphabet/declare.sh+25−0

This diff is large: its 26 lines aren’t shown here.

appl/alphabet/eval.b+757−0

This diff is large: its 758 lines aren’t shown here.

appl/alphabet/extvalues.b+49−0

This diff is large: its 50 lines aren’t shown here.

appl/alphabet/fs/and.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/alphabet/fs/bundle.b+210−0

This diff is large: its 211 lines aren’t shown here.

appl/alphabet/fs/bundle.m+9−0

This diff is large: its 10 lines aren’t shown here.

appl/alphabet/fs/chstat.b+189−0

This diff is large: its 190 lines aren’t shown here.

appl/alphabet/fs/compose.b+105−0

This diff is large: its 106 lines aren’t shown here.

appl/alphabet/fs/depth.b+54−0

This diff is large: its 55 lines aren’t shown here.

appl/alphabet/fs/entries.b+91−0

This diff is large: its 92 lines aren’t shown here.

appl/alphabet/fs/exec.b+172−0

This diff is large: its 173 lines aren’t shown here.

appl/alphabet/fs/filter.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/alphabet/fs/ls.b+107−0

This diff is large: its 108 lines aren’t shown here.

appl/alphabet/fs/match.b+84−0

This diff is large: its 85 lines aren’t shown here.

appl/alphabet/fs/merge.b+192−0

This diff is large: its 193 lines aren’t shown here.

appl/alphabet/fs/mergewrite.b+244−0

This diff is large: its 245 lines aren’t shown here.

appl/alphabet/fs/mkext.b+266−0

This diff is large: its 267 lines aren’t shown here.

appl/alphabet/fs/mkfile+55−0

This diff is large: its 56 lines aren’t shown here.

appl/alphabet/fs/mode.b+125−0

This diff is large: its 126 lines aren’t shown here.

appl/alphabet/fs/newer.b+64−0

This diff is large: its 65 lines aren’t shown here.

appl/alphabet/fs/not.b+53−0

This diff is large: its 54 lines aren’t shown here.

appl/alphabet/fs/or.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/alphabet/fs/path.b+82−0

This diff is large: its 83 lines aren’t shown here.

appl/alphabet/fs/pipe.b+230−0

This diff is large: its 231 lines aren’t shown here.

appl/alphabet/fs/print.b+61−0

This diff is large: its 62 lines aren’t shown here.

appl/alphabet/fs/proto.b+416−0

This diff is large: its 417 lines aren’t shown here.

appl/alphabet/fs/query.b+135−0

This diff is large: its 136 lines aren’t shown here.

appl/alphabet/fs/run.b+65−0

This diff is large: its 66 lines aren’t shown here.

appl/alphabet/fs/select.b+60−0

This diff is large: its 61 lines aren’t shown here.

appl/alphabet/fs/setroot.b+109−0

This diff is large: its 110 lines aren’t shown here.

appl/alphabet/fs/size.b+64−0

This diff is large: its 65 lines aren’t shown here.

appl/alphabet/fs/unbundle.b+259−0

This diff is large: its 260 lines aren’t shown here.

appl/alphabet/fs/unbundle.m+9−0

This diff is large: its 10 lines aren’t shown here.

appl/alphabet/fs/walk.b+242−0

This diff is large: its 243 lines aren’t shown here.

appl/alphabet/fs/write.b+137−0

This diff is large: its 138 lines aren’t shown here.

appl/alphabet/fsdecl.sh+13−0

This diff is large: its 14 lines aren’t shown here.

appl/alphabet/getendpoint.sh+13−0

This diff is large: its 14 lines aren’t shown here.

appl/alphabet/grid/farm.b+144−0

This diff is large: its 145 lines aren’t shown here.

appl/alphabet/grid/line2rec.b+91−0

This diff is large: its 92 lines aren’t shown here.

appl/alphabet/grid/local.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/alphabet/grid/mkfile+22−0

This diff is large: its 23 lines aren’t shown here.

appl/alphabet/grid/remote.b+88−0

This diff is large: its 89 lines aren’t shown here.

appl/alphabet/grid/rexec.b+112−0

This diff is large: its 113 lines aren’t shown here.

appl/alphabet/main/auth.b+157−0

This diff is large: its 158 lines aren’t shown here.

appl/alphabet/main/cat.b+78−0

This diff is large: its 79 lines aren’t shown here.

appl/alphabet/main/create.b+55−0

This diff is large: its 56 lines aren’t shown here.

appl/alphabet/main/dial.b+85−0

This diff is large: its 86 lines aren’t shown here.

appl/alphabet/main/echo.b+51−0

This diff is large: its 52 lines aren’t shown here.

appl/alphabet/main/export.b+52−0

This diff is large: its 53 lines aren’t shown here.

appl/alphabet/main/fd.b+83−0

This diff is large: its 84 lines aren’t shown here.

appl/alphabet/main/filter.b+114−0

This diff is large: its 115 lines aren’t shown here.

appl/alphabet/main/genfilter.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/alphabet/main/mkfile+36−0

This diff is large: its 37 lines aren’t shown here.

appl/alphabet/main/mount.b+80−0

This diff is large: its 81 lines aren’t shown here.

appl/alphabet/main/par.b+50−0

This diff is large: its 51 lines aren’t shown here.

appl/alphabet/main/parse.b+43−0

This diff is large: its 44 lines aren’t shown here.

appl/alphabet/main/pretty.b+116−0

This diff is large: its 117 lines aren’t shown here.

appl/alphabet/main/print.b+55−0

This diff is large: its 56 lines aren’t shown here.

appl/alphabet/main/read.b+56−0

This diff is large: its 57 lines aren’t shown here.

appl/alphabet/main/readall.b+46−0

This diff is large: its 47 lines aren’t shown here.

appl/alphabet/main/rewrite.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/alphabet/main/rw.b+50−0

This diff is large: its 51 lines aren’t shown here.

appl/alphabet/main/seq.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/alphabet/main/unparse.b+38−0

This diff is large: its 39 lines aren’t shown here.

appl/alphabet/main/w2fd.b+61−0

This diff is large: its 62 lines aren’t shown here.

appl/alphabet/main/wait.b+35−0

This diff is large: its 36 lines aren’t shown here.

appl/alphabet/mkendpoint.sh+14−0

This diff is large: its 15 lines aren’t shown here.

appl/alphabet/mkfile+49−0

This diff is large: its 50 lines aren’t shown here.

appl/alphabet/newtypesets+229−0

This diff is large: its 230 lines aren’t shown here.

appl/alphabet/proxy.b+304−0

This diff is large: its 305 lines aren’t shown here.

appl/alphabet/reports.b+189−0

This diff is large: its 190 lines aren’t shown here.

appl/alphabet/rexecsrv.sh+9−0

This diff is large: its 10 lines aren’t shown here.

appl/alphabet/setup+63−0

This diff is large: its 64 lines aren’t shown here.

appl/alphabet/typesets/abc.b+180−0

This diff is large: its 181 lines aren’t shown here.

appl/alphabet/typesets/abctypes.b+229−0

This diff is large: its 230 lines aren’t shown here.

appl/alphabet/typesets/fs.b+226−0

This diff is large: its 227 lines aren’t shown here.

appl/alphabet/typesets/fstypes.b+230−0

This diff is large: its 231 lines aren’t shown here.

appl/alphabet/typesets/grid.b+160−0

This diff is large: its 161 lines aren’t shown here.

appl/alphabet/typesets/gridtypes.b+230−0

This diff is large: its 231 lines aren’t shown here.

appl/alphabet/typesets/mkfile+34−0

This diff is large: its 35 lines aren’t shown here.

appl/charon/build.b+2864−0

This diff is large: its 2865 lines aren’t shown here.

appl/charon/build.m+478−0

This diff is large: its 479 lines aren’t shown here.

appl/charon/charon.b+2171−0

This diff is large: its 2172 lines aren’t shown here.

appl/charon/charon.m+20−0

This diff is large: its 21 lines aren’t shown here.

appl/charon/chutils.b+2045−0

This diff is large: its 2046 lines aren’t shown here.

appl/charon/chutils.m+370−0

This diff is large: its 371 lines aren’t shown here.

appl/charon/common.m+23−0

This diff is large: its 24 lines aren’t shown here.

appl/charon/cookiesrv.b+595−0

This diff is large: its 596 lines aren’t shown here.

appl/charon/cookiesrv.m+12−0

This diff is large: its 13 lines aren’t shown here.

appl/charon/ctype.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/charon/ctype.m+24−0

This diff is large: its 25 lines aren’t shown here.

appl/charon/date.b+62−0

This diff is large: its 63 lines aren’t shown here.

appl/charon/date.m+12−0

This diff is large: its 13 lines aren’t shown here.

appl/charon/event.b+273−0

This diff is large: its 274 lines aren’t shown here.

appl/charon/event.m+100−0

This diff is large: its 101 lines aren’t shown here.

appl/charon/file.b+134−0

This diff is large: its 135 lines aren’t shown here.

appl/charon/ftp.b+314−0

This diff is large: its 315 lines aren’t shown here.

appl/charon/gui.b+560−0

This diff is large: its 561 lines aren’t shown here.

appl/charon/gui.m+48−0

This diff is large: its 49 lines aren’t shown here.

appl/charon/http.b+1040−0

This diff is large: its 1041 lines aren’t shown here.

appl/charon/img.b+3607−0

This diff is large: its 3608 lines aren’t shown here.

appl/charon/img.m+115−0

This diff is large: its 116 lines aren’t shown here.

appl/charon/jscript.b+3025−0

This diff is large: its 3026 lines aren’t shown here.

appl/charon/layout.b+4832−0

This diff is large: its 4833 lines aren’t shown here.

appl/charon/layout.m+235−0

This diff is large: its 236 lines aren’t shown here.

appl/charon/lex.b+1340−0

This diff is large: its 1341 lines aren’t shown here.

appl/charon/lex.m+105−0

This diff is large: its 106 lines aren’t shown here.

appl/charon/mkfile+92−0

This diff is large: its 93 lines aren’t shown here.

appl/charon/paginate.b+511−0

This diff is large: its 512 lines aren’t shown here.

appl/charon/paginate.m+16−0

This diff is large: its 17 lines aren’t shown here.

appl/charon/rgb.inc+620−0

This diff is large: its 621 lines aren’t shown here.

appl/charon/script.m+14−0

This diff is large: its 15 lines aren’t shown here.

appl/charon/transport.m+13−0

This diff is large: its 14 lines aren’t shown here.

appl/charon/url.b+225−0

This diff is large: its 226 lines aren’t shown here.

appl/charon/url.m+30−0

This diff is large: its 31 lines aren’t shown here.

appl/charon/xxx.inc+75−0

This diff is large: its 76 lines aren’t shown here.

appl/charon/ycbcr.inc+621−0

This diff is large: its 622 lines aren’t shown here.

appl/cmd/9660srv.b+1504−0

This diff is large: its 1505 lines aren’t shown here.

appl/cmd/9export.b+165−0

This diff is large: its 166 lines aren’t shown here.

appl/cmd/9srvfs.b+99−0

This diff is large: its 100 lines aren’t shown here.

appl/cmd/9win.b+453−0

This diff is large: its 454 lines aren’t shown here.

appl/cmd/B.b+107−0

This diff is large: its 108 lines aren’t shown here.

appl/cmd/ar.b+857−0

This diff is large: its 858 lines aren’t shown here.

appl/cmd/archfs.b+630−0

This diff is large: its 631 lines aren’t shown here.

appl/cmd/auplay.b+114−0

This diff is large: its 115 lines aren’t shown here.

appl/cmd/auth/aescbc.b+240−0

This diff is large: its 241 lines aren’t shown here.

appl/cmd/auth/ai2key.b+144−0

This diff is large: its 145 lines aren’t shown here.

appl/cmd/auth/changelogin.b+304−0

This diff is large: its 305 lines aren’t shown here.

appl/cmd/auth/convpasswd.b+120−0

This diff is large: its 121 lines aren’t shown here.

appl/cmd/auth/countersigner.b+64−0

This diff is large: its 65 lines aren’t shown here.

appl/cmd/auth/createsignerkey.b+144−0

This diff is large: its 145 lines aren’t shown here.

appl/cmd/auth/dsagen.b+62−0

This diff is large: its 63 lines aren’t shown here.

appl/cmd/auth/factotum/authio.m+85−0

This diff is large: its 86 lines aren’t shown here.

appl/cmd/auth/factotum/factotum.b+1066−0

This diff is large: its 1067 lines aren’t shown here.

appl/cmd/auth/factotum/feedkey.b+321−0

This diff is large: its 322 lines aren’t shown here.

appl/cmd/auth/factotum/mkfile+27−0

This diff is large: its 28 lines aren’t shown here.

appl/cmd/auth/factotum/proto/authquery.b+204−0

This diff is large: its 205 lines aren’t shown here.

appl/cmd/auth/factotum/proto/infauth.b+431−0

This diff is large: its 432 lines aren’t shown here.

appl/cmd/auth/factotum/proto/keyreps.b+173−0

This diff is large: its 174 lines aren’t shown here.

appl/cmd/auth/factotum/proto/keyreps.m+23−0

This diff is large: its 24 lines aren’t shown here.

appl/cmd/auth/factotum/proto/mkfile+24−0

This diff is large: its 25 lines aren’t shown here.

appl/cmd/auth/factotum/proto/p9any.b+237−0

This diff is large: its 238 lines aren’t shown here.

appl/cmd/auth/factotum/proto/pass.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/cmd/auth/factotum/proto/rsa.b+126−0

This diff is large: its 127 lines aren’t shown here.

appl/cmd/auth/factotum/rpc.b+68−0

This diff is large: its 69 lines aren’t shown here.

appl/cmd/auth/getpk.b+83−0

This diff is large: its 84 lines aren’t shown here.

appl/cmd/auth/keyfs.b+806−0

This diff is large: its 807 lines aren’t shown here.

appl/cmd/auth/keysrv.b+199−0

This diff is large: its 200 lines aren’t shown here.

appl/cmd/auth/logind.b+244−0

This diff is large: its 245 lines aren’t shown here.

appl/cmd/auth/mkauthinfo.b+125−0

This diff is large: its 126 lines aren’t shown here.

appl/cmd/auth/mkfile+39−0

This diff is large: its 40 lines aren’t shown here.

appl/cmd/auth/passwd.b+290−0

This diff is large: its 291 lines aren’t shown here.

appl/cmd/auth/rsagen.b+76−0

This diff is large: its 77 lines aren’t shown here.

appl/cmd/auth/secstore.b+332−0

This diff is large: its 333 lines aren’t shown here.

appl/cmd/auth/signer.b+132−0

This diff is large: its 133 lines aren’t shown here.

appl/cmd/auth/verify.b+85−0

This diff is large: its 86 lines aren’t shown here.

appl/cmd/auxi/cpuslave.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/cmd/auxi/digest.b+91−0

This diff is large: its 92 lines aren’t shown here.

appl/cmd/auxi/fpgaload.b+67−0

This diff is large: its 68 lines aren’t shown here.

appl/cmd/auxi/mangaload.b+350−0

This diff is large: its 351 lines aren’t shown here.

appl/cmd/auxi/mkfile+24−0

This diff is large: its 25 lines aren’t shown here.

appl/cmd/auxi/pcmcia.b+491−0

This diff is large: its 492 lines aren’t shown here.

appl/cmd/auxi/rdbgsrv.b+222−0

This diff is large: its 223 lines aren’t shown here.

appl/cmd/auxi/rstyxd.b+110−0

This diff is large: its 111 lines aren’t shown here.

appl/cmd/avr/burn.b+859−0

This diff is large: its 860 lines aren’t shown here.

appl/cmd/avr/mkfile+10−0

This diff is large: its 11 lines aren’t shown here.

appl/cmd/basename.b+50−0

This diff is large: its 51 lines aren’t shown here.

appl/cmd/bind.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/cmd/bit2gif.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/cmd/broke.b+84−0

This diff is large: its 85 lines aren’t shown here.

appl/cmd/bytes.b+212−0

This diff is large: its 213 lines aren’t shown here.

appl/cmd/cal.b+295−0

This diff is large: its 296 lines aren’t shown here.

appl/cmd/calc.b+2547−0

This diff is large: its 2548 lines aren’t shown here.

appl/cmd/cat.b+48−0

This diff is large: its 49 lines aren’t shown here.

appl/cmd/cd.b+48−0

This diff is large: its 49 lines aren’t shown here.

appl/cmd/cddb.b+247−0

This diff is large: its 248 lines aren’t shown here.

appl/cmd/chgrp.b+58−0

This diff is large: its 59 lines aren’t shown here.

appl/cmd/chmod.b+125−0

This diff is large: its 126 lines aren’t shown here.

appl/cmd/cleanname.b+45−0

This diff is large: its 46 lines aren’t shown here.

appl/cmd/cmp.b+151−0

This diff is large: its 152 lines aren’t shown here.

appl/cmd/comm.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/cmd/cook.b+1924−0

This diff is large: its 1925 lines aren’t shown here.

appl/cmd/cp.b+237−0

This diff is large: its 238 lines aren’t shown here.

appl/cmd/cprof.b+190−0

This diff is large: its 191 lines aren’t shown here.

appl/cmd/cpu.b+168−0

This diff is large: its 169 lines aren’t shown here.

appl/cmd/crypt.b+263−0

This diff is large: its 264 lines aren’t shown here.

appl/cmd/date.b+71−0

This diff is large: its 72 lines aren’t shown here.

appl/cmd/dbfs.b+518−0

This diff is large: its 519 lines aren’t shown here.

appl/cmd/dbm/delete.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/cmd/dbm/fetch.b+37−0

This diff is large: its 38 lines aren’t shown here.

appl/cmd/dbm/keys.b+32−0

This diff is large: its 33 lines aren’t shown here.

appl/cmd/dbm/list.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/cmd/dbm/mkfile+19−0

This diff is large: its 20 lines aren’t shown here.

appl/cmd/dbm/store.b+69−0

This diff is large: its 70 lines aren’t shown here.

appl/cmd/dd.b+625−0

This diff is large: its 626 lines aren’t shown here.

appl/cmd/dial.b+148−0

This diff is large: its 149 lines aren’t shown here.

appl/cmd/diff.b+854−0

This diff is large: its 855 lines aren’t shown here.

appl/cmd/disdep.b+250−0

This diff is large: its 251 lines aren’t shown here.

appl/cmd/disdump.b+52−0

This diff is large: its 53 lines aren’t shown here.

appl/cmd/disk/format.b+755−0

This diff is large: its 756 lines aren’t shown here.

appl/cmd/disk/ftl.b+911−0

This diff is large: its 912 lines aren’t shown here.

appl/cmd/disk/kfs.b+3844−0

This diff is large: its 3845 lines aren’t shown here.

appl/cmd/disk/kfscmd.b+53−0

This diff is large: its 54 lines aren’t shown here.

appl/cmd/disk/mbr.b+134−0

This diff is large: its 135 lines aren’t shown here.

appl/cmd/disk/mkext.b+352−0

This diff is large: its 353 lines aren’t shown here.

appl/cmd/disk/mkfile+25−0

This diff is large: its 26 lines aren’t shown here.

appl/cmd/disk/mkfs.b+732−0

This diff is large: its 733 lines aren’t shown here.

appl/cmd/disk/prep/calc.tab.b+454−0

This diff is large: its 455 lines aren’t shown here.

appl/cmd/disk/prep/calc.tab.m+7−0

This diff is large: its 8 lines aren’t shown here.

appl/cmd/disk/prep/calc.y+174−0

This diff is large: its 175 lines aren’t shown here.

appl/cmd/disk/prep/fdisk.b+924−0

This diff is large: its 925 lines aren’t shown here.

appl/cmd/disk/prep/mkfile+26−0

This diff is large: its 27 lines aren’t shown here.

appl/cmd/disk/prep/pedit.b+503−0

This diff is large: its 504 lines aren’t shown here.

appl/cmd/disk/prep/pedit.m+53−0

This diff is large: its 54 lines aren’t shown here.

appl/cmd/disk/prep/prep.b+508−0

This diff is large: its 509 lines aren’t shown here.

appl/cmd/dossrv.b+3431−0

This diff is large: its 3432 lines aren’t shown here.

appl/cmd/du.b+163−0

This diff is large: its 164 lines aren’t shown here.

appl/cmd/echo.b+36−0

This diff is large: its 37 lines aren’t shown here.

appl/cmd/ed.b+1588−0

This diff is large: its 1589 lines aren’t shown here.

appl/cmd/emuinit.b+110−0

This diff is large: its 111 lines aren’t shown here.

appl/cmd/env.b+52−0

This diff is large: its 53 lines aren’t shown here.

appl/cmd/export.b+57−0

This diff is large: its 58 lines aren’t shown here.

appl/cmd/fc.b+612−0

This diff is large: its 613 lines aren’t shown here.

appl/cmd/fcp.b+312−0

This diff is large: its 313 lines aren’t shown here.

appl/cmd/fmt.b+204−0

This diff is large: its 205 lines aren’t shown here.

appl/cmd/fone.b+560−0

This diff is large: its 561 lines aren’t shown here.

appl/cmd/fortune.b+100−0

This diff is large: its 101 lines aren’t shown here.

appl/cmd/freq.b+112−0

This diff is large: its 113 lines aren’t shown here.

appl/cmd/fs.b+109−0

This diff is large: its 110 lines aren’t shown here.

appl/cmd/fs/and.b+65−0

This diff is large: its 66 lines aren’t shown here.

appl/cmd/fs/bundle.b+195−0

This diff is large: its 196 lines aren’t shown here.

appl/cmd/fs/chstat.b+185−0

This diff is large: its 186 lines aren’t shown here.

appl/cmd/fs/compose.b+100−0

This diff is large: its 101 lines aren’t shown here.

appl/cmd/fs/depth.b+49−0

This diff is large: its 50 lines aren’t shown here.

appl/cmd/fs/entries.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/cmd/fs/eval.b+648−0

This diff is large: its 649 lines aren’t shown here.

appl/cmd/fs/exec.b+162−0

This diff is large: its 163 lines aren’t shown here.

appl/cmd/fs/filter.b+64−0

This diff is large: its 65 lines aren’t shown here.

appl/cmd/fs/ls.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/cmd/fs/match.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/cmd/fs/merge.b+187−0

This diff is large: its 188 lines aren’t shown here.

appl/cmd/fs/mergewrite.b+186−0

This diff is large: its 187 lines aren’t shown here.

appl/cmd/fs/mkfile+60−0

This diff is large: its 61 lines aren’t shown here.

appl/cmd/fs/mode.b+120−0

This diff is large: its 121 lines aren’t shown here.

appl/cmd/fs/not.b+48−0

This diff is large: its 49 lines aren’t shown here.

appl/cmd/fs/or.b+65−0

This diff is large: its 66 lines aren’t shown here.

appl/cmd/fs/path.b+77−0

This diff is large: its 78 lines aren’t shown here.

appl/cmd/fs/pipe.b+223−0

This diff is large: its 224 lines aren’t shown here.

appl/cmd/fs/print.b+51−0

This diff is large: its 52 lines aren’t shown here.

appl/cmd/fs/proto.b+393−0

This diff is large: its 394 lines aren’t shown here.

appl/cmd/fs/query.b+130−0

This diff is large: its 131 lines aren’t shown here.

appl/cmd/fs/readfile.b+144−0

This diff is large: its 145 lines aren’t shown here.

appl/cmd/fs/run.b+60−0

This diff is large: its 61 lines aren’t shown here.

appl/cmd/fs/select.b+56−0

This diff is large: its 57 lines aren’t shown here.

appl/cmd/fs/setroot.b+104−0

This diff is large: its 105 lines aren’t shown here.

appl/cmd/fs/size.b+54−0

This diff is large: its 55 lines aren’t shown here.

appl/cmd/fs/template.b+35−0

This diff is large: its 36 lines aren’t shown here.

appl/cmd/fs/unbundle.b+259−0

This diff is large: its 260 lines aren’t shown here.

appl/cmd/fs/void.b+33−0

This diff is large: its 34 lines aren’t shown here.

appl/cmd/fs/walk.b+233−0

This diff is large: its 234 lines aren’t shown here.

appl/cmd/fs/write.b+111−0

This diff is large: its 112 lines aren’t shown here.

appl/cmd/ftest.b+153−0

This diff is large: its 154 lines aren’t shown here.

appl/cmd/ftpfs.b+1955−0

This diff is large: its 1956 lines aren’t shown here.

appl/cmd/getauthinfo.b+185−0

This diff is large: its 186 lines aren’t shown here.

appl/cmd/getfile.b+74−0

This diff is large: its 75 lines aren’t shown here.

appl/cmd/gettar.b+248−0

This diff is large: its 249 lines aren’t shown here.

appl/cmd/gif2bit.b+101−0

This diff is large: its 102 lines aren’t shown here.

appl/cmd/grep.b+155−0

This diff is large: its 156 lines aren’t shown here.

appl/cmd/gunzip.b+139−0

This diff is large: its 140 lines aren’t shown here.

appl/cmd/gzip.b+228−0

This diff is large: its 229 lines aren’t shown here.

appl/cmd/idea.b+116−0

This diff is large: its 117 lines aren’t shown here.

appl/cmd/import.b+165−0

This diff is large: its 166 lines aren’t shown here.

appl/cmd/install/NOTICE+6−0

This diff is large: its 7 lines aren’t shown here.

appl/cmd/install/applylog.b+699−0

This diff is large: its 700 lines aren’t shown here.

appl/cmd/install/arch.b+288−0

This diff is large: its 289 lines aren’t shown here.

appl/cmd/install/arch.m+36−0

This diff is large: its 37 lines aren’t shown here.

appl/cmd/install/archfs.b+579−0

This diff is large: its 580 lines aren’t shown here.

appl/cmd/install/archfs.m+7−0

This diff is large: its 8 lines aren’t shown here.

appl/cmd/install/ckproto.b+267−0

This diff is large: its 268 lines aren’t shown here.

appl/cmd/install/create.b+445−0

This diff is large: its 446 lines aren’t shown here.

appl/cmd/install/eproto.b+357−0

This diff is large: its 358 lines aren’t shown here.

appl/cmd/install/info.b+73−0

This diff is large: its 74 lines aren’t shown here.

appl/cmd/install/inst.b+500−0

This diff is large: its 501 lines aren’t shown here.

appl/cmd/install/install.b+430−0

This diff is large: its 431 lines aren’t shown here.

appl/cmd/install/log.b+76−0

This diff is large: its 77 lines aren’t shown here.

appl/cmd/install/logs.b+287−0

This diff is large: its 288 lines aren’t shown here.

appl/cmd/install/logs.m+44−0

This diff is large: its 45 lines aren’t shown here.

appl/cmd/install/mergelog.b+239−0

This diff is large: its 240 lines aren’t shown here.

appl/cmd/install/mkfile+43−0

This diff is large: its 44 lines aren’t shown here.

appl/cmd/install/mkproto.b+99−0

This diff is large: its 100 lines aren’t shown here.

appl/cmd/install/proto.b+320−0

This diff is large: its 321 lines aren’t shown here.

appl/cmd/install/proto.m+6−0

This diff is large: its 7 lines aren’t shown here.

appl/cmd/install/proto2list.b+209−0

This diff is large: its 210 lines aren’t shown here.

appl/cmd/install/protocaller.m+8−0

This diff is large: its 9 lines aren’t shown here.

appl/cmd/install/updatelog.b+386−0

This diff is large: its 387 lines aren’t shown here.

appl/cmd/install/wdiff.b+148−0

This diff is large: its 149 lines aren’t shown here.

appl/cmd/install/wfind.b+204−0

This diff is large: its 205 lines aren’t shown here.

appl/cmd/install/wrap.b+684−0

This diff is large: its 685 lines aren’t shown here.

appl/cmd/install/wrap.m+41−0

This diff is large: its 42 lines aren’t shown here.

appl/cmd/install/wrap2list.b+305−0

This diff is large: its 306 lines aren’t shown here.

appl/cmd/iostats.b+635−0

This diff is large: its 636 lines aren’t shown here.

appl/cmd/ip/bootpd.b+661−0

This diff is large: its 662 lines aren’t shown here.

appl/cmd/ip/dhcp.b+162−0

This diff is large: its 163 lines aren’t shown here.

appl/cmd/ip/mkfile+29−0

This diff is large: its 30 lines aren’t shown here.

appl/cmd/ip/nppp/mkfile+24−0

This diff is large: its 25 lines aren’t shown here.

appl/cmd/ip/nppp/modem.b+469−0

This diff is large: its 470 lines aren’t shown here.

appl/cmd/ip/nppp/modem.m+47−0

This diff is large: its 48 lines aren’t shown here.

appl/cmd/ip/nppp/pppchat.b+322−0

This diff is large: its 323 lines aren’t shown here.

appl/cmd/ip/nppp/ppplink.b+782−0

This diff is large: its 783 lines aren’t shown here.

appl/cmd/ip/nppp/ppptest.b+90−0

This diff is large: its 91 lines aren’t shown here.

appl/cmd/ip/nppp/script.b+171−0

This diff is large: its 172 lines aren’t shown here.

appl/cmd/ip/nppp/script.m+15−0

This diff is large: its 16 lines aren’t shown here.

appl/cmd/ip/ping.b+358−0

This diff is large: its 359 lines aren’t shown here.

appl/cmd/ip/ppp/mkfile+27−0

This diff is large: its 28 lines aren’t shown here.

appl/cmd/ip/ppp/modem.b+468−0

This diff is large: its 469 lines aren’t shown here.

appl/cmd/ip/ppp/modem.m+41−0

This diff is large: its 42 lines aren’t shown here.

appl/cmd/ip/ppp/pppclient.b+216−0

This diff is large: its 217 lines aren’t shown here.

appl/cmd/ip/ppp/pppclient.m+31−0

This diff is large: its 32 lines aren’t shown here.

appl/cmd/ip/ppp/pppdial.b+283−0

This diff is large: its 284 lines aren’t shown here.

appl/cmd/ip/ppp/pppgui.b+373−0

This diff is large: its 374 lines aren’t shown here.

appl/cmd/ip/ppp/pppgui.m+21−0

This diff is large: its 22 lines aren’t shown here.

appl/cmd/ip/ppp/ppptest.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/cmd/ip/ppp/script.b+168−0

This diff is large: its 169 lines aren’t shown here.

appl/cmd/ip/ppp/script.m+14−0

This diff is large: its 15 lines aren’t shown here.

appl/cmd/ip/rip.b+625−0

This diff is large: its 626 lines aren’t shown here.

appl/cmd/ip/sntp.b+310−0

This diff is large: its 311 lines aren’t shown here.

appl/cmd/ip/tftpd.b+512−0

This diff is large: its 513 lines aren’t shown here.

appl/cmd/ip/virgild.b+126−0

This diff is large: its 127 lines aren’t shown here.

appl/cmd/irtest.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/cmd/itest.b+478−0

This diff is large: its 479 lines aren’t shown here.

appl/cmd/itreplay.b+230−0

This diff is large: its 231 lines aren’t shown here.

appl/cmd/kill.b+146−0

This diff is large: its 147 lines aren’t shown here.

appl/cmd/lego/clock.b+214−0

This diff is large: its 215 lines aren’t shown here.

appl/cmd/lego/clockface.b+384−0

This diff is large: its 385 lines aren’t shown here.

appl/cmd/lego/firmdl.b+294−0

This diff is large: its 295 lines aren’t shown here.

appl/cmd/lego/link.b+603−0

This diff is large: its 604 lines aren’t shown here.

appl/cmd/lego/mkfile+23−0

This diff is large: its 24 lines aren’t shown here.

appl/cmd/lego/rcxsend.b+240−0

This diff is large: its 241 lines aren’t shown here.

appl/cmd/lego/rcxsend.m+6−0

This diff is large: its 7 lines aren’t shown here.

appl/cmd/lego/send.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/cmd/lego/timers.b+263−0

This diff is large: its 264 lines aren’t shown here.

appl/cmd/lego/timers.m+17−0

This diff is large: its 18 lines aren’t shown here.

appl/cmd/limbo/arg.m+50−0

This diff is large: its 51 lines aren’t shown here.

appl/cmd/limbo/asm.b+263−0

This diff is large: its 264 lines aren’t shown here.

appl/cmd/limbo/com.b+1402−0

This diff is large: its 1403 lines aren’t shown here.

appl/cmd/limbo/decls.b+1177−0

This diff is large: its 1178 lines aren’t shown here.

appl/cmd/limbo/dis.b+560−0

This diff is large: its 561 lines aren’t shown here.

appl/cmd/limbo/disoptab.m+355−0

This diff is large: its 356 lines aren’t shown here.

appl/cmd/limbo/ecom.b+2345−0

This diff is large: its 2346 lines aren’t shown here.

appl/cmd/limbo/gen.b+1011−0

This diff is large: its 1012 lines aren’t shown here.

appl/cmd/limbo/isa.m+247−0

This diff is large: its 248 lines aren’t shown here.

appl/cmd/limbo/lex.b+1178−0

This diff is large: its 1179 lines aren’t shown here.

appl/cmd/limbo/limbo.b+3100−0

This diff is large: its 3101 lines aren’t shown here.

appl/cmd/limbo/limbo.m+527−0

This diff is large: its 528 lines aren’t shown here.

appl/cmd/limbo/limbo.y+1974−0

This diff is large: its 1975 lines aren’t shown here.

appl/cmd/limbo/mkfile+35−0

This diff is large: its 36 lines aren’t shown here.

appl/cmd/limbo/nodes.b+1402−0

This diff is large: its 1403 lines aren’t shown here.

appl/cmd/limbo/opname.m+109−0

This diff is large: its 110 lines aren’t shown here.

appl/cmd/limbo/optim.b+3−0

This diff is large: its 4 lines aren’t shown here.

appl/cmd/limbo/sbl.b+397−0

This diff is large: its 398 lines aren’t shown here.

appl/cmd/limbo/stubs.b+575−0

This diff is large: its 576 lines aren’t shown here.

appl/cmd/limbo/typecheck.b+3223−0

This diff is large: its 3224 lines aren’t shown here.

appl/cmd/limbo/types.b+4234−0

This diff is large: its 4235 lines aren’t shown here.

appl/cmd/listen.b+261−0

This diff is large: its 262 lines aren’t shown here.

appl/cmd/lockfs.b+778−0

This diff is large: its 779 lines aren’t shown here.

appl/cmd/logfile.b+259−0

This diff is large: its 260 lines aren’t shown here.

appl/cmd/look.b+384−0

This diff is large: its 385 lines aren’t shown here.

appl/cmd/ls.b+332−0

This diff is large: its 333 lines aren’t shown here.

appl/cmd/lstar.b+120−0

This diff is large: its 121 lines aren’t shown here.

appl/cmd/m4.b+946−0

This diff is large: its 947 lines aren’t shown here.

appl/cmd/man2html.b+1366−0

This diff is large: its 1367 lines aren’t shown here.

appl/cmd/man2txt.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/cmd/manufacture.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/cmd/mash/builtins.b+347−0

This diff is large: its 348 lines aren’t shown here.

appl/cmd/mash/depends.b+228−0

This diff is large: its 229 lines aren’t shown here.

appl/cmd/mash/dump.b+199−0

This diff is large: its 200 lines aren’t shown here.

appl/cmd/mash/exec.b+401−0

This diff is large: its 402 lines aren’t shown here.

appl/cmd/mash/expr.b+158−0

This diff is large: its 159 lines aren’t shown here.

appl/cmd/mash/eyacc.b+2785−0

This diff is large: its 2786 lines aren’t shown here.

appl/cmd/mash/eyaccpar+223−0

This diff is large: its 224 lines aren’t shown here.

appl/cmd/mash/history.b+206−0

This diff is large: its 207 lines aren’t shown here.

appl/cmd/mash/lex.b+547−0

This diff is large: its 548 lines aren’t shown here.

appl/cmd/mash/make.b+723−0

This diff is large: its 724 lines aren’t shown here.

appl/cmd/mash/mash.b+154−0

This diff is large: its 155 lines aren’t shown here.

appl/cmd/mash/mash.m+372−0

This diff is large: its 373 lines aren’t shown here.

appl/cmd/mash/mash.y+269−0

This diff is large: its 270 lines aren’t shown here.

appl/cmd/mash/mashfile+36−0

This diff is large: its 37 lines aren’t shown here.

appl/cmd/mash/mashlib.b+60−0

This diff is large: its 61 lines aren’t shown here.

appl/cmd/mash/mashparse.b+662−0

This diff is large: its 663 lines aren’t shown here.

appl/cmd/mash/mashparse.m+56−0

This diff is large: its 57 lines aren’t shown here.

appl/cmd/mash/misc.b+313−0

This diff is large: its 314 lines aren’t shown here.

appl/cmd/mash/mkfile+78−0

This diff is large: its 79 lines aren’t shown here.

appl/cmd/mash/serve.b+154−0

This diff is large: its 155 lines aren’t shown here.

appl/cmd/mash/symb.b+265−0

This diff is large: its 266 lines aren’t shown here.

appl/cmd/mash/tk.b+603−0

This diff is large: its 604 lines aren’t shown here.

appl/cmd/mash/xeq.b+543−0

This diff is large: its 544 lines aren’t shown here.

appl/cmd/mc.b+154−0

This diff is large: its 155 lines aren’t shown here.

appl/cmd/md5sum.b+65−0

This diff is large: its 66 lines aren’t shown here.

appl/cmd/mdb.b+537−0

This diff is large: its 538 lines aren’t shown here.

appl/cmd/memfs.b+648−0

This diff is large: its 649 lines aren’t shown here.

appl/cmd/metamorph.b+94−0

This diff is large: its 95 lines aren’t shown here.

appl/cmd/mk/ar.m+26−0

This diff is large: its 27 lines aren’t shown here.

appl/cmd/mk/mk.b+4190−0

This diff is large: its 4191 lines aren’t shown here.

appl/cmd/mk/mkbinds+2−0

This diff is large: its 3 lines aren’t shown here.

appl/cmd/mk/mkconfig+28−0

This diff is large: its 29 lines aren’t shown here.

appl/cmd/mk/mkfile+19−0

This diff is large: its 20 lines aren’t shown here.

appl/cmd/mk/mksubdirs+16−0

This diff is large: its 17 lines aren’t shown here.

appl/cmd/mkdir.b+75−0

This diff is large: its 76 lines aren’t shown here.

appl/cmd/mkfile+229−0

This diff is large: its 230 lines aren’t shown here.

appl/cmd/mntgen.b+188−0

This diff is large: its 189 lines aren’t shown here.

appl/cmd/mount.b+346−0

This diff is large: its 347 lines aren’t shown here.

appl/cmd/mouse.b+394−0

This diff is large: its 395 lines aren’t shown here.

appl/cmd/mpc/mkfile+14−0

This diff is large: its 15 lines aren’t shown here.

appl/cmd/mpc/qconfig.b+193−0

This diff is large: its 194 lines aren’t shown here.

appl/cmd/mpc/qflash.b+188−0

This diff is large: its 189 lines aren’t shown here.

appl/cmd/mprof.b+260−0

This diff is large: its 261 lines aren’t shown here.

appl/cmd/mv.b+183−0

This diff is large: its 184 lines aren’t shown here.

appl/cmd/ndb/cs.b+686−0

This diff is large: its 687 lines aren’t shown here.

appl/cmd/ndb/csquery.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/cmd/ndb/dns.b+1871−0

This diff is large: its 1872 lines aren’t shown here.

appl/cmd/ndb/dnsquery.b+177−0

This diff is large: its 178 lines aren’t shown here.

appl/cmd/ndb/mkfile+28−0

This diff is large: its 29 lines aren’t shown here.

appl/cmd/ndb/mkhash.b+119−0

This diff is large: its 120 lines aren’t shown here.

appl/cmd/ndb/query.b+135−0

This diff is large: its 136 lines aren’t shown here.

appl/cmd/ndb/registry.b+776−0

This diff is large: its 777 lines aren’t shown here.

appl/cmd/ndb/regquery.b+104−0

This diff is large: its 105 lines aren’t shown here.

appl/cmd/netkey.b+166−0

This diff is large: its 167 lines aren’t shown here.

appl/cmd/netstat.b+91−0

This diff is large: its 92 lines aren’t shown here.

appl/cmd/newer.b+36−0

This diff is large: its 37 lines aren’t shown here.

appl/cmd/ns.b+157−0

This diff is large: its 158 lines aren’t shown here.

appl/cmd/nsbuild.b+41−0

This diff is large: its 42 lines aren’t shown here.

appl/cmd/os.b+168−0

This diff is large: its 169 lines aren’t shown here.

appl/cmd/p.b+141−0

This diff is large: its 142 lines aren’t shown here.

appl/cmd/palm/connex.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/cmd/palm/desklink.b+843−0

This diff is large: its 844 lines aren’t shown here.

appl/cmd/palm/desklink.m+90−0

This diff is large: its 91 lines aren’t shown here.

appl/cmd/palm/mkfile+16−0

This diff is large: its 17 lines aren’t shown here.

appl/cmd/palm/palmsrv.b+901−0

This diff is large: its 902 lines aren’t shown here.

appl/cmd/pause.b+17−0

This diff is large: its 18 lines aren’t shown here.

appl/cmd/plumb.b+128−0

This diff is large: its 129 lines aren’t shown here.

appl/cmd/plumber.b+766−0

This diff is large: its 767 lines aren’t shown here.

appl/cmd/prof.b+243−0

This diff is large: its 244 lines aren’t shown here.

appl/cmd/promptstring.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/cmd/ps.b+61−0

This diff is large: its 62 lines aren’t shown here.

appl/cmd/puttar.b+183−0

This diff is large: its 184 lines aren’t shown here.

appl/cmd/pwd.b+28−0

This diff is large: its 29 lines aren’t shown here.

appl/cmd/ramfile.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/cmd/randpass.b+41−0

This diff is large: its 42 lines aren’t shown here.

appl/cmd/raw2iaf.b+122−0

This diff is large: its 123 lines aren’t shown here.

appl/cmd/rawdbfs.b+812−0

This diff is large: its 813 lines aren’t shown here.

appl/cmd/rcmd.b+170−0

This diff is large: its 171 lines aren’t shown here.

appl/cmd/rdp.b+1230−0

This diff is large: its 1231 lines aren’t shown here.

appl/cmd/read.b+62−0

This diff is large: its 63 lines aren’t shown here.

appl/cmd/rioimport.b+620−0

This diff is large: its 621 lines aren’t shown here.

appl/cmd/rm.b+99−0

This diff is large: its 100 lines aren’t shown here.

appl/cmd/runas.b+60−0

This diff is large: its 61 lines aren’t shown here.

appl/cmd/sed.b+911−0

This diff is large: its 912 lines aren’t shown here.

appl/cmd/sendmail.b+252−0

This diff is large: its 253 lines aren’t shown here.

appl/cmd/sh/arg.b+181−0

This diff is large: its 182 lines aren’t shown here.

appl/cmd/sh/csv.b+244−0

This diff is large: its 245 lines aren’t shown here.

appl/cmd/sh/doc/History+14−0

This diff is large: its 15 lines aren’t shown here.

appl/cmd/sh/echo.b+96−0

This diff is large: its 97 lines aren’t shown here.

appl/cmd/sh/expr.b+281−0

This diff is large: its 282 lines aren’t shown here.

appl/cmd/sh/file2chan.b+459−0

This diff is large: its 460 lines aren’t shown here.

appl/cmd/sh/mkfile+65−0

This diff is large: its 66 lines aren’t shown here.

appl/cmd/sh/mload.b+348−0

This diff is large: its 349 lines aren’t shown here.

appl/cmd/sh/mpexpr.b+435−0

This diff is large: its 436 lines aren’t shown here.

appl/cmd/sh/regex.b+220−0

This diff is large: its 221 lines aren’t shown here.

appl/cmd/sh/sexprs.b+271−0

This diff is large: its 272 lines aren’t shown here.

appl/cmd/sh/sh.b+2876−0

This diff is large: its 2877 lines aren’t shown here.

appl/cmd/sh/sh.y+2628−0

This diff is large: its 2629 lines aren’t shown here.

appl/cmd/sh/std.b+812−0

This diff is large: its 813 lines aren’t shown here.

appl/cmd/sh/string.b+212−0

This diff is large: its 213 lines aren’t shown here.

appl/cmd/sh/test.b+96−0

This diff is large: its 97 lines aren’t shown here.

appl/cmd/sh/tk.b+438−0

This diff is large: its 439 lines aren’t shown here.

appl/cmd/sha1sum.b+65−0

This diff is large: its 66 lines aren’t shown here.

appl/cmd/sleep.b+46−0

This diff is large: its 47 lines aren’t shown here.

appl/cmd/sort.b+129−0

This diff is large: its 130 lines aren’t shown here.

appl/cmd/spki/mkfile+22−0

This diff is large: its 23 lines aren’t shown here.

appl/cmd/spki/verify.b+107−0

This diff is large: its 108 lines aren’t shown here.

appl/cmd/src.b+96−0

This diff is large: its 97 lines aren’t shown here.

appl/cmd/stack.b+184−0

This diff is large: its 185 lines aren’t shown here.

appl/cmd/stackv.b+502−0

This diff is large: its 503 lines aren’t shown here.

appl/cmd/stream.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/cmd/strings.b+87−0

This diff is large: its 88 lines aren’t shown here.

appl/cmd/styxchat.b+546−0

This diff is large: its 547 lines aren’t shown here.

appl/cmd/styxlisten.b+262−0

This diff is large: its 263 lines aren’t shown here.

appl/cmd/styxmon.b+110−0

This diff is large: its 111 lines aren’t shown here.

appl/cmd/sum.b+59−0

This diff is large: its 60 lines aren’t shown here.

appl/cmd/tail.b+379−0

This diff is large: its 380 lines aren’t shown here.

appl/cmd/tarfs.b+438−0

This diff is large: its 439 lines aren’t shown here.

appl/cmd/tclsh.b+48−0

This diff is large: its 49 lines aren’t shown here.

appl/cmd/tcs.b+204−0

This diff is large: its 205 lines aren’t shown here.

appl/cmd/tee.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/cmd/telnet.b+469−0

This diff is large: its 470 lines aren’t shown here.

appl/cmd/test.b+284−0

This diff is large: its 285 lines aren’t shown here.

appl/cmd/time.b+97−0

This diff is large: its 98 lines aren’t shown here.

appl/cmd/timestamp.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/cmd/tkcmd.b+190−0

This diff is large: its 191 lines aren’t shown here.

appl/cmd/tokenize.b+33−0

This diff is large: its 34 lines aren’t shown here.

appl/cmd/touch.b+77−0

This diff is large: its 78 lines aren’t shown here.

appl/cmd/touchcal.b+278−0

This diff is large: its 279 lines aren’t shown here.

appl/cmd/tr.b+319−0

This diff is large: its 320 lines aren’t shown here.

appl/cmd/trfs.b+213−0

This diff is large: its 214 lines aren’t shown here.

appl/cmd/tsort.b+133−0

This diff is large: its 134 lines aren’t shown here.

appl/cmd/unicode.b+162−0

This diff is large: its 163 lines aren’t shown here.

appl/cmd/uniq.b+79−0

This diff is large: its 80 lines aren’t shown here.

appl/cmd/units.b+1061−0

This diff is large: its 1062 lines aren’t shown here.

appl/cmd/units.y+771−0

This diff is large: its 772 lines aren’t shown here.

appl/cmd/unmount.b+44−0

This diff is large: its 45 lines aren’t shown here.

appl/cmd/usb/mkfile+11−0

This diff is large: its 12 lines aren’t shown here.

appl/cmd/usb/usbd.b+835−0

This diff is large: its 836 lines aren’t shown here.

appl/cmd/uudecode.b+132−0

This diff is large: its 133 lines aren’t shown here.

appl/cmd/uuencode.b+101−0

This diff is large: its 102 lines aren’t shown here.

appl/cmd/vacfs.b+467−0

This diff is large: its 468 lines aren’t shown here.

appl/cmd/vacget.b+205−0

This diff is large: its 206 lines aren’t shown here.

appl/cmd/vacput.b+329−0

This diff is large: its 330 lines aren’t shown here.

appl/cmd/wav2iaf.b+171−0

This diff is large: its 172 lines aren’t shown here.

appl/cmd/wc.b+303−0

This diff is large: its 304 lines aren’t shown here.

appl/cmd/webgrab.b+571−0

This diff is large: its 572 lines aren’t shown here.

appl/cmd/wish.b+191−0

This diff is large: its 192 lines aren’t shown here.

appl/cmd/wmexport.b+556−0

This diff is large: its 557 lines aren’t shown here.

appl/cmd/wmimport.b+64−0

This diff is large: its 65 lines aren’t shown here.

appl/cmd/xargs.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/cmd/xd.b+316−0

This diff is large: its 317 lines aren’t shown here.

appl/cmd/yacc.b+2809−0

This diff is large: its 2810 lines aren’t shown here.

appl/cmd/zeros.b+68−0

This diff is large: its 69 lines aren’t shown here.

appl/collab/clients/chat.b+224−0

This diff is large: its 225 lines aren’t shown here.

appl/collab/clients/poll.b+282−0

This diff is large: its 283 lines aren’t shown here.

appl/collab/clients/poller.b+330−0

This diff is large: its 331 lines aren’t shown here.

appl/collab/clients/whiteboard.b+586−0

This diff is large: its 587 lines aren’t shown here.

appl/collab/collabsrv.b+176−0

This diff is large: its 177 lines aren’t shown here.

appl/collab/connect.b+156−0

This diff is large: its 157 lines aren’t shown here.

appl/collab/lib/messages.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/collab/lib/messages.m+42−0

This diff is large: its 43 lines aren’t shown here.

appl/collab/mkfile+62−0

This diff is large: its 63 lines aren’t shown here.

appl/collab/proxy.b+177−0

This diff is large: its 178 lines aren’t shown here.

appl/collab/proxy.m+5−0

This diff is large: its 6 lines aren’t shown here.

appl/collab/runcollab+8−0

This diff is large: its 9 lines aren’t shown here.

appl/collab/servers/chatsrv.b+263−0

This diff is large: its 264 lines aren’t shown here.

appl/collab/servers/memfssrv.b+20−0

This diff is large: its 21 lines aren’t shown here.

appl/collab/servers/mpx.b+301−0

This diff is large: its 302 lines aren’t shown here.

appl/collab/servers/wbsrv.b+226−0

This diff is large: its 227 lines aren’t shown here.

appl/collab/service.m+4−0

This diff is large: its 5 lines aren’t shown here.

appl/collab/srvmgr.b+190−0

This diff is large: its 191 lines aren’t shown here.

appl/collab/srvmgr.m+22−0

This diff is large: its 23 lines aren’t shown here.

appl/demo/camera/camera.b+2557−0

This diff is large: its 2558 lines aren’t shown here.

appl/demo/camera/camload.bit+0−0

Binary file not shown.

appl/demo/camera/camproc.bit+0−0

Binary file not shown.

appl/demo/camera/mkfile+42−0

This diff is large: its 43 lines aren’t shown here.

appl/demo/camera/runcam.sh+3−0

This diff is large: its 4 lines aren’t shown here.

appl/demo/camera/runcamlocal.sh+3−0

This diff is large: its 4 lines aren’t shown here.

appl/demo/camera/tkinterface.b+2508−0

This diff is large: its 2509 lines aren’t shown here.

appl/demo/chat/chat.b+203−0

This diff is large: its 204 lines aren’t shown here.

appl/demo/chat/chatclient.sh+20−0

This diff is large: its 21 lines aren’t shown here.

appl/demo/chat/chatsrv.b+268−0

This diff is large: its 269 lines aren’t shown here.

appl/demo/chat/mkfile+30−0

This diff is large: its 31 lines aren’t shown here.

appl/demo/cpupool/mkfile+26−0

This diff is large: its 27 lines aren’t shown here.

appl/demo/cpupool/regpoll.b+63−0

This diff is large: its 64 lines aren’t shown here.

appl/demo/cpupool/runrstyx.sh+50−0

This diff is large: its 51 lines aren’t shown here.

appl/demo/lego/clockface.b+367−0

This diff is large: its 368 lines aren’t shown here.

appl/demo/lego/clockreg.sh+17−0

This diff is large: its 18 lines aren’t shown here.

appl/demo/lego/firmdl.b+294−0

This diff is large: its 295 lines aren’t shown here.

appl/demo/lego/legolink.b+601−0

This diff is large: its 602 lines aren’t shown here.

appl/demo/lego/mkfile+36−0

This diff is large: its 37 lines aren’t shown here.

appl/demo/lego/rcxsend.b+240−0

This diff is large: its 241 lines aren’t shown here.

appl/demo/lego/rcxsend.m+4−0

This diff is large: its 5 lines aren’t shown here.

appl/demo/lego/styx.srec+329−0

This diff is large: its 330 lines aren’t shown here.

appl/demo/lego/timers.b+263−0

This diff is large: its 264 lines aren’t shown here.

appl/demo/lego/timers.m+15−0

This diff is large: its 16 lines aren’t shown here.

appl/demo/mkfile+14−0

This diff is large: its 15 lines aren’t shown here.

appl/demo/ns/mkfile+27−0

This diff is large: its 28 lines aren’t shown here.

appl/demo/ns/ns.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/demo/ns/runns.sh+7−0

This diff is large: its 8 lines aren’t shown here.

appl/demo/odbc/mkfile+31−0

This diff is large: its 32 lines aren’t shown here.

appl/demo/odbc/odbcmnt.b+428−0

This diff is large: its 429 lines aren’t shown here.

appl/demo/odbc/runodbc.sh+17−0

This diff is large: its 18 lines aren’t shown here.

appl/demo/spree/mkfile+23−0

This diff is large: its 24 lines aren’t shown here.

appl/demo/spree/spreeclient.sh+44−0

This diff is large: its 45 lines aren’t shown here.

appl/demo/whiteboard/mkfile+28−0

This diff is large: its 29 lines aren’t shown here.

appl/demo/whiteboard/runwb.sh+7−0

This diff is large: its 8 lines aren’t shown here.

appl/demo/whiteboard/wbsrv.b+268−0

This diff is large: its 269 lines aren’t shown here.

appl/demo/whiteboard/whiteboard.b+605−0

This diff is large: its 606 lines aren’t shown here.

appl/ebook/checkxml.b+132−0

This diff is large: its 133 lines aren’t shown here.

appl/ebook/cssfont.b+179−0

This diff is large: its 180 lines aren’t shown here.

appl/ebook/cssfont.m+9−0

This diff is large: its 10 lines aren’t shown here.

appl/ebook/cssparser.b+143−0

This diff is large: its 144 lines aren’t shown here.

appl/ebook/cssparser.m+11−0

This diff is large: its 12 lines aren’t shown here.

appl/ebook/dtd/oebdoc101.dtd+524−0

This diff is large: its 525 lines aren’t shown here.

appl/ebook/dtd/oebpkg101.dtd+280−0

This diff is large: its 281 lines aren’t shown here.

appl/ebook/ebook.b+1893−0

This diff is large: its 1894 lines aren’t shown here.

appl/ebook/mimeimage.b+96−0

This diff is large: its 97 lines aren’t shown here.

appl/ebook/mimeimage.m+7−0

This diff is large: its 8 lines aren’t shown here.

appl/ebook/mkfile+36−0

This diff is large: its 37 lines aren’t shown here.

appl/ebook/oebpackage.b+276−0

This diff is large: its 277 lines aren’t shown here.

appl/ebook/oebpackage.m+34−0

This diff is large: its 35 lines aren’t shown here.

appl/ebook/reader.b+1797−0

This diff is large: its 1798 lines aren’t shown here.

appl/ebook/reader.m+120−0

This diff is large: its 121 lines aren’t shown here.

appl/ebook/strcache.m+6−0

This diff is large: its 7 lines aren’t shown here.

appl/ebook/strmap.b+40−0

This diff is large: its 41 lines aren’t shown here.

appl/ebook/strmap.m+12−0

This diff is large: its 13 lines aren’t shown here.

appl/ebook/stylesheet.b+156−0

This diff is large: its 157 lines aren’t shown here.

appl/ebook/stylesheet.m+42−0

This diff is large: its 43 lines aren’t shown here.

appl/ebook/table.b+176−0

This diff is large: its 177 lines aren’t shown here.

appl/ebook/table.m+11−0

This diff is large: its 12 lines aren’t shown here.

appl/ebook/tst.txt+379−0

This diff is large: its 380 lines aren’t shown here.

appl/ebook/understandingoeb.opf+65−0

This diff is large: its 66 lines aren’t shown here.

appl/ebook/units.b+146−0

This diff is large: its 147 lines aren’t shown here.

appl/ebook/units.m+6−0

This diff is large: its 7 lines aren’t shown here.

appl/grid/README+2−0

This diff is large: its 3 lines aren’t shown here.

appl/grid/blurdemo.b+977−0

This diff is large: its 978 lines aren’t shown here.

appl/grid/cpupool.b+917−0

This diff is large: its 918 lines aren’t shown here.

appl/grid/demo/block.b+212−0

This diff is large: its 213 lines aren’t shown here.

appl/grid/demo/blur.b+654−0

This diff is large: its 655 lines aren’t shown here.

appl/grid/demo/mkfile+32−0

This diff is large: its 33 lines aren’t shown here.

appl/grid/find.b+262−0

This diff is large: its 263 lines aren’t shown here.

appl/grid/jpg2bit.b+47−0

This diff is large: its 48 lines aren’t shown here.

appl/grid/lib/announce.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/grid/lib/browser.b+1178−0

This diff is large: its 1179 lines aren’t shown here.

appl/grid/lib/browser.m+97−0

This diff is large: its 98 lines aren’t shown here.

appl/grid/lib/fbrowse.b+390−0

This diff is large: its 391 lines aren’t shown here.

appl/grid/lib/mkfile+27−0

This diff is large: its 28 lines aren’t shown here.

appl/grid/lib/pathreader.m+3−0

This diff is large: its 4 lines aren’t shown here.

appl/grid/lib/srvbrowse.b+719−0

This diff is large: its 720 lines aren’t shown here.

appl/grid/mkfile+56−0

This diff is large: its 57 lines aren’t shown here.

appl/grid/query.b+399−0

This diff is large: its 400 lines aren’t shown here.

appl/grid/readjpg.b+1146−0

This diff is large: its 1147 lines aren’t shown here.

appl/grid/register.b+239−0

This diff is large: its 240 lines aren’t shown here.

appl/grid/reglisten.b+305−0

This diff is large: its 306 lines aren’t shown here.

appl/grid/regstyxlisten.b+279−0

This diff is large: its 280 lines aren’t shown here.

appl/grid/remotelogon.b+427−0

This diff is large: its 428 lines aren’t shown here.

appl/grid/usercreatesrv.b+93−0

This diff is large: its 94 lines aren’t shown here.

appl/lib/NOTICE+25−0

This diff is large: its 26 lines aren’t shown here.

appl/lib/arg.b+118−0

This diff is large: its 119 lines aren’t shown here.

appl/lib/asn1.b+1030−0

This diff is large: its 1031 lines aren’t shown here.

appl/lib/attrdb.b+486−0

This diff is large: its 487 lines aren’t shown here.

appl/lib/attrhash.b+109−0

This diff is large: its 110 lines aren’t shown here.

appl/lib/auth.b+326−0

This diff is large: its 327 lines aren’t shown here.

appl/lib/auth9.b+342−0

This diff is large: its 343 lines aren’t shown here.

appl/lib/bloomfilter.b+72−0

This diff is large: its 73 lines aren’t shown here.

appl/lib/bufio.b+534−0

This diff is large: its 535 lines aren’t shown here.

appl/lib/cfg.b+234−0

This diff is large: its 235 lines aren’t shown here.

appl/lib/cfgfile.b+152−0

This diff is large: its 153 lines aren’t shown here.

appl/lib/chanfill.b+52−0

This diff is large: its 53 lines aren’t shown here.

appl/lib/complete.b+92−0

This diff is large: its 93 lines aren’t shown here.

appl/lib/convcs/8bit_stob.b+24−0

This diff is large: its 25 lines aren’t shown here.

appl/lib/convcs/big5_btos.b+87−0

This diff is large: its 88 lines aren’t shown here.

appl/lib/convcs/big5_stob.b+93−0

This diff is large: its 94 lines aren’t shown here.

appl/lib/convcs/convcs.b+165−0

This diff is large: its 166 lines aren’t shown here.

appl/lib/convcs/cp932_btos.b+179−0

This diff is large: its 180 lines aren’t shown here.

appl/lib/convcs/cp_btos.b+45−0

This diff is large: its 46 lines aren’t shown here.

appl/lib/convcs/cp_stob.b+49−0

This diff is large: its 50 lines aren’t shown here.

appl/lib/convcs/euc-jp_btos.b+162−0

This diff is large: its 163 lines aren’t shown here.

appl/lib/convcs/gb2312_btos.b+70−0

This diff is large: its 71 lines aren’t shown here.

appl/lib/convcs/genbig5.b+1790−0

This diff is large: its 1791 lines aren’t shown here.

appl/lib/convcs/gencp.b+28−0

This diff is large: its 29 lines aren’t shown here.

appl/lib/convcs/gencp932.b+7814−0

This diff is large: its 7815 lines aren’t shown here.

appl/lib/convcs/gengb2312.b+1143−0

This diff is large: its 1144 lines aren’t shown here.

appl/lib/convcs/genjisx0201kana.b+117−0

This diff is large: its 118 lines aren’t shown here.

appl/lib/convcs/genjisx0208-1997.b+6958−0

This diff is large: its 6959 lines aren’t shown here.

appl/lib/convcs/genjisx0212.b+6146−0

This diff is large: its 6147 lines aren’t shown here.

appl/lib/convcs/ibm437.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/lib/convcs/ibm850.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/lib/convcs/ibm866.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/lib/convcs/iso8859-1.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-10.b+43−0

This diff is large: its 44 lines aren’t shown here.

appl/lib/convcs/iso8859-15.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-2.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-3.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-4.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-5.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-6.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-7.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-8.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/iso8859-9.b+42−0

This diff is large: its 43 lines aren’t shown here.

appl/lib/convcs/koi8-r.b+43−0

This diff is large: its 44 lines aren’t shown here.

appl/lib/convcs/mkdata+40−0

This diff is large: its 41 lines aren’t shown here.

appl/lib/convcs/mkfile+29−0

This diff is large: its 30 lines aren’t shown here.

appl/lib/convcs/utf16_btos.b+66−0

This diff is large: its 67 lines aren’t shown here.

appl/lib/convcs/utf16_stob.b+47−0

This diff is large: its 48 lines aren’t shown here.

appl/lib/convcs/utf8_btos.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/lib/convcs/utf8_stob.b+17−0

This diff is large: its 18 lines aren’t shown here.

appl/lib/convcs/windows-1250.b+26−0

This diff is large: its 27 lines aren’t shown here.

appl/lib/convcs/windows-1251.b+34−0

This diff is large: its 35 lines aren’t shown here.

appl/lib/convcs/windows-1252.b+26−0

This diff is large: its 27 lines aren’t shown here.

appl/lib/crc.b+45−0

This diff is large: its 46 lines aren’t shown here.

appl/lib/crypt/mkfile+24−0

This diff is large: its 25 lines aren’t shown here.

appl/lib/crypt/pkcs.b+572−0

This diff is large: its 573 lines aren’t shown here.

appl/lib/crypt/ssl3.b+5557−0

This diff is large: its 5558 lines aren’t shown here.

appl/lib/crypt/sslsession.b+176−0

This diff is large: its 177 lines aren’t shown here.

appl/lib/crypt/x509.b+4125−0

This diff is large: its 4126 lines aren’t shown here.

appl/lib/csv.b+86−0

This diff is large: its 87 lines aren’t shown here.

appl/lib/daytime.b+511−0

This diff is large: its 512 lines aren’t shown here.

appl/lib/db.b+253−0

This diff is large: its 254 lines aren’t shown here.

appl/lib/dbm.b+463−0

This diff is large: its 464 lines aren’t shown here.

appl/lib/dbsrv.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/lib/debug.b+1496−0

This diff is large: its 1497 lines aren’t shown here.

appl/lib/deflate.b+1453−0

This diff is large: its 1454 lines aren’t shown here.

appl/lib/devpointer.b+123−0

This diff is large: its 124 lines aren’t shown here.

appl/lib/dhcpclient.b+1029−0

This diff is large: its 1030 lines aren’t shown here.

appl/lib/dial.b+384−0

This diff is large: its 385 lines aren’t shown here.

appl/lib/dialog.b+190−0

This diff is large: its 191 lines aren’t shown here.

appl/lib/dict.b+57−0

This diff is large: its 58 lines aren’t shown here.

appl/lib/dis.b+609−0

This diff is large: its 610 lines aren’t shown here.

appl/lib/diskblocks.b+122−0

This diff is large: its 123 lines aren’t shown here.

appl/lib/disks.b+363−0

This diff is large: its 364 lines aren’t shown here.

appl/lib/dividers.b+242−0

This diff is large: its 243 lines aren’t shown here.

appl/lib/ecmascript/builtin.b+1480−0

This diff is large: its 1481 lines aren’t shown here.

appl/lib/ecmascript/date.b+495−0

This diff is large: its 496 lines aren’t shown here.

appl/lib/ecmascript/ecmascript.b+2626−0

This diff is large: its 2627 lines aren’t shown here.

appl/lib/ecmascript/exec.b+863−0

This diff is large: its 864 lines aren’t shown here.

appl/lib/ecmascript/mkfile+23−0

This diff is large: its 24 lines aren’t shown here.

appl/lib/ecmascript/obj.b+836−0

This diff is large: its 837 lines aren’t shown here.

appl/lib/ecmascript/pprint.b+378−0

This diff is large: its 379 lines aren’t shown here.

appl/lib/ecmascript/regexp.b+1286−0

This diff is large: its 1287 lines aren’t shown here.

appl/lib/ecmascript/uri.b+140−0

This diff is large: its 141 lines aren’t shown here.

appl/lib/encoding/base16.b+43−0

This diff is large: its 44 lines aren’t shown here.

appl/lib/encoding/base32.b+60−0

This diff is large: its 61 lines aren’t shown here.

appl/lib/encoding/base32a.b+57−0

This diff is large: its 58 lines aren’t shown here.

appl/lib/encoding/base64.b+92−0

This diff is large: its 93 lines aren’t shown here.

appl/lib/encoding/mkfile+16−0

This diff is large: its 17 lines aren’t shown here.

appl/lib/env.b+91−0

This diff is large: its 92 lines aren’t shown here.

appl/lib/ether.b+83−0

This diff is large: its 84 lines aren’t shown here.

appl/lib/exception.b+59−0

This diff is large: its 60 lines aren’t shown here.

appl/lib/factotum.b+521−0

This diff is large: its 522 lines aren’t shown here.

appl/lib/filepat.b+169−0

This diff is large: its 170 lines aren’t shown here.

appl/lib/format.b+147−0

This diff is large: its 148 lines aren’t shown here.

appl/lib/fsfilter.b+67−0

This diff is large: its 68 lines aren’t shown here.

appl/lib/fslib.b+400−0

This diff is large: its 401 lines aren’t shown here.

appl/lib/fsproto.b+385−0

This diff is large: its 386 lines aren’t shown here.

appl/lib/gamer.b+147−0

This diff is large: its 148 lines aren’t shown here.

appl/lib/hash.b+80−0

This diff is large: its 81 lines aren’t shown here.

appl/lib/html.b+664−0

This diff is large: its 665 lines aren’t shown here.

appl/lib/ida/NOTICE+33−0

This diff is large: its 34 lines aren’t shown here.

appl/lib/ida/ida.b+228−0

This diff is large: its 229 lines aren’t shown here.

appl/lib/ida/idatab.b+65549−0

This diff is large: its 65550 lines aren’t shown here.

appl/lib/ida/idatab.dist+0−0

Binary file not shown.

appl/lib/ida/idatest.b+84−0

This diff is large: its 85 lines aren’t shown here.

appl/lib/ida/mkfile+21−0

This diff is large: its 22 lines aren’t shown here.

appl/lib/ida/mktab.b+32−0

This diff is large: its 33 lines aren’t shown here.

appl/lib/imageremap.b+738−0

This diff is large: its 739 lines aren’t shown here.

appl/lib/inflate.b+820−0

This diff is large: its 821 lines aren’t shown here.

appl/lib/ip.b+656−0

This diff is large: its 657 lines aren’t shown here.

appl/lib/ipattr.b+217−0

This diff is large: its 218 lines aren’t shown here.

appl/lib/ir.b+95−0

This diff is large: its 96 lines aren’t shown here.

appl/lib/irmpath.b+118−0

This diff is large: its 119 lines aren’t shown here.

appl/lib/irsage.b+99−0

This diff is large: its 100 lines aren’t shown here.

appl/lib/irsim.b+83−0

This diff is large: its 84 lines aren’t shown here.

appl/lib/itslib.b+45−0

This diff is large: its 46 lines aren’t shown here.

appl/lib/json.b+619−0

This diff is large: its 620 lines aren’t shown here.

appl/lib/keyset.b+89−0

This diff is large: its 90 lines aren’t shown here.

appl/lib/libc.b+148−0

This diff is large: its 149 lines aren’t shown here.

appl/lib/libc0.b+249−0

This diff is large: its 250 lines aren’t shown here.

appl/lib/lists.b+142−0

This diff is large: its 143 lines aren’t shown here.

appl/lib/lock.b+26−0

This diff is large: its 27 lines aren’t shown here.

appl/lib/login.b+175−0

This diff is large: its 176 lines aren’t shown here.

appl/lib/man.b+139−0

This diff is large: its 140 lines aren’t shown here.

appl/lib/memfs.b+46−0

This diff is large: its 47 lines aren’t shown here.

appl/lib/mkfile+247−0

This diff is large: its 248 lines aren’t shown here.

appl/lib/mpeg.b+148−0

This diff is large: its 149 lines aren’t shown here.

appl/lib/msgio.b+152−0

This diff is large: its 153 lines aren’t shown here.

appl/lib/names.b+154−0

This diff is large: its 155 lines aren’t shown here.

appl/lib/nametree.b+277−0

This diff is large: its 278 lines aren’t shown here.

appl/lib/newns.b+465−0

This diff is large: its 466 lines aren’t shown here.

appl/lib/ninep.b+914−0

This diff is large: its 915 lines aren’t shown here.

appl/lib/oldauth.b+344−0

This diff is large: its 345 lines aren’t shown here.

appl/lib/palm.b+504−0

This diff is large: its 505 lines aren’t shown here.

appl/lib/palmdb.b+576−0

This diff is large: its 577 lines aren’t shown here.

appl/lib/palmfile.b+703−0

This diff is large: its 704 lines aren’t shown here.

appl/lib/parseman.b+806−0

This diff is large: its 807 lines aren’t shown here.

appl/lib/plumbing.b+254−0

This diff is large: its 255 lines aren’t shown here.

appl/lib/plumbing.m+23−0

This diff is large: its 24 lines aren’t shown here.

appl/lib/plumbmsg.b+190−0

This diff is large: its 191 lines aren’t shown here.

appl/lib/pop3.b+290−0

This diff is large: its 291 lines aren’t shown here.

appl/lib/popup.b+124−0

This diff is large: its 125 lines aren’t shown here.

appl/lib/powerman.b+59−0

This diff is large: its 60 lines aren’t shown here.

This diff is larger than a page shows: the files after these aren’t listed. Clone the repository to see all of it.