Sys.syncAll over C asks whether fd is open; test/libc with -Werror The mend met in rless: the C Sys's syncAll never used fd, so a program over it failed with -Werror. Naming it _fd, as the proposal had it, can't be done while the seed builds src: the seed's interface check counts a parameter's name, though 5.9 says a signature doesn't. So syncAll asks fcntl(F_GETFD) whether fd is open first, and gives -9 (EBADF) for one that isn't, as Linux's syncfs does; each Sys's test says so. test/check.sh now builds test/libc with -Werror, so a warning in the C Sys fails make check.
| @@ -42,8 +42,8 @@ | ||
| 42 | 42 | one. `test/msg` holds this compiler's `X.stderr` and `X.err` for the |
| 43 | 43 | programs in `conform/`. |
| 44 | 44 | `test/pretty/X.raz` must format to `X.expect`. Examples in `examples/` |
| 45 | -work the same way, compiled with `-Werror`, as are the tools and the | |
| 46 | -library's tests: they must have no warnings. | |
| 45 | +work the same way, compiled with `-Werror`, as are `test/libc`, the | |
| 46 | +tools and the library's tests: they must have no warnings. | |
| 47 | 47 | |
| 48 | 48 | ## How we work |
| 49 | 49 |
| @@ -491,29 +491,6 @@ | ||
| 491 | 491 | breaks a `match` on `Status` that names all four, so it is left out: |
| 492 | 492 | the shell knows when it continues a job itself. |
| 493 | 493 | |
| 494 | -## `Sys.syncAll`'s unused parameter, in the C `Sys` | |
| 495 | - | |
| 496 | -`lib/Sys.raz`, the `Sys` over the C library, has `syncAll(fd)` call | |
| 497 | -C's `sync`, which takes no file and flushes every file system; so `fd` | |
| 498 | -is never used, and a program built over it with `-Werror` fails: | |
| 499 | - | |
| 500 | -``` | |
| 501 | -lib/Sys.raz:249:15: error: parameter fd is never used | |
| 502 | -``` | |
| 503 | - | |
| 504 | -Linux's `Sys` uses `fd` (`syncfs`), so only the C one warns, and only | |
| 505 | -for a program that imports `Sys`, which is most. raz's own checks | |
| 506 | -build `test/libc` without `-Werror`, so they don't see it. | |
| 507 | - | |
| 508 | -The proposal: call the parameter `_fd` in `lib/Sys.raz`, as the | |
| 509 | -warning says. A parameter's name isn't part of the signature (5.9), | |
| 510 | -so the interface check between the two files still holds, and no | |
| 511 | -program changes. It is a mend of the library, not a wish: it could | |
| 512 | -come with any release. | |
| 513 | - | |
| 514 | -Met in rless, whose `make rless-c` builds over the C `Sys` without | |
| 515 | -`-Werror` for this alone. | |
| 516 | - | |
| 517 | 494 | ## `Map.done` |
| 518 | 495 | |
| 519 | 496 | `Map` takes memory from its allocator as it grows and frees the old |
| @@ -1472,6 +1472,7 @@ | ||
| 1472 | 1472 | m := INT(i.ino); |
| 1473 | 1473 | i, err := info("/tmp/raz-sys-dir/h"); |
| 1474 | 1474 | if (err # 0) or (INT(i.ino) # m) or (syncAll(fd) # 0) then exit(2); end; |
| 1475 | + if syncAll(-1) # -9 then exit(2); end; (* EBADF *) | |
| 1475 | 1476 | (* the lock: one open file holds it, another can't take it until |
| 1476 | 1477 | the first is closed *) |
| 1477 | 1478 | k := openRead("/tmp/raz-sys-dir/h"); |
| @@ -254,9 +254,12 @@ | ||
| 254 | 254 | |
| 255 | 255 | (* Returns once everything written to the file system that holds fd |
| 256 | 256 | is on the disk: 0, or minus an errno. POSIX has no call for one file |
| 257 | - system, so it is sync's, which flushes them all and does no less. *) | |
| 257 | + system, so it is sync's, which flushes them all and does no less; | |
| 258 | + fd is still asked whether it is open, for the -9 (EBADF) Linux's | |
| 259 | + syncfs gives one that isn't. *) | |
| 258 | 260 | proc syncAll*(fd: INT): INT; |
| 259 | 261 | begin |
| 262 | + if C.fcntl(I32(fd), 1, 0) < 0 then return failed(); end; (* F_GETFD *) | |
| 260 | 263 | C.sync; |
| 261 | 264 | return 0; |
| 262 | 265 | end; |
| @@ -1455,6 +1458,7 @@ | ||
| 1455 | 1458 | m := INT(i.ino); |
| 1456 | 1459 | i, err := info("/tmp/raz-sys-dir/h"); |
| 1457 | 1460 | if (err # 0) or (INT(i.ino) # m) or (syncAll(fd) # 0) then exit(2); end; |
| 1461 | + if syncAll(-1) # -9 then exit(2); end; (* EBADF *) | |
| 1458 | 1462 | (* the lock: one open file holds it, another can't take it until |
| 1459 | 1463 | the first is closed *) |
| 1460 | 1464 | k := openRead("/tmp/raz-sys-dir/h"); |
| @@ -13,10 +13,10 @@ | ||
| 13 | 13 | # A program without X.expect is compiled, not run. test/libc puts |
| 14 | 14 | # lib/Sys.raz, over the C library, before the system call one. |
| 15 | 15 | # Programs in test/err must not compile, and must print X.err; there |
| 16 | -# X.args holds the compiler's options. The examples, the tools and the | |
| 17 | -# library's tests are compiled with -Werror, so warnings fail them. Then | |
| 18 | -# the version, tools/Doc.raz, the report's examples, the tutorial's, | |
| 19 | -# tools/Pretty.raz, and the library's own tests. | |
| 16 | +# X.args holds the compiler's options. The examples, test/libc, the | |
| 17 | +# tools and the library's tests are compiled with -Werror, so warnings | |
| 18 | +# fail them. Then the version, tools/Doc.raz, the report's examples, | |
| 19 | +# the tutorial's, tools/Pretty.raz, and the library's own tests. | |
| 20 | 20 | |
| 21 | 21 | raz=./raz |
| 22 | 22 | out=build/check |
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | run() { # run dir name |
| 35 | 35 | dir=$1; name=$2 |
| 36 | 36 | flags= |
| 37 | - [ $dir = examples ] && flags=-Werror | |
| 37 | + [ $dir = examples ] || [ $dir = test/libc ] && flags=-Werror | |
| 38 | 38 | if ! $raz $flags -I $dir/mods -o $out/$name $dir/$name.raz 2>$out/$name.cerr; then |
| 39 | 39 | echo "FAIL $dir/$name: doesn't compile: $(cat $out/$name.cerr)" |
| 40 | 40 | fail=$((fail + 1)); return |