1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
use fmt;
use os;
use io;
use fs;
use errors;
use drawing::{pos};
// type chunk = struct {
// fd: io::file,
// d: []u32,
// };
// def CHUNKSIZE: size = 512;
// def CHUNK_LENGTH: size = CHUNKSIZE*CHUNKSIZE*size(u32);
// fn open_chunk_file(chunkpos: pos) (chunk | fs::error) = {
// const path = fmt::asprintf("c.{}.{}.dat", chunkpos.0, chunkpos.1);
// defer free(path);
// const fd = fs::create_file(os::cwd, path,
// fs::mode::USER_RW | fs::mode::GROUP_RW,
// fs::flag::RDWR)?;
// io::trunc(fd, CHUNK_LENGTH)?;
// const dp = io::mmap(null, CHUNK_LENGTH,
// io::prot::READ | io::prot::WRITE,
// io::mflag::SHARED,
// fd, 0)?;
// const d = (dp: *[*]u32)[..CHUNKSIZE*CHUNKSIZE];
// return chunk { fd = fd, d = d };
// };
export fn main() void = {
// match (open_chunk_file((-3,12))) {
// case let e: fs::error =>
// fmt::fatal(fs::strerror(e));
// case let ch: chunk =>
// ch.d[0] = 0x12345678;
// ch.d[CHUNKSIZE*CHUNKSIZE - 1]=0xdeadbeef;
// };
const t = test2 { a=4, b=5 };
thethe(&t);
};
|