raz / commit ca1d9f1c

commit
ca1d9f1c12f037fb6a13c8d84727d7026038cbc3
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
0b1679c1
site: v0.17.2

The download, the library's PDF and spec page with Sys.execve.

patch · log

10 files changed, +31 -28

site/public/_redirects (history) modified +1 -1

@@ -1 +1 @@
1-/download/latest /download/raz-0.17.1-linux-x86_64.tar.gz 302
1+/download/latest /download/raz-0.17.2-linux-x86_64.tar.gz 302

site/public/advanced/listing.html (history) modified +12 -12

@@ -258,18 +258,18 @@
258258 <ul><li><code>gdb</code> finds procedures by name and lines by number, since the executable carries them: <code>break Dot.dot</code> and <code>list</code> work, and so does stepping a line at a time.</li><li><code>RAZ_PROFILE=1</code> samples the program every millisecond and says which procedures and lines took the time.</li><li><code>objdump -d</code> disassembles what is really in the file, if you want to see the bytes behind a listing.</li></ul>
259259 <pre class="output term"><code><span class="cmd">$ raz -o Dot Dot.raz</span>
260260 <span class="cmd">$ objdump -d -M intel --no-show-raw-insn Dot | sed -n &#x27;/&lt;Dot.dot&gt;:/,/ret/p&#x27; | head -12</span>
261-0000000000403bc0 &lt;Dot.dot&gt;:
262- 403bc0: push rbp
263- 403bc1: mov rbp,rsp
264- 403bc4: sub rsp,0x40
265- 403bcb: mov QWORD PTR [rbp-0x38],rbx
266- 403bcf: xor ebx,ebx
267- 403bd1: mov QWORD PTR [rbp-0x30],r12
268- 403bd5: xor r12d,r12d
269- 403bd8: mov QWORD PTR [rbp-0x28],r13
270- 403bdc: xor r13d,r13d
271- 403bdf: mov QWORD PTR [rbp-0x20],rdx
272- 403be3: mov QWORD PTR [rbp-0x18],rcx</code></pre>
261+0000000000403b00 &lt;Dot.dot&gt;:
262+ 403b00: push rbp
263+ 403b01: mov rbp,rsp
264+ 403b04: sub rsp,0x40
265+ 403b0b: mov QWORD PTR [rbp-0x38],rbx
266+ 403b0f: xor ebx,ebx
267+ 403b11: mov QWORD PTR [rbp-0x30],r12
268+ 403b15: xor r12d,r12d
269+ 403b18: mov QWORD PTR [rbp-0x28],r13
270+ 403b1c: xor r13d,r13d
271+ 403b1f: mov QWORD PTR [rbp-0x20],rdx
272+ 403b23: mov QWORD PTR [rbp-0x18],rcx</code></pre>
273273 <p>The listing is what the encoder meant; <code>objdump</code> is what the processor will read. They tell the same story.</p><p class="tryit">Save a program under its module&rsquo;s name and run it with <code>raz run Name.raz</code>.</p><div class="pager"><a href="syscalls.html">&larr; System calls</a><a href="index.html">Contents</a><a class="next" href="volatile.html">Volatile &rarr;</a></div></article></div>
274274 </main>
275275 <footer>raz is under the ISC license.</footer>

site/public/advanced/static.html (history) modified +4 -4

@@ -65,7 +65,7 @@
6565 <span class="cmd">$ ldd Bare</span>
6666 not a dynamic executable
6767 <span class="cmd">$ ls -l Bare | awk &#x27;{print $5, &quot;bytes&quot;}&#x27;</span>
68-26728 bytes</code></pre>
68+26304 bytes</code></pre>
6969 <p>It is statically linked: no interpreter, no shared libraries, no <code>libc</code>. <code>ldd</code> says so.</p>
7070 <h2>What it does when it runs</h2>
7171 <p><code>strace</code> lists every system call a program makes. This is the whole of it:</p>
@@ -134,14 +134,14 @@
134134 <pre class="output term"><code><span class="cmd">$ raz Lean.raz</span>
135135 <span class="cmd">$ raz Heavy.raz</span>
136136 <span class="cmd">$ ls -l Lean Heavy | awk &#x27;{print $9, $5}&#x27;</span>
137-Heavy 28904
138-Lean 28896</code></pre>
137+Heavy 28480
138+Lean 28464</code></pre>
139139 <p>The sizes differ by a few bytes, not by the hundreds of kilobytes that the table and the procedure would take: they are not in the executable at all. You can link in a library module without worrying what else it offers.</p>
140140 <h2>Stripping</h2>
141141 <p><code>-s</code> leaves out what is there for finding faults: the symbols and line numbers, the places a failure is told by, and the profiler. It is for the final build of a size-conscious program; the default keeps them so that gdb and failure messages work.</p>
142142 <pre class="output term"><code><span class="cmd">$ raz -s -o Lean-stripped Lean.raz</span>
143143 <span class="cmd">$ ls -l Lean Lean-stripped | awk &#x27;{print $9, $5}&#x27;</span>
144-Lean 28896
144+Lean 28464
145145 Lean-stripped 6856
146146 <span class="cmd">$ ./Lean-stripped</span>
147147 same program</code></pre>

site/public/advanced/targets.html (history) modified +1 -1

@@ -52,7 +52,7 @@
5252 Sys.raz
5353 Thread.linux-x86_64.raz
5454 <span class="cmd">$ cd $RAZLIB &amp;&amp; grep -c SYSCALL Sys.linux-x86_64.raz Sys.raz</span>
55-Sys.linux-x86_64.raz:128
55+Sys.linux-x86_64.raz:129
5656 Sys.raz:0</code></pre>
5757 <h2>A module of your own</h2>
5858 <p>Here is a module with two files. <code>Clock.linux-x86_64.raz</code> is for this target; <code>Clock.raz</code> is what any other target would use. Both say what they are in <code>Name</code>, and both make <code>ticks</code>.</p>

site/public/download/raz-0.17.2-linux-x86_64.tar.gz (history) added

Binary file; the patch has it.

site/public/download/raz-0.17.2-linux-x86_64.tar.gz.sha256 (history) added +1 -0

@@ -0,0 +1 @@
1+ba019964915644ce6c0efe08258a08dcaf6ee20ce37a32ac2404a587c0b2c387 raz-0.17.2-linux-x86_64.tar.gz

site/public/index.html (history) modified +8 -8

@@ -113,24 +113,24 @@
113113 <a href="raz-lib.pdf">the library</a>.</p>
114114
115115 <h2 id="download">Download</h2>
116-<p>raz 0.17.1 is a tarball for x86-64 Linux with the compiler, <code>raz</code>,
116+<p>raz 0.17.2 is a tarball for x86-64 Linux with the compiler, <code>raz</code>,
117117 its library, <code>lib/</code>, which it finds beside itself, the formatter
118118 and the documentation tool as sources in <code>tools/</code>, and the manual
119119 pages. It needs nothing else installed.</p>
120120 <div class="cta">
121- <a class="btn primary" href="download/raz-0.17.1-linux-x86_64.tar.gz">Download raz 0.17.1</a>
122- <a class="btn" href="download/raz-0.17.1-linux-x86_64.tar.gz.sha256">SHA-256</a>
121+ <a class="btn primary" href="download/raz-0.17.2-linux-x86_64.tar.gz">Download raz 0.17.2</a>
122+ <a class="btn" href="download/raz-0.17.2-linux-x86_64.tar.gz.sha256">SHA-256</a>
123123 </div>
124-<pre class="code"><code>$ tar xzf raz-0.17.1-linux-x86_64.tar.gz
125-$ ln -s $PWD/raz-0.17.1-linux-x86_64/raz ~/.local/bin/raz
124+<pre class="code"><code>$ tar xzf raz-0.17.2-linux-x86_64.tar.gz
125+$ ln -s $PWD/raz-0.17.2-linux-x86_64/raz ~/.local/bin/raz
126126 $ raz run Hello.raz</code></pre>
127127 <p>The link works since raz finds <code>lib/</code> beside its real path. The
128128 manual pages are in <code>man/</code>: <code>man ./man/raz-tutorial.7</code>.
129129 The address <code>download/latest</code> always leads to the newest release,
130-and <code>download/raz-0.17.1-linux-x86_64.tar.gz</code> to this one, for
131-good. Earlier releases: <a href="download/raz-0.17.0-linux-x86_64.tar.gz">0.17.0</a>, <a href="download/raz-0.16.0-linux-x86_64.tar.gz">0.16.0</a>, <a href="download/raz-0.15.0-linux-x86_64.tar.gz">0.15.0</a>, <a href="download/raz-0.14.0-linux-x86_64.tar.gz">0.14.0</a>, <a href="download/raz-0.13.0-linux-x86_64.tar.gz">0.13.0</a>, <a href="download/raz-0.12.0-linux-x86_64.tar.gz">0.12.0</a>, <a href="download/raz-0.11.1-linux-x86_64.tar.gz">0.11.1</a>, <a href="download/raz-0.11.0-linux-x86_64.tar.gz">0.11.0</a>, <a href="download/raz-0.10.1-linux-x86_64.tar.gz">0.10.1</a>, <a href="download/raz-0.10.0-linux-x86_64.tar.gz">0.10.0</a>, <a href="download/raz-0.9.1-linux-x86_64.tar.gz">0.9.1</a>, <a href="download/raz-0.9.0-linux-x86_64.tar.gz">0.9.0</a>, <a href="download/raz-0.8.0-linux-x86_64.tar.gz">0.8.0</a>, <a href="download/raz-0.7.1-linux-x86_64.tar.gz">0.7.1</a>; each has its SHA-256 beside it, with
130+and <code>download/raz-0.17.2-linux-x86_64.tar.gz</code> to this one, for
131+good. Earlier releases: <a href="download/raz-0.17.1-linux-x86_64.tar.gz">0.17.1</a>, <a href="download/raz-0.17.0-linux-x86_64.tar.gz">0.17.0</a>, <a href="download/raz-0.16.0-linux-x86_64.tar.gz">0.16.0</a>, <a href="download/raz-0.15.0-linux-x86_64.tar.gz">0.15.0</a>, <a href="download/raz-0.14.0-linux-x86_64.tar.gz">0.14.0</a>, <a href="download/raz-0.13.0-linux-x86_64.tar.gz">0.13.0</a>, <a href="download/raz-0.12.0-linux-x86_64.tar.gz">0.12.0</a>, <a href="download/raz-0.11.1-linux-x86_64.tar.gz">0.11.1</a>, <a href="download/raz-0.11.0-linux-x86_64.tar.gz">0.11.0</a>, <a href="download/raz-0.10.1-linux-x86_64.tar.gz">0.10.1</a>, <a href="download/raz-0.10.0-linux-x86_64.tar.gz">0.10.0</a>, <a href="download/raz-0.9.1-linux-x86_64.tar.gz">0.9.1</a>, <a href="download/raz-0.9.0-linux-x86_64.tar.gz">0.9.0</a>, <a href="download/raz-0.8.0-linux-x86_64.tar.gz">0.8.0</a>, <a href="download/raz-0.7.1-linux-x86_64.tar.gz">0.7.1</a>; each has its SHA-256 beside it, with
132132 <code>.sha256</code> added to its name.</p>
133-<p class="sha">SHA-256 <code>49fb424ac3b7ee9ed29c87cd9fcb89ed314d2c17ca449077154aa293f2b9ff1c</code></p>
133+<p class="sha">SHA-256 <code>ba019964915644ce6c0efe08258a08dcaf6ee20ce37a32ac2404a587c0b2c387</code></p>
134134
135135 </main>
136136 <footer>raz is under the ISC license.</footer>

site/public/raz-lib.pdf (history) modified

Binary file; the patch has it.

site/public/spec.html (history) modified +3 -1

@@ -869,7 +869,7 @@
869869 </tr>
870870 <tr>
871871 <td><code>Sys</code></td>
872-<td>system calls: <code>open</code>, <code>openMode</code>, <code>openRead</code>, <code>create</code>, <code>read</code>, <code>write</code>, <code>seek</code>, <code>position</code>, <code>truncate</code>, <code>sync</code>, <code>syncAll</code>, <code>lock</code>, <code>close</code>, <code>dup</code>, <code>dupTo</code>, <code>dupAbove</code>, <code>keepOnExec</code>, <code>mmap</code>, <code>munmap</code>, <code>isTerminal</code>, <code>yield</code>, <code>exit</code>; files and directories, <code>rename</code>, <code>remove</code>, <code>removeDir</code>, <code>makeDir</code>, <code>chmod</code>, <code>access</code>, <code>umask</code>, <code>symlink</code>, <code>readLink</code>, <code>info</code>, <code>linkInfo</code>, <code>infoOf</code>, <code>openDir</code>, <code>nextEntry</code>, <code>entryKind</code>, <code>closeDir</code>; the terminal, <code>rawMode</code>, <code>restoreMode</code>, <code>getMode</code>, <code>setMode</code>, <code>termSize</code>, <code>ready</code>; the environment, <code>env</code>, <code>envAt</code>, <code>setEnv</code>, <code>workDir</code>, <code>setWorkDir</code>; programs, <code>spawn</code> and <code>exec</code>, pipes and signals; the user, the machine, time used and limits; time, <code>clock</code>, <code>now</code>, <code>sleep</code>; <code>random</code>; what an errno means, <code>errorText</code>; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and <code>Sys.raz</code> over the C library for the others</td>
872+<td>system calls: <code>open</code>, <code>openMode</code>, <code>openRead</code>, <code>create</code>, <code>read</code>, <code>write</code>, <code>seek</code>, <code>position</code>, <code>truncate</code>, <code>sync</code>, <code>syncAll</code>, <code>lock</code>, <code>close</code>, <code>dup</code>, <code>dupTo</code>, <code>dupAbove</code>, <code>keepOnExec</code>, <code>mmap</code>, <code>munmap</code>, <code>isTerminal</code>, <code>yield</code>, <code>exit</code>; files and directories, <code>rename</code>, <code>remove</code>, <code>removeDir</code>, <code>makeDir</code>, <code>chmod</code>, <code>access</code>, <code>umask</code>, <code>symlink</code>, <code>readLink</code>, <code>info</code>, <code>linkInfo</code>, <code>infoOf</code>, <code>openDir</code>, <code>nextEntry</code>, <code>entryKind</code>, <code>closeDir</code>; the terminal, <code>rawMode</code>, <code>restoreMode</code>, <code>getMode</code>, <code>setMode</code>, <code>termSize</code>, <code>ready</code>; the environment, <code>env</code>, <code>envAt</code>, <code>setEnv</code>, <code>workDir</code>, <code>setWorkDir</code>; programs, <code>spawn</code>, <code>exec</code> and <code>execve</code>, pipes and signals; the user, the machine, time used and limits; time, <code>clock</code>, <code>now</code>, <code>sleep</code>; <code>random</code>; what an errno means, <code>errorText</code>; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and <code>Sys.raz</code> over the C library for the others</td>
873873 </tr>
874874 <tr>
875875 <td><code>Out</code></td>
@@ -1128,6 +1128,7 @@
11281128 proc setTermSize*(fd, cols, rows: INT): INT; (* the size its programs are told of *)
11291129 proc spawn*(p: Program): INT; (* a program started: its process id *)
11301130 proc exec*(p: Program): INT; (* p run in this program&#39;s place; returns only if it can&#39;t *)
1131+proc execve*(path: []U8; args, env: [][]U8): INT; (* as the kernel&#39;s execve: no search *)
11311132 proc fork*: INT; (* this program copied: 0 in the copy, its process id in this one *)
11321133 proc wait*(pid: INT; block: BOOL): (INT, Status, INT); (* which program, how, and its code *)
11331134 proc kill*(pid, signal: INT): INT;
@@ -1178,6 +1179,7 @@
11781179 <p><code>spawn</code> starts the program at <code>p.path</code>, with <code>p.args</code> as its arguments, the first being its name. A <code>p.path</code> without a <code>/</code> is looked for as a shell looks for a command, and as C’s <code>execvp</code> does: in each directory of this program’s <code>PATH</code> in turn, an empty one being the working directory, or of <code>/bin:/usr/bin</code> if <code>PATH</code> is unset or empty; the first that runs is the program. Its environment is this program’s with each <code>NAME=value</code> of <code>p.env</code> added or put in place of the old value, or, if <code>p.onlyEnv</code>, <code>p.env</code> alone. It starts in <code>p.dir</code>. Its standard input, output and error are <code>p.fds</code>; a 0 gives it this program’s own, so <code>{path: "ls", args: ["ls"]}</code> runs <code>ls</code> as a shell runs it, with every other field zero. It gets no other open file but those of <code>p.more</code>, each at its own number, as a shell passes <code>3&lt;file</code> on, every signal does what it does at first, and none is blocked. If <code>p.tty</code> is a pseudo-terminal’s fd, the program starts a session on that terminal: it is its controlling terminal, and its standard input, output and error, and <code>p.fds</code> and <code>p.group</code> are not used.</p>
11791180 <p><code>p.group</code> puts the program in a process group, the programs that a shell’s job is made of: -1 makes it the first of a new group, whose number is its process id, and the other programs of the job join that number. The terminal gives its keys, and the signals of Ctrl-C and Ctrl-Z, to one group, the one in its foreground: <code>p.foreground</code> puts the program’s group there before it starts, and <code>foreground</code> puts any group there, as a shell does to take the terminal back. <code>setGroup</code> moves a program to a group, as the shell does for each program it starts, for whichever of the two runs first; a shell runs in a group of its own, <code>setGroup(0, 0)</code>.</p>
11801181 <p><code>exec</code> runs the program <code>p</code> describes in this program’s place, as a shell’s <code>exec cmd</code> does, found and started as <code>spawn</code> would start it, <code>p.tty</code>, <code>p.group</code>, <code>p.foreground</code>, <code>p.fds</code> and <code>p.dir</code> included, except that it keeps this program’s other open files: each stays open in the program unless <code>keepOnExec(fd, false)</code> was said of it, as it is of <code>pipe</code>’s, and those of <code>p.more</code> are kept. It returns only if the program can’t run: -2 (ENOENT) or -13 (EACCES) if there is none to run, with nothing done; or, if the program is found but won’t start, minus the errno, with what <code>p</code> asks of the terminal, the group, the files and the directory done, and this program’s signals as they were.</p>
1182+<p><code>execve(path, args, env)</code> is the kernel’s execve, for a shell, which has looked for the program along its own <code>PATH</code> and set up the child already: the program at <code>path</code> is run with <code>args</code> and with <code>env</code>, <code>NAME=value</code>, for its whole environment. Nothing is searched for, and every fd and signal stays as it is, but that a handled signal does what it does at first: an ignored one stays ignored, as <code>trap '' HUP</code> wants of the command it comes before. It returns only if it can’t: minus an errno, with nothing changed.</p>
11811183 <p>A shell moves its own files with <code>dup</code> and <code>dupTo</code>, for <code>2&gt;&amp;1</code> and <code>exec &gt;log</code> and around a builtin: <code>dupTo(fd, into)</code> makes <code>into</code> the same open file as <code>fd</code>, closing what <code>into</code> was, and <code>dup</code> gives a new fd for it, the lowest free, as a shell saves a file to give it back. <code>dupAbove(fd, 10)</code> gives one at 10 or above, closed on exec, out of the way of the fds a script names (<code>3&gt;log</code>), as a shell keeps its own. <code>fork</code> copies this program, which goes on from there in both: it is 0 in the copy and the copy’s process id in this one, as a shell runs a builtin or a procedure as a stage of a pipe. Only the thread that calls it is copied, so a program with threads mustn’t; and what <code>Out</code> keeps is copied too, to be written twice, so <code>Out.flush</code> comes first. <code>group</code> is the process group this program is in: a shell starting on a terminal waits until it is <code>foregroundOf(0)</code> before it takes it. <code>access</code> says whether this user, by its real ids, may read, write or execute a file, as <code>test -r</code>, <code>-w</code> and <code>-x</code> ask, which <code>Info.mode</code> alone can’t say; an empty <code>how</code> asks only whether it is there. <code>open</code> refuses <code>executing</code>, with -22 (EINVAL). <code>umask</code> sets the bits taken away from the mode of every file this program, and those it starts, make, and says what they were. <code>envAt</code> gives the environment one variable at a time, from 0, for a shell to list it and to pass it on whole with <code>onlyEnv</code>. <code>setEnv</code> refuses a name that is empty or holds an <code>=</code>, and a 0 in either, with -22; as C’s <code>setenv</code>, it isn’t safe while another thread reads the environment, and what <code>env</code> gave for a variable may be gone once it sets that variable again. <code>getMode</code> reads a terminal’s modes, and <code>setMode</code> sets them again once what was written is sent, so that a shell keeps them for each job: a program stopped by Ctrl-Z with its terminal raw gets it back raw, and the shell its own between. <code>cpuTime</code> says how long the processor ran this program, in its own code and in the system for it, or, if <code>children</code>, the programs it started and has waited for, as <code>time</code> and <code>times</code> say. <code>limit</code> gives a limit, <code>limitFiles</code> say, soft and hard, and <code>setLimit</code> sets them, as <code>ulimit</code> does: a program may raise its soft limit up to the hard one, and lower either. <code>uid</code> is the user this program runs as, <code>euid</code> the one whose rights it has, 0 for root, as a prompt shows <code>#</code>; <code>hostName</code> is the machine’s name.</p>
11821184 <p><code>wait</code> waits for the program <code>pid</code> to change, for any of this program’s if <code>pid</code> is -1, or for any of the group <code>g</code> if <code>pid</code> is <code>-g</code>, as a shell waits for a job’s programs, and says which one, and how: <code>exited</code>, with its exit status; <code>killed</code>, with the number of the signal that ended it; or <code>stopped</code>, by Ctrl-Z or a signal, with the signal’s number. Without <code>block</code> it doesn’t wait, and is 0 and <code>running</code> if no program changed. A program that has nothing to wait for is -10 (ECHILD). <code>kill</code> sends a program a signal, <code>sigTerm</code> to end it; to a group, if <code>pid</code> is minus its number.</p>
11831185 <p><strong>Signals.</strong> <code>catch</code> takes the signals <code>sigs</code> away from what they would do, ending the program most of them, and gives an fd that is ready to read when one comes, so that a program waits for signals with <code>ready</code> and <code>readyOf</code> as it waits for keys or a server. <code>caught</code> gives each signal that came, in turn. A later <code>catch</code> adds to the signals caught and gives the same fd. Catching <code>sigKill</code> or <code>sigStop</code>, or the signals <code>Rt</code> reports, SIGSEGV and SIGFPE, is -22 (EINVAL). <code>ignore</code> makes a signal do nothing, as a shell ignores <code>sigTtou</code> so that it can take its terminal back, and <code>ignore(sig, false)</code> gives it back what it does at first. A program that <code>spawn</code> starts begins with neither.</p>

site/public/tour/hello.html (history) modified +1 -1

@@ -70,7 +70,7 @@
7070 <span class="cmd">$ raz run Quiet.raz</span>
7171 hello, again
7272 <span class="cmd">$ ls -l Quiet | awk &#x27;{print $5, &quot;bytes&quot;}&#x27;</span>
73-28904 bytes</code></pre>
73+28480 bytes</code></pre>
7474 <p>The program is a static executable with no run time besides the code it uses, so it is a few kilobytes, and runs without any library installed.</p>
7575 <h2>What <code>Out</code> can write</h2>
7676 <p><code>Out</code> is the library's buffered output. It writes strings, single characters, numbers in decimal or hexadecimal, and a line feed. A string is written as it is, with <code>\n</code> for a line feed, <code>\t</code> for a tab, <code>\"</code> and <code>\\</code>; or between backquotes, as a raw string with no escapes at all, which may run over lines (lesson 6).</p>