@shd101wyy/yo 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/SKILL.md +4 -4
- package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
- package/.github/skills/yo-project-workflow/SKILL.md +6 -3
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
- package/.github/skills/yo-syntax/SKILL.md +7 -6
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +456 -438
- package/out/cjs/yo-cli.cjs +576 -543
- package/out/cjs/yo-lsp.cjs +559 -532
- package/out/esm/index.mjs +281 -263
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/alg/hash.yo +13 -21
- package/std/allocator.yo +25 -40
- package/std/async.yo +3 -7
- package/std/build.yo +105 -151
- package/std/cli/arg_parser.yo +184 -169
- package/std/collections/array_list.yo +350 -314
- package/std/collections/btree_map.yo +142 -131
- package/std/collections/deque.yo +132 -128
- package/std/collections/hash_map.yo +542 -566
- package/std/collections/hash_set.yo +623 -687
- package/std/collections/linked_list.yo +275 -293
- package/std/collections/ordered_map.yo +113 -85
- package/std/collections/priority_queue.yo +73 -73
- package/std/crypto/md5.yo +191 -95
- package/std/crypto/random.yo +56 -64
- package/std/crypto/sha256.yo +151 -107
- package/std/encoding/base64.yo +87 -81
- package/std/encoding/hex.yo +43 -50
- package/std/encoding/html.yo +56 -81
- package/std/encoding/html_char_utils.yo +7 -13
- package/std/encoding/html_entities.yo +2248 -2253
- package/std/encoding/json.yo +316 -224
- package/std/encoding/punycode.yo +86 -116
- package/std/encoding/toml.yo +67 -66
- package/std/encoding/utf16.yo +37 -44
- package/std/env.yo +62 -91
- package/std/error.yo +7 -15
- package/std/fmt/display.yo +5 -9
- package/std/fmt/index.yo +8 -14
- package/std/fmt/to_string.yo +330 -315
- package/std/fmt/writer.yo +58 -87
- package/std/fs/dir.yo +83 -102
- package/std/fs/file.yo +147 -180
- package/std/fs/metadata.yo +45 -78
- package/std/fs/temp.yo +55 -65
- package/std/fs/types.yo +27 -40
- package/std/fs/walker.yo +53 -68
- package/std/gc.yo +5 -8
- package/std/glob.yo +30 -43
- package/std/http/client.yo +107 -120
- package/std/http/http.yo +106 -96
- package/std/http/index.yo +4 -6
- package/std/imm/list.yo +88 -93
- package/std/imm/map.yo +528 -464
- package/std/imm/set.yo +52 -57
- package/std/imm/sorted_map.yo +340 -286
- package/std/imm/sorted_set.yo +57 -63
- package/std/imm/string.yo +404 -345
- package/std/imm/vec.yo +173 -181
- package/std/io/reader.yo +3 -6
- package/std/io/writer.yo +4 -8
- package/std/libc/assert.yo +5 -9
- package/std/libc/ctype.yo +32 -22
- package/std/libc/dirent.yo +26 -25
- package/std/libc/errno.yo +164 -90
- package/std/libc/fcntl.yo +52 -45
- package/std/libc/float.yo +66 -44
- package/std/libc/limits.yo +42 -33
- package/std/libc/math.yo +53 -82
- package/std/libc/signal.yo +72 -47
- package/std/libc/stdatomic.yo +217 -188
- package/std/libc/stdint.yo +5 -29
- package/std/libc/stdio.yo +5 -29
- package/std/libc/stdlib.yo +32 -39
- package/std/libc/string.yo +5 -23
- package/std/libc/sys/stat.yo +58 -56
- package/std/libc/time.yo +5 -19
- package/std/libc/unistd.yo +5 -20
- package/std/libc/wctype.yo +6 -9
- package/std/libc/windows.yo +26 -30
- package/std/log.yo +41 -55
- package/std/net/addr.yo +102 -97
- package/std/net/dns.yo +27 -28
- package/std/net/errors.yo +50 -49
- package/std/net/tcp.yo +113 -124
- package/std/net/udp.yo +55 -66
- package/std/os/env.yo +35 -33
- package/std/os/signal.yo +15 -25
- package/std/path.yo +276 -311
- package/std/prelude.yo +6304 -4315
- package/std/process/command.yo +87 -103
- package/std/process/index.yo +12 -31
- package/std/regex/compiler.yo +196 -95
- package/std/regex/flags.yo +58 -39
- package/std/regex/index.yo +157 -173
- package/std/regex/match.yo +20 -31
- package/std/regex/node.yo +134 -152
- package/std/regex/parser.yo +283 -259
- package/std/regex/unicode.yo +172 -202
- package/std/regex/vm.yo +155 -171
- package/std/string/index.yo +5 -7
- package/std/string/rune.yo +45 -55
- package/std/string/string.yo +937 -964
- package/std/string/string_builder.yo +94 -104
- package/std/string/unicode.yo +46 -64
- package/std/sync/channel.yo +72 -73
- package/std/sync/cond.yo +31 -36
- package/std/sync/mutex.yo +30 -32
- package/std/sync/once.yo +13 -16
- package/std/sync/rwlock.yo +26 -31
- package/std/sync/waitgroup.yo +20 -25
- package/std/sys/advise.yo +16 -24
- package/std/sys/bufio/buf_reader.yo +77 -93
- package/std/sys/bufio/buf_writer.yo +52 -65
- package/std/sys/clock.yo +4 -9
- package/std/sys/constants.yo +77 -61
- package/std/sys/copy.yo +4 -10
- package/std/sys/dir.yo +26 -43
- package/std/sys/dns.yo +41 -61
- package/std/sys/errors.yo +95 -103
- package/std/sys/events.yo +45 -57
- package/std/sys/externs.yo +319 -267
- package/std/sys/fallocate.yo +7 -11
- package/std/sys/fcntl.yo +14 -22
- package/std/sys/file.yo +26 -40
- package/std/sys/future.yo +5 -8
- package/std/sys/iov.yo +12 -25
- package/std/sys/lock.yo +12 -13
- package/std/sys/mmap.yo +38 -43
- package/std/sys/path.yo +3 -8
- package/std/sys/perm.yo +7 -21
- package/std/sys/pipe.yo +5 -12
- package/std/sys/process.yo +23 -29
- package/std/sys/seek.yo +10 -12
- package/std/sys/signal.yo +7 -13
- package/std/sys/signals.yo +52 -35
- package/std/sys/socket.yo +63 -58
- package/std/sys/socketpair.yo +3 -6
- package/std/sys/sockinfo.yo +11 -20
- package/std/sys/statfs.yo +11 -34
- package/std/sys/statx.yo +25 -52
- package/std/sys/sysinfo.yo +15 -20
- package/std/sys/tcp.yo +62 -92
- package/std/sys/temp.yo +5 -9
- package/std/sys/time.yo +5 -15
- package/std/sys/timer.yo +6 -11
- package/std/sys/tty.yo +10 -18
- package/std/sys/udp.yo +22 -39
- package/std/sys/umask.yo +3 -6
- package/std/sys/unix.yo +33 -52
- package/std/testing/bench.yo +49 -52
- package/std/thread.yo +10 -15
- package/std/time/datetime.yo +105 -89
- package/std/time/duration.yo +43 -56
- package/std/time/instant.yo +13 -18
- package/std/time/sleep.yo +5 -9
- package/std/url/index.yo +184 -209
- package/std/worker.yo +6 -10
package/std/sys/fallocate.yo
CHANGED
|
@@ -2,23 +2,19 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! Synchronous wrapper for `fallocate`-style allocation.
|
|
4
4
|
//! Returns 0 on success, -errno on failure.
|
|
5
|
-
|
|
6
|
-
{ __yo_sync_fallocate } :: import "./externs.yo";
|
|
7
|
-
|
|
5
|
+
{ __yo_sync_fallocate } :: import("./externs.yo");
|
|
8
6
|
// Mode constants
|
|
9
|
-
FALLOC_FL_KEEP_SIZE :: i32(0x01);
|
|
10
|
-
FALLOC_FL_PUNCH_HOLE :: i32(0x02);
|
|
11
|
-
FALLOC_FL_ZERO_RANGE :: i32(0x10);
|
|
12
|
-
|
|
7
|
+
FALLOC_FL_KEEP_SIZE :: i32(0x01); // Do not change file size
|
|
8
|
+
FALLOC_FL_PUNCH_HOLE :: i32(0x02); // Deallocate range (Linux-specific)
|
|
9
|
+
FALLOC_FL_ZERO_RANGE :: i32(0x10); // Zero range (Linux-specific)
|
|
13
10
|
// Pre-allocate disk space for a file range.
|
|
14
11
|
// Ensures writes in [offset, offset + length) have space reserved.
|
|
15
|
-
fallocate :: (fn(fd: i32, mode: i32, offset: i64, length: i64) -> i32)(
|
|
12
|
+
fallocate :: (fn(fd : i32, mode : i32, offset : i64, length : i64) -> i32)(
|
|
16
13
|
__yo_sync_fallocate(fd, mode, offset, length)
|
|
17
14
|
);
|
|
18
|
-
|
|
19
|
-
export
|
|
15
|
+
export(
|
|
20
16
|
fallocate,
|
|
21
17
|
FALLOC_FL_KEEP_SIZE,
|
|
22
18
|
FALLOC_FL_PUNCH_HOLE,
|
|
23
19
|
FALLOC_FL_ZERO_RANGE
|
|
24
|
-
;
|
|
20
|
+
);
|
package/std/sys/fcntl.yo
CHANGED
|
@@ -6,39 +6,31 @@
|
|
|
6
6
|
//!
|
|
7
7
|
//! - `getfl`/`getfd`: flags on success, -errno on failure
|
|
8
8
|
//! - `setfl`/`setfd`: 0 on success, -errno on failure
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
__yo_sync_fcntl_getfl,
|
|
12
|
-
__yo_sync_fcntl_setfl,
|
|
13
|
-
__yo_sync_fcntl_getfd,
|
|
14
|
-
__yo_sync_fcntl_setfd
|
|
15
|
-
} :: import "./externs.yo";
|
|
16
|
-
{ O_NONBLOCK } :: import "./constants.yo";
|
|
17
|
-
|
|
9
|
+
{ __yo_sync_fcntl_getfl, __yo_sync_fcntl_setfl, __yo_sync_fcntl_getfd, __yo_sync_fcntl_setfd } :: import("./externs.yo");
|
|
10
|
+
{ O_NONBLOCK } :: import("./constants.yo");
|
|
18
11
|
// POSIX FD_CLOEXEC value. On Windows this is interpreted by the runtime wrapper.
|
|
19
12
|
FD_CLOEXEC :: i32(1);
|
|
20
|
-
|
|
21
13
|
// Get file status flags (F_GETFL)
|
|
22
|
-
getfl :: (fn(fd: i32) -> i32)(
|
|
14
|
+
getfl :: (fn(fd : i32) -> i32)(
|
|
23
15
|
__yo_sync_fcntl_getfl(fd)
|
|
24
16
|
);
|
|
25
|
-
|
|
26
17
|
// Set file status flags (F_SETFL)
|
|
27
|
-
setfl :: (fn(fd: i32, flags: i32) -> i32)(
|
|
18
|
+
setfl :: (fn(fd : i32, flags : i32) -> i32)(
|
|
28
19
|
__yo_sync_fcntl_setfl(fd, flags)
|
|
29
20
|
);
|
|
30
|
-
|
|
31
21
|
// Get file descriptor flags (F_GETFD)
|
|
32
|
-
getfd :: (fn(fd: i32) -> i32)(
|
|
22
|
+
getfd :: (fn(fd : i32) -> i32)(
|
|
33
23
|
__yo_sync_fcntl_getfd(fd)
|
|
34
24
|
);
|
|
35
|
-
|
|
36
25
|
// Set file descriptor flags (F_SETFD)
|
|
37
|
-
setfd :: (fn(fd: i32, flags: i32) -> i32)(
|
|
26
|
+
setfd :: (fn(fd : i32, flags : i32) -> i32)(
|
|
38
27
|
__yo_sync_fcntl_setfd(fd, flags)
|
|
39
28
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
export(
|
|
30
|
+
getfl,
|
|
31
|
+
setfl,
|
|
32
|
+
getfd,
|
|
33
|
+
setfd,
|
|
34
|
+
O_NONBLOCK,
|
|
35
|
+
FD_CLOEXEC
|
|
36
|
+
);
|
package/std/sys/file.yo
CHANGED
|
@@ -16,91 +16,77 @@
|
|
|
16
16
|
// fd := IOError.from_result(fd_result).unwrap();
|
|
17
17
|
// close_result := await IO.close(fd);
|
|
18
18
|
// };
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
{
|
|
22
|
-
__yo_async_read_start, __yo_async_write_start,
|
|
23
|
-
__yo_async_openat_start, __yo_async_close_start,
|
|
24
|
-
__yo_async_statx_start,
|
|
25
|
-
__yo_async_fsync_start, __yo_async_fdatasync_start,
|
|
26
|
-
__yo_async_ftruncate_start,
|
|
27
|
-
__yo_file_open, __yo_file_close, __yo_file_size
|
|
28
|
-
} :: import "./externs.yo";
|
|
29
|
-
|
|
19
|
+
{ IOFuture } :: import("./future.yo");
|
|
20
|
+
{ __yo_async_read_start, __yo_async_write_start, __yo_async_openat_start, __yo_async_close_start, __yo_async_statx_start, __yo_async_fsync_start, __yo_async_fdatasync_start, __yo_async_ftruncate_start, __yo_file_open, __yo_file_close, __yo_file_size } :: import("./externs.yo");
|
|
30
21
|
// ============================================================================
|
|
31
22
|
// Async File Operations (return IOFuture, use with await)
|
|
32
23
|
// ============================================================================
|
|
33
|
-
|
|
34
24
|
// Open a file relative to dirfd. Use AT_FDCWD for current directory.
|
|
35
25
|
// Returns fd on success, -errno on failure.
|
|
36
|
-
openat :: (fn(dirfd: i32, path: *(u8), flags: i32, mode: i32) -> IOFuture)(
|
|
26
|
+
openat :: (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IOFuture)(
|
|
37
27
|
__yo_async_openat_start(dirfd, path, flags, mode)
|
|
38
28
|
);
|
|
39
|
-
|
|
40
29
|
// Close a file descriptor.
|
|
41
30
|
// Returns 0 on success, -errno on failure.
|
|
42
|
-
close :: (fn(fd: i32) -> IOFuture)(
|
|
31
|
+
close :: (fn(fd : i32) -> IOFuture)(
|
|
43
32
|
__yo_async_close_start(fd)
|
|
44
33
|
);
|
|
45
|
-
|
|
46
34
|
// Read from fd into buffer at the given offset.
|
|
47
35
|
// Returns number of bytes read on success, -errno on failure.
|
|
48
|
-
read :: (fn(fd: i32, buffer: *(u8), size: u32, offset: u64) -> IOFuture)(
|
|
36
|
+
read :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
|
|
49
37
|
__yo_async_read_start(fd, buffer, size, offset)
|
|
50
38
|
);
|
|
51
|
-
|
|
52
39
|
// Write buffer to fd at the given offset.
|
|
53
40
|
// Returns number of bytes written on success, -errno on failure.
|
|
54
|
-
write :: (fn(fd: i32, buffer: *(u8), size: u32, offset: u64) -> IOFuture)(
|
|
41
|
+
write :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
|
|
55
42
|
__yo_async_write_start(fd, buffer, size, offset)
|
|
56
43
|
);
|
|
57
|
-
|
|
58
44
|
// Get file metadata via statx. Results are written to statxbuf.
|
|
59
45
|
// Use Statx object to wrap and read the buffer.
|
|
60
46
|
// Returns 0 on success, -errno on failure.
|
|
61
|
-
statx :: (fn(dirfd: i32, path: *(u8), flags: i32, mask: u32, statxbuf: *(u8)) -> IOFuture)(
|
|
47
|
+
statx :: (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IOFuture)(
|
|
62
48
|
__yo_async_statx_start(dirfd, path, flags, mask, statxbuf)
|
|
63
49
|
);
|
|
64
|
-
|
|
65
50
|
// Sync file data and metadata to disk.
|
|
66
51
|
// Returns 0 on success, -errno on failure.
|
|
67
|
-
fsync :: (fn(fd: i32) -> IOFuture)(
|
|
52
|
+
fsync :: (fn(fd : i32) -> IOFuture)(
|
|
68
53
|
__yo_async_fsync_start(fd)
|
|
69
54
|
);
|
|
70
|
-
|
|
71
55
|
// Sync file data (but not metadata) to disk.
|
|
72
56
|
// Returns 0 on success, -errno on failure.
|
|
73
|
-
fdatasync :: (fn(fd: i32) -> IOFuture)(
|
|
57
|
+
fdatasync :: (fn(fd : i32) -> IOFuture)(
|
|
74
58
|
__yo_async_fdatasync_start(fd)
|
|
75
59
|
);
|
|
76
|
-
|
|
77
60
|
// Truncate file to the given length.
|
|
78
61
|
// Returns 0 on success, -errno on failure.
|
|
79
|
-
ftruncate :: (fn(fd: i32, length: i64) -> IOFuture)(
|
|
62
|
+
ftruncate :: (fn(fd : i32, length : i64) -> IOFuture)(
|
|
80
63
|
__yo_async_ftruncate_start(fd, length)
|
|
81
64
|
);
|
|
82
|
-
|
|
83
65
|
// ============================================================================
|
|
84
66
|
// Sync File Helpers
|
|
85
67
|
// ============================================================================
|
|
86
|
-
|
|
87
68
|
// Open a file synchronously. Returns fd on success, -errno on failure.
|
|
88
|
-
open_sync :: (fn(path: *(u8), flags: i32, mode: i32) -> i32)(
|
|
69
|
+
open_sync :: (fn(path : *(u8), flags : i32, mode : i32) -> i32)(
|
|
89
70
|
__yo_file_open(path, flags, mode)
|
|
90
71
|
);
|
|
91
|
-
|
|
92
72
|
// Close a file descriptor synchronously.
|
|
93
|
-
close_sync :: (fn(fd: i32) -> unit)(
|
|
73
|
+
close_sync :: (fn(fd : i32) -> unit)(
|
|
94
74
|
__yo_file_close(fd)
|
|
95
75
|
);
|
|
96
|
-
|
|
97
76
|
// Get file size synchronously. Returns size on success, -errno on failure.
|
|
98
|
-
file_size :: (fn(fd: i32) -> i64)(
|
|
77
|
+
file_size :: (fn(fd : i32) -> i64)(
|
|
99
78
|
__yo_file_size(fd)
|
|
100
79
|
);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
export(
|
|
81
|
+
openat,
|
|
82
|
+
close,
|
|
83
|
+
read,
|
|
84
|
+
write,
|
|
85
|
+
statx,
|
|
86
|
+
fsync,
|
|
87
|
+
fdatasync,
|
|
88
|
+
ftruncate,
|
|
89
|
+
open_sync,
|
|
90
|
+
close_sync,
|
|
91
|
+
file_size
|
|
92
|
+
);
|
package/std/sys/future.yo
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
//! `IOFuture` type — opaque handle to a C async I/O future struct.
|
|
2
|
-
|
|
3
2
|
// ============================================================================
|
|
4
3
|
// Extern type for I/O Future
|
|
5
4
|
// ============================================================================
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
extern(
|
|
6
|
+
"Yo",
|
|
8
7
|
__yo_io_future_t : Type
|
|
9
|
-
;
|
|
10
|
-
|
|
8
|
+
);
|
|
11
9
|
IOFuture :: Impl(Concrete(__yo_io_future_t), Future(i32));
|
|
12
|
-
|
|
13
|
-
export
|
|
10
|
+
export(
|
|
14
11
|
__yo_io_future_t,
|
|
15
12
|
IOFuture
|
|
16
|
-
;
|
|
13
|
+
);
|
package/std/sys/iov.yo
CHANGED
|
@@ -2,43 +2,30 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! Synchronous wrappers for vectored file descriptor I/O.
|
|
4
4
|
//! Returns byte count on success, -errno / negative platform error on failure.
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
__yo_sync_readv,
|
|
8
|
-
__yo_sync_writev,
|
|
9
|
-
__yo_sync_preadv,
|
|
10
|
-
__yo_sync_pwritev,
|
|
11
|
-
__yo_iovec_size,
|
|
12
|
-
__yo_iovec_set
|
|
13
|
-
} :: import "./externs.yo";
|
|
14
|
-
|
|
5
|
+
{ __yo_sync_readv, __yo_sync_writev, __yo_sync_preadv, __yo_sync_pwritev, __yo_iovec_size, __yo_iovec_set } :: import("./externs.yo");
|
|
15
6
|
iovec_size :: (fn() -> usize)(
|
|
16
7
|
__yo_iovec_size()
|
|
17
8
|
);
|
|
18
|
-
|
|
19
|
-
readv :: (fn(fd: i32, iov: *(u8), iovcnt: i32) -> i32)(
|
|
9
|
+
readv :: (fn(fd : i32, iov : *(u8), iovcnt : i32) -> i32)(
|
|
20
10
|
__yo_sync_readv(fd, iov, iovcnt)
|
|
21
11
|
);
|
|
22
|
-
|
|
23
|
-
writev :: (fn(fd: i32, iov: *(u8), iovcnt: i32) -> i32)(
|
|
12
|
+
writev :: (fn(fd : i32, iov : *(u8), iovcnt : i32) -> i32)(
|
|
24
13
|
__yo_sync_writev(fd, iov, iovcnt)
|
|
25
14
|
);
|
|
26
|
-
|
|
27
|
-
preadv :: (fn(fd: i32, iov: *(u8), iovcnt: i32, offset: i64) -> i32)(
|
|
15
|
+
preadv :: (fn(fd : i32, iov : *(u8), iovcnt : i32, offset : i64) -> i32)(
|
|
28
16
|
__yo_sync_preadv(fd, iov, iovcnt, offset)
|
|
29
17
|
);
|
|
30
|
-
|
|
31
|
-
pwritev :: (fn(fd: i32, iov: *(u8), iovcnt: i32, offset: i64) -> i32)(
|
|
18
|
+
pwritev :: (fn(fd : i32, iov : *(u8), iovcnt : i32, offset : i64) -> i32)(
|
|
32
19
|
__yo_sync_pwritev(fd, iov, iovcnt, offset)
|
|
33
20
|
);
|
|
34
|
-
|
|
35
|
-
iovec_set :: (fn(iov: *(u8), index: usize, base: *(u8), len: usize) -> unit)(
|
|
21
|
+
iovec_set :: (fn(iov : *(u8), index : usize, base : *(u8), len : usize) -> unit)(
|
|
36
22
|
__yo_iovec_set(iov, index, base, len)
|
|
37
23
|
);
|
|
38
|
-
|
|
39
|
-
export
|
|
24
|
+
export(
|
|
40
25
|
iovec_size,
|
|
41
|
-
readv,
|
|
42
|
-
|
|
26
|
+
readv,
|
|
27
|
+
writev,
|
|
28
|
+
preadv,
|
|
29
|
+
pwritev,
|
|
43
30
|
iovec_set
|
|
44
|
-
;
|
|
31
|
+
);
|
package/std/sys/lock.yo
CHANGED
|
@@ -5,22 +5,21 @@
|
|
|
5
5
|
//!
|
|
6
6
|
//! Operations can be OR'd with `LOCK_NB` for non-blocking.
|
|
7
7
|
//! `LOCK_NB` returns -EWOULDBLOCK (-11) if the lock cannot be acquired immediately.
|
|
8
|
-
|
|
9
|
-
{ __yo_sync_flock } :: import "./externs.yo";
|
|
10
|
-
|
|
8
|
+
{ __yo_sync_flock } :: import("./externs.yo");
|
|
11
9
|
// Lock operation constants
|
|
12
|
-
LOCK_SH :: i32(1);
|
|
13
|
-
LOCK_EX :: i32(2);
|
|
14
|
-
LOCK_NB :: i32(4);
|
|
15
|
-
LOCK_UN :: i32(8);
|
|
16
|
-
|
|
10
|
+
LOCK_SH :: i32(1); // Shared (read) lock
|
|
11
|
+
LOCK_EX :: i32(2); // Exclusive (write) lock
|
|
12
|
+
LOCK_NB :: i32(4); // Non-blocking (OR with LOCK_SH or LOCK_EX)
|
|
13
|
+
LOCK_UN :: i32(8); // Unlock
|
|
17
14
|
// Acquire or release an advisory lock on a file descriptor.
|
|
18
15
|
// Returns 0 on success, -errno on failure.
|
|
19
|
-
flock :: (fn(fd: i32, operation: i32) -> i32)(
|
|
16
|
+
flock :: (fn(fd : i32, operation : i32) -> i32)(
|
|
20
17
|
__yo_sync_flock(fd, operation)
|
|
21
18
|
);
|
|
22
|
-
|
|
23
|
-
export
|
|
19
|
+
export(
|
|
24
20
|
flock,
|
|
25
|
-
LOCK_SH,
|
|
26
|
-
|
|
21
|
+
LOCK_SH,
|
|
22
|
+
LOCK_EX,
|
|
23
|
+
LOCK_NB,
|
|
24
|
+
LOCK_UN
|
|
25
|
+
);
|
package/std/sys/mmap.yo
CHANGED
|
@@ -6,23 +6,13 @@
|
|
|
6
6
|
//! - Mapped pointer on success
|
|
7
7
|
//! - Encoded error pointer on failure (negative errno cast to pointer)
|
|
8
8
|
// Use is_error(ptr) and error_code(ptr) to detect/decode mmap failures.
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
{
|
|
12
|
-
__yo_sync_mmap,
|
|
13
|
-
__yo_sync_mmap_is_error,
|
|
14
|
-
__yo_sync_mmap_errno,
|
|
15
|
-
__yo_sync_munmap,
|
|
16
|
-
__yo_sync_mprotect,
|
|
17
|
-
__yo_sync_msync
|
|
18
|
-
} :: import "./externs.yo";
|
|
19
|
-
|
|
9
|
+
{ platform, Platform } :: import("../process");
|
|
10
|
+
{ __yo_sync_mmap, __yo_sync_mmap_is_error, __yo_sync_mmap_errno, __yo_sync_munmap, __yo_sync_mprotect, __yo_sync_msync } :: import("./externs.yo");
|
|
20
11
|
// Protection constants
|
|
21
|
-
PROT_NONE
|
|
22
|
-
PROT_READ
|
|
12
|
+
PROT_NONE :: i32(0);
|
|
13
|
+
PROT_READ :: i32(1);
|
|
23
14
|
PROT_WRITE :: i32(2);
|
|
24
|
-
PROT_EXEC
|
|
25
|
-
|
|
15
|
+
PROT_EXEC :: i32(4);
|
|
26
16
|
// Mapping flags
|
|
27
17
|
MAP_SHARED :: i32(1);
|
|
28
18
|
MAP_PRIVATE :: i32(2);
|
|
@@ -30,7 +20,6 @@ MAP_ANONYMOUS :: cond(
|
|
|
30
20
|
(platform == Platform.Macos) => i32(0x1000),
|
|
31
21
|
true => i32(0x20)
|
|
32
22
|
);
|
|
33
|
-
|
|
34
23
|
// msync flags
|
|
35
24
|
MS_ASYNC :: i32(1);
|
|
36
25
|
MS_INVALIDATE :: i32(2);
|
|
@@ -38,53 +27,59 @@ MS_SYNC :: cond(
|
|
|
38
27
|
(platform == Platform.Macos) => i32(0x10),
|
|
39
28
|
true => i32(4)
|
|
40
29
|
);
|
|
41
|
-
|
|
42
30
|
// Map a file or anonymous memory region.
|
|
43
31
|
// For anonymous mappings, pass flags including MAP_ANONYMOUS and fd = -1.
|
|
44
|
-
mmap :: (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
mmap :: (
|
|
33
|
+
fn(
|
|
34
|
+
addr : ?*(u8),
|
|
35
|
+
length : usize,
|
|
36
|
+
prot : i32,
|
|
37
|
+
flags : i32,
|
|
38
|
+
fd : i32,
|
|
39
|
+
offset : i64
|
|
40
|
+
) -> ?*(u8)
|
|
41
|
+
)(
|
|
52
42
|
__yo_sync_mmap(addr, length, prot, flags, fd, offset)
|
|
53
43
|
);
|
|
54
|
-
|
|
55
44
|
// Returns true if mmap returned an encoded error pointer.
|
|
56
|
-
is_error :: (fn(addr: ?*(u8)) -> bool)(
|
|
45
|
+
is_error :: (fn(addr : ?*(u8)) -> bool)(
|
|
57
46
|
__yo_sync_mmap_is_error(addr)
|
|
58
47
|
);
|
|
59
|
-
|
|
60
48
|
// Decode errno from an encoded mmap error pointer.
|
|
61
49
|
// Returns 0 if addr is not an encoded error pointer.
|
|
62
|
-
error_code :: (fn(addr: ?*(u8)) -> i32)(
|
|
50
|
+
error_code :: (fn(addr : ?*(u8)) -> i32)(
|
|
63
51
|
__yo_sync_mmap_errno(addr)
|
|
64
52
|
);
|
|
65
|
-
|
|
66
53
|
// Unmap a previously mapped region.
|
|
67
54
|
// Returns 0 on success, -errno on failure.
|
|
68
|
-
munmap :: (fn(addr: *(u8), length: usize) -> i32)(
|
|
55
|
+
munmap :: (fn(addr : *(u8), length : usize) -> i32)(
|
|
69
56
|
__yo_sync_munmap(addr, length)
|
|
70
57
|
);
|
|
71
|
-
|
|
72
58
|
// Change memory protection on a mapped region.
|
|
73
59
|
// Returns 0 on success, -errno on failure.
|
|
74
|
-
mprotect :: (fn(addr: *(u8), length: usize, prot: i32) -> i32)(
|
|
60
|
+
mprotect :: (fn(addr : *(u8), length : usize, prot : i32) -> i32)(
|
|
75
61
|
__yo_sync_mprotect(addr, length, prot)
|
|
76
62
|
);
|
|
77
|
-
|
|
78
63
|
// Flush mapped pages to storage.
|
|
79
64
|
// Returns 0 on success, -errno on failure.
|
|
80
|
-
msync :: (fn(addr: *(u8), length: usize, flags: i32) -> i32)(
|
|
65
|
+
msync :: (fn(addr : *(u8), length : usize, flags : i32) -> i32)(
|
|
81
66
|
__yo_sync_msync(addr, length, flags)
|
|
82
67
|
);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
68
|
+
export(
|
|
69
|
+
mmap,
|
|
70
|
+
is_error,
|
|
71
|
+
error_code,
|
|
72
|
+
munmap,
|
|
73
|
+
mprotect,
|
|
74
|
+
msync,
|
|
75
|
+
PROT_NONE,
|
|
76
|
+
PROT_READ,
|
|
77
|
+
PROT_WRITE,
|
|
78
|
+
PROT_EXEC,
|
|
79
|
+
MAP_SHARED,
|
|
80
|
+
MAP_PRIVATE,
|
|
81
|
+
MAP_ANONYMOUS,
|
|
82
|
+
MS_ASYNC,
|
|
83
|
+
MS_INVALIDATE,
|
|
84
|
+
MS_SYNC
|
|
85
|
+
);
|
package/std/sys/path.yo
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! Synchronous wrapper for `realpath`.
|
|
4
4
|
//! Returns 0 on success, -errno on failure.
|
|
5
|
-
|
|
6
|
-
{ __yo_sync_realpath } :: import "./externs.yo";
|
|
7
|
-
|
|
5
|
+
{ __yo_sync_realpath } :: import("./externs.yo");
|
|
8
6
|
// Resolve a path to its canonical absolute form (resolves symlinks, . and ..).
|
|
9
7
|
// Writes result to `resolved` buffer (must be at least PATH_MAX bytes).
|
|
10
8
|
// Returns 0 on success, -errno on failure.
|
|
11
|
-
realpath :: (fn(path: *(u8), resolved: *(u8)) -> i32)(
|
|
9
|
+
realpath :: (fn(path : *(u8), resolved : *(u8)) -> i32)(
|
|
12
10
|
__yo_sync_realpath(path, resolved)
|
|
13
11
|
);
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
realpath
|
|
17
|
-
;
|
|
12
|
+
export(realpath);
|
package/std/sys/perm.yo
CHANGED
|
@@ -18,61 +18,47 @@
|
|
|
18
18
|
// // Change file permissions to 0644
|
|
19
19
|
// ret2 := perm.chmodat(AT_FDCWD, *(u8)("/tmp/test.txt"), u32(0o644), i32(0));
|
|
20
20
|
// assert(ret2 == i32(0));
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
__yo_sync_access,
|
|
24
|
-
__yo_sync_fchmod, __yo_sync_fchmodat,
|
|
25
|
-
__yo_sync_fchown, __yo_sync_fchownat
|
|
26
|
-
} :: import "./externs.yo";
|
|
27
|
-
|
|
21
|
+
{ __yo_sync_access, __yo_sync_fchmod, __yo_sync_fchmodat, __yo_sync_fchown, __yo_sync_fchownat } :: import("./externs.yo");
|
|
28
22
|
// ============================================================================
|
|
29
23
|
// chmod — Change file permissions
|
|
30
24
|
// ============================================================================
|
|
31
|
-
|
|
32
25
|
// Change file permissions by fd.
|
|
33
26
|
// Returns 0 on success, -errno on failure.
|
|
34
|
-
fchmod :: (fn(fd: i32, mode: u32) -> i32)(
|
|
27
|
+
fchmod :: (fn(fd : i32, mode : u32) -> i32)(
|
|
35
28
|
__yo_sync_fchmod(fd, mode)
|
|
36
29
|
);
|
|
37
|
-
|
|
38
30
|
// Change file permissions by path relative to dirfd.
|
|
39
31
|
// Use AT_FDCWD for current directory.
|
|
40
32
|
// flags: 0 or AT_SYMLINK_NOFOLLOW
|
|
41
33
|
// Returns 0 on success, -errno on failure.
|
|
42
|
-
chmodat :: (fn(dirfd: i32, path: *(u8), mode: u32, flags: i32) -> i32)(
|
|
34
|
+
chmodat :: (fn(dirfd : i32, path : *(u8), mode : u32, flags : i32) -> i32)(
|
|
43
35
|
__yo_sync_fchmodat(dirfd, path, mode, flags)
|
|
44
36
|
);
|
|
45
|
-
|
|
46
37
|
// ============================================================================
|
|
47
38
|
// chown — Change file ownership
|
|
48
39
|
// ============================================================================
|
|
49
|
-
|
|
50
40
|
// Change file ownership by fd.
|
|
51
41
|
// Returns 0 on success, -errno on failure.
|
|
52
|
-
fchown :: (fn(fd: i32, uid: u32, gid: u32) -> i32)(
|
|
42
|
+
fchown :: (fn(fd : i32, uid : u32, gid : u32) -> i32)(
|
|
53
43
|
__yo_sync_fchown(fd, uid, gid)
|
|
54
44
|
);
|
|
55
|
-
|
|
56
45
|
// Change file ownership by path relative to dirfd.
|
|
57
46
|
// Use AT_FDCWD for current directory.
|
|
58
47
|
// flags: 0 or AT_SYMLINK_NOFOLLOW
|
|
59
48
|
// Returns 0 on success, -errno on failure.
|
|
60
|
-
chownat :: (fn(dirfd: i32, path: *(u8), uid: u32, gid: u32, flags: i32) -> i32)(
|
|
49
|
+
chownat :: (fn(dirfd : i32, path : *(u8), uid : u32, gid : u32, flags : i32) -> i32)(
|
|
61
50
|
__yo_sync_fchownat(dirfd, path, uid, gid, flags)
|
|
62
51
|
);
|
|
63
|
-
|
|
64
52
|
// ============================================================================
|
|
65
53
|
// access — Check file accessibility
|
|
66
54
|
// ============================================================================
|
|
67
|
-
|
|
68
55
|
// Check if file is accessible with given mode.
|
|
69
56
|
// dirfd: AT_FDCWD for current directory, or an open directory fd
|
|
70
57
|
// path: file path (relative to dirfd)
|
|
71
58
|
// mode: F_OK (exists), R_OK (readable), W_OK (writable), X_OK (executable)
|
|
72
59
|
// Combine with bitwise OR: (R_OK | W_OK)
|
|
73
60
|
// Returns 0 on success, -errno on failure (e.g. -ENOENT, -EACCES).
|
|
74
|
-
access :: (fn(dirfd: i32, path: *(u8), mode: i32) -> i32)(
|
|
61
|
+
access :: (fn(dirfd : i32, path : *(u8), mode : i32) -> i32)(
|
|
75
62
|
__yo_sync_access(dirfd, path, mode)
|
|
76
63
|
);
|
|
77
|
-
|
|
78
|
-
export fchmod, chmodat, fchown, chownat, access;
|
|
64
|
+
export(fchmod, chmodat, fchown, chownat, access);
|
package/std/sys/pipe.yo
CHANGED
|
@@ -7,25 +7,18 @@
|
|
|
7
7
|
//!
|
|
8
8
|
//! - `pipe`: 0 on success, -errno on failure
|
|
9
9
|
//! - `dup`/`dup2`: new fd on success, -errno on failure
|
|
10
|
-
|
|
11
|
-
{ __yo_sync_pipe, __yo_sync_dup, __yo_sync_dup2 } :: import "./externs.yo";
|
|
12
|
-
|
|
10
|
+
{ __yo_sync_pipe, __yo_sync_dup, __yo_sync_dup2 } :: import("./externs.yo");
|
|
13
11
|
// Create a pipe pair (pipefd[0] = read, pipefd[1] = write).
|
|
14
12
|
// Returns 0 on success, -errno on failure.
|
|
15
|
-
pipe :: (fn(pipefd: *(i32)) -> i32)(
|
|
13
|
+
pipe :: (fn(pipefd : *(i32)) -> i32)(
|
|
16
14
|
__yo_sync_pipe(pipefd)
|
|
17
15
|
);
|
|
18
|
-
|
|
19
16
|
// Duplicate a file descriptor. Returns new fd on success, -errno on failure.
|
|
20
|
-
dup :: (fn(fd: i32) -> i32)(
|
|
17
|
+
dup :: (fn(fd : i32) -> i32)(
|
|
21
18
|
__yo_sync_dup(fd)
|
|
22
19
|
);
|
|
23
|
-
|
|
24
20
|
// Duplicate a file descriptor to a specific fd. Returns new fd on success, -errno on failure.
|
|
25
|
-
dup2 :: (fn(oldfd: i32, newfd: i32) -> i32)(
|
|
21
|
+
dup2 :: (fn(oldfd : i32, newfd : i32) -> i32)(
|
|
26
22
|
__yo_sync_dup2(oldfd, newfd)
|
|
27
23
|
);
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
pipe, dup, dup2
|
|
31
|
-
;
|
|
24
|
+
export(pipe, dup, dup2);
|
package/std/sys/process.yo
CHANGED
|
@@ -7,53 +7,47 @@
|
|
|
7
7
|
//!
|
|
8
8
|
//! `argv`/`envp` are NULL-terminated arrays of C strings.
|
|
9
9
|
// Use `?*(u8)` for entries so .None can be used as the terminator.
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
{
|
|
13
|
-
__yo_async_spawn_start, __yo_async_waitpid_start,
|
|
14
|
-
__yo_process_exit_status, __yo_process_term_signal,
|
|
15
|
-
__yo_kill
|
|
16
|
-
} :: import "./externs.yo";
|
|
17
|
-
|
|
10
|
+
{ IOFuture } :: import("./future.yo");
|
|
11
|
+
{ __yo_async_spawn_start, __yo_async_waitpid_start, __yo_process_exit_status, __yo_process_term_signal, __yo_kill } :: import("./externs.yo");
|
|
18
12
|
// Spawn a child process.
|
|
19
13
|
// Returns the child pid on success, -errno on failure.
|
|
20
14
|
// `argv` is a NULL-terminated array of argument strings.
|
|
21
15
|
// `envp` is a NULL-terminated array of "KEY=VALUE" strings (or .None for inherit).
|
|
22
16
|
// stdin_fd/stdout_fd/stderr_fd: fd redirections (-1 = inherit)
|
|
23
|
-
spawn :: (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
spawn :: (
|
|
18
|
+
fn(
|
|
19
|
+
file : *(u8),
|
|
20
|
+
argv : *(?*(u8)),
|
|
21
|
+
envp : ?*(?*(u8)),
|
|
22
|
+
stdin_fd : i32,
|
|
23
|
+
stdout_fd : i32,
|
|
24
|
+
stderr_fd : i32
|
|
25
|
+
) -> IOFuture
|
|
26
|
+
)(
|
|
31
27
|
__yo_async_spawn_start(file, argv, envp, stdin_fd, stdout_fd, stderr_fd)
|
|
32
28
|
);
|
|
33
|
-
|
|
34
29
|
// Wait for a child process to exit.
|
|
35
30
|
// Returns the exit status (encoded; use exit_status/term_signal helpers).
|
|
36
|
-
waitpid :: (fn(pid: i32, options: i32) -> IOFuture)(
|
|
31
|
+
waitpid :: (fn(pid : i32, options : i32) -> IOFuture)(
|
|
37
32
|
__yo_async_waitpid_start(pid, options)
|
|
38
33
|
);
|
|
39
|
-
|
|
40
34
|
// Send a signal to a process.
|
|
41
35
|
// Returns 0 on success, -errno on failure.
|
|
42
|
-
kill :: (fn(pid: i32, signum: i32) -> i32)(
|
|
36
|
+
kill :: (fn(pid : i32, signum : i32) -> i32)(
|
|
43
37
|
__yo_kill(pid, signum)
|
|
44
38
|
);
|
|
45
|
-
|
|
46
39
|
// Helper: extract exit code from waitpid status.
|
|
47
|
-
exit_status :: (fn(status: i32) -> i32)(
|
|
40
|
+
exit_status :: (fn(status : i32) -> i32)(
|
|
48
41
|
__yo_process_exit_status(status)
|
|
49
42
|
);
|
|
50
|
-
|
|
51
43
|
// Helper: check if process was terminated by signal.
|
|
52
|
-
term_signal :: (fn(status: i32) -> i32)(
|
|
44
|
+
term_signal :: (fn(status : i32) -> i32)(
|
|
53
45
|
__yo_process_term_signal(status)
|
|
54
46
|
);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
export(
|
|
48
|
+
spawn,
|
|
49
|
+
waitpid,
|
|
50
|
+
kill,
|
|
51
|
+
exit_status,
|
|
52
|
+
term_signal
|
|
53
|
+
);
|
package/std/sys/seek.yo
CHANGED
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! Synchronous wrapper for `lseek`.
|
|
4
4
|
//! Returns resulting absolute file offset on success, -errno on failure.
|
|
5
|
-
|
|
6
|
-
{ __yo_sync_lseek } :: import "./externs.yo";
|
|
7
|
-
|
|
5
|
+
{ __yo_sync_lseek } :: import("./externs.yo");
|
|
8
6
|
// Whence constants
|
|
9
|
-
SEEK_SET :: i32(0);
|
|
10
|
-
SEEK_CUR :: i32(1);
|
|
11
|
-
SEEK_END :: i32(2);
|
|
12
|
-
|
|
7
|
+
SEEK_SET :: i32(0); // Set offset to absolute position
|
|
8
|
+
SEEK_CUR :: i32(1); // Set offset relative to current position
|
|
9
|
+
SEEK_END :: i32(2); // Set offset relative to end of file
|
|
13
10
|
// Reposition read/write file offset.
|
|
14
11
|
// Returns resulting offset from file start, or -errno on failure.
|
|
15
|
-
lseek :: (fn(fd: i32, offset: i64, whence: i32) -> i64)(
|
|
12
|
+
lseek :: (fn(fd : i32, offset : i64, whence : i32) -> i64)(
|
|
16
13
|
__yo_sync_lseek(fd, offset, whence)
|
|
17
14
|
);
|
|
18
|
-
|
|
19
|
-
export
|
|
15
|
+
export(
|
|
20
16
|
lseek,
|
|
21
|
-
SEEK_SET,
|
|
22
|
-
|
|
17
|
+
SEEK_SET,
|
|
18
|
+
SEEK_CUR,
|
|
19
|
+
SEEK_END
|
|
20
|
+
);
|