4563 Commits

Author SHA1 Message Date
Ominitay
796687f156 Add chmod and chown 2021-11-15 20:04:55 -05:00
Lewis Gaul
dfd604834b Fix copy-paste error that results in incorrect results from exp64() 2021-11-15 19:40:03 -05:00
Chris Heyes
5d2a77cd9a
Json Stringify option to not write out null optional fields (#8979) 2021-11-15 18:56:51 -05:00
lucky
590880158a
update docs (#10150)
add fast kdf test
fix inconsistent kdf error
refactor

Co-authored-by: lucky <>
2021-11-15 20:48:24 +01:00
Gregory Anders
b26b72f540 BoundedArray: add appendAssumeCapacity 2021-11-14 22:52:01 -05:00
Andrew Kelley
46af3a320c
Merge pull request #10081 from hnakamur/lib_std_os_linux_io_uring_cancel
std.os.linux: Add cancel and io_uring_prep_cancel
2021-11-14 22:51:11 -05:00
lucky
c61fbe77c8
add argon2 kdf (#9756) 2021-11-15 04:47:57 +01:00
Kenta Iwasaki
09c17acf02 io_uring: add poll_update
Add method from liburing to queue (but not submit) a SQE to update the
user data of an existing poll operation.
2021-11-14 13:56:41 -05:00
Hiroaki Nakamura
77d1d5839a Use io_uring_prep_rw in io_uring_prep_cancel
follow liburing's API as closely as possible.

Signed-off-by: Hiroaki Nakamura <hnakamur@gmail.com>
2021-11-12 10:51:49 +09:00
Hiroaki Nakamura
2a54c2ff19 std.os.linux: Add cancel and io_uring_prep_cancel
Signed-off-by: Hiroaki Nakamura <hnakamur@gmail.com>
2021-11-12 10:51:49 +09:00
Jakub Konka
19e5663869
Merge pull request #9935 from g-w1/plan9-std
add plan9 support to std
2021-11-11 10:45:00 -08:00
Andrew Kelley
e5bc092408
Merge pull request #10058 from marler8997/builderPathJoin
add pathJoin to builder
2021-11-10 12:40:15 -05:00
Andrew Kelley
b521510cd4
Merge pull request #9853 from koachan/sparc64-unittests
SPARCv9: make more tests pass
2021-11-10 11:32:10 -05:00
Andrew Kelley
008b0ec5e5 std.Thread.Mutex: change API to lock() and unlock()
This is a breaking change. Before, usage looked like this:

```zig
const held = mutex.acquire();
defer held.release();
```

Now it looks like this:

```zig
mutex.lock();
defer mutex.unlock();
```

The `Held` type was an idea to make mutexes slightly safer by making it
more difficult to forget to release an aquired lock. However, this
ultimately caused more problems than it solved, when any data structures
needed to store a held mutex. Simplify everything by reducing the API
down to the primitives: lock() and unlock().

Closes #8051
Closes #8246
Closes #10105
2021-11-09 18:31:03 -07:00
Andrew Kelley
65e518e8e8 io_uring: skip statx test failure on older kernels 2021-11-09 18:31:03 -07:00
Andrew Kelley
d2cdfb9490 stage2: add 4 new linker flags for WebAssembly
--import-memory          import memory from the environment
--initial-memory=[bytes] initial size of the linear memory
--max-memory=[bytes]     maximum size of the linear memory
--global-base=[addr]     where to start to place global data

See #8633
2021-11-09 14:29:20 -07:00
Jonathan Marler
c13166ee85 Omit array type for pathJoin calls 2021-11-09 14:20:28 -07:00
Jonathan Marler
cebac8c662 add pathJoin to builder 2021-11-09 14:20:28 -07:00
Silver
9bb7ff68cc std: Publicize Allocator.reallocBytes
This is useful when dealing with runtime-known alignments, eg. interfacing
with C code that accepts custom allocation callbacks.

Closes #9394
2021-11-09 13:41:38 -05:00
Gregory Anders
3534f8a3ed std: ppoll: cast number of fds to nfds_t
On some systems, the type of the length of a slice is different from the
nfds_t type, so cast the slice length to nfds_t. This is already done in
poll, so just copy that implementation for ppoll.
2021-11-09 13:36:36 -05:00
Vincent Rischmann
082072bd4f os/linux/io_uring: implement statx 2021-11-09 13:35:17 -05:00
Jacob G-W
73be14027d plan9: more syscalls 2021-11-09 07:08:27 -05:00
Jacob G-W
fe314e60bb fix outputs in inline assembly 2021-11-09 07:08:27 -05:00
Jacob G-W
09992f8acc add initial plan9 support to std 2021-11-09 07:08:23 -05:00
Frank Denis
bd8b94bd0e crypto/edwards25519: correctly flip the Y sign in the H2C operation
No security implications, but the current hash-to-curve standard
defines the sign of the Y coordinate to be negative if `gx1`
is a square, positive otherwise.

We were doing it the other way round.
2021-11-08 14:55:27 +01:00
LemonBoy
2551946a51 std: Fix path resolution on Windows
GetCurrentDirectory returns a path with a trailing slash iff the cwd is
a root directory, making the code in `resolveWindows` return an invalid
path with two consecutive slashes.

Closes #10093
2021-11-04 21:05:14 -04:00
Ryan Liptak
e97feb96e4 Replace ArrayList.init/ensureTotalCapacity pairs with initCapacity
Because ArrayList.initCapacity uses 'precise' capacity allocation, this should save memory on average, and definitely will save memory in cases where ArrayList is used where a regular allocated slice could have also be used.
2021-11-04 14:54:25 -04:00
LemonBoy
d03e9d0b83 compiler-rt: Fix f16 API declarations to be consistent
LLVM and compiler-rt must agree on how the parameters are passed, it
turns out that in LLVM13 something changed and broke the test case for
AArch64 systems.

It has nothing to do with fma at all.

Closes #9900
2021-11-04 14:30:35 -04:00
Andrew Kelley
a78e61acf9 std: expose rusage constants under rusage namespace 2021-11-01 15:55:22 -07:00
Andrew Kelley
63f4778827 std: add Linux perf syscall bits
Example usage:

```zig
const std = @import("std");
const PERF = std.os.linux.PERF;
const assert = std.debug.assert;

test "perf" {
    var attr: std.os.linux.perf_event_attr = .{
        .type = PERF.TYPE.HARDWARE,
        .config = @enumToInt(PERF.COUNT.HW.INSTRUCTIONS),
        .flags = .{
            .disabled = true,
            .exclude_kernel = true,
            .exclude_hv = true,
        },
    };
    const fd = try std.os.perf_event_open(&attr, 0, -1, -1, PERF.FLAG.FD_CLOEXEC);
    defer std.os.close(fd);

    _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.RESET, 0);
    _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.ENABLE, 0);

    long();

    _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.DISABLE, 0);

    var result: usize = 0;
    assert((try std.os.read(fd, std.mem.asBytes(&result))) == @sizeOf(usize));

    std.debug.print("instruction count: {d}\n", .{result});
}

fn long() void {
    var i: usize = 0;
    while (i < 100000) : (i += 1) {}
}
```
2021-11-01 14:45:05 -07:00
Ryan Liptak
a343758141 Update ensureTotalCapacity to ensureTotalCapacityPrecise where it makes sense
These calls are all late-initialization of ArrayList's that were initialized outside the current scope. This allows us to still get the potential memory-saving benefits of the 'precision' of initCapacity.
2021-11-01 00:57:33 -07:00
Ryan Liptak
f49d42729a std.ArrayList: add ensureTotalCapacityPrecise and update doc comments
initCapacity did and still does use the ensureTotalCapacityPrecise logic because the initial capacity of an ArrayList is not important in terms of how it grows, so allocating a more exact slice up-front allows for saving memory when the array list never exceeds that initial allocation size. There are use cases where this precise capacity is useful outside of the `init` function, though, like in instances where the user does not call the `init` function themselves but otherwise knows that an ArrayList is empty so calling `ensureTotalCapacityPrecise` can give the same memory savings that `initCapacity` would have.

Closes #9775
2021-11-01 00:57:24 -07:00
pfg
1de6f9a267
std: add missing termios def to std/c/linux.zig
Fixes #9707
2021-10-30 18:32:26 +02:00
Andrew Kelley
d6067db062 stage2: implement @popCount for non-vectors 2021-10-29 17:49:02 -07:00
Matthew Borkowski
5ff01bd820 gpa: fix memory limit accounting for large allocations 2021-10-29 19:22:24 -04:00
ominitay
544d7d9982 Add argument for fillFn to Random.init
As suggested by @leecannon, this provides more flexibility to the
`Random` interface. For exmaple, this allows for an implementation to
provide multiple different fill functions.
2021-10-29 19:20:31 -04:00
Kenta Iwasaki
2cdffc97f0 zig: expose linker options and include '-z notext'
Add an option to allow the '-z notext' option to be passed to the linker
via. the compiler frontend, which is a flag that tells the linker that
relocations in read-only sections are permitted. Certain targets such as
Solana BPF rely on this flag.

Expose all linker options i.e. '-z nodelete', '-z now', '-z relro' in
the compiler frontend. Usage documentation has been updated accordingly.

Expose the '-z notext' flag in the standard library build runner.
2021-10-29 19:18:44 -04:00
InKryption
83a4bb6e69 Make std.meta.trait.isContainer true for opaques
Makes `std.meta.trait.hasFn` work as expected for opaque types with function declarations. Alternative is to add clause directly to `std.meta.trait.hasFn` to account for opaque types.
2021-10-29 20:02:25 +00:00
InKryption
eeb8629bea Use debug.assert instead of testing.expect.
`testing.expect` and friends are intended to be used only in tests; this change reflects that intention.
2021-10-29 20:01:59 +00:00
InKryption
ee038df7e2
Make pointer variables in ( init-lib | init-exe )/build.zig const. (#10057)
* Make `main_tests` variable constant
* Apply same change in init-exe.zig
2021-10-29 13:37:17 -04:00
Andrew Kelley
8e93ec6d24 std.ArrayListUnmanaged: implement writer() 2021-10-28 13:21:17 -07:00
Ominitay
c1a5ff34f3 std.rand: Refactor Random interface
These changes have been made to resolve issue #10037. The `Random`
interface was implemented in such a way that causes significant slowdown
when calling the `fill` function of the rng used.

The `Random` interface is no longer stored in a field of the rng, and is
instead returned by the child function `random()` of the rng. This
avoids the performance issues caused by the interface.
2021-10-27 16:07:48 -04:00
Andrew Kelley
9024f27d8f
Merge pull request #10040 from mattbork/extern-fn-scopes
stage2: fix extern fn decl parsing and astgen
2021-10-27 15:58:33 -04:00
Matthew Borkowski
c8a066f408 parse.zig: report error for extern fn with body 2021-10-26 20:12:28 -04:00
Lewis Gaul
f890de6294
Fix bug in exp2() (#9999)
* Fix bug in exp2_64 to handle negative values (bad translation from C)

* Apply fix to exp2_32() as well, and modify comment on musl behaviour

* Use +%= instead of @addWithOverflow()
2021-10-26 18:57:58 -04:00
Jonathan Marler
ad5b90ab10 multi_array_list: get function take self by value 2021-10-26 18:55:02 -04:00
Andrew Kelley
30d01c8fea
Merge pull request #9874 from leecannon/frame_pointer
Make omiting frame pointer independent of build mode
2021-10-25 19:15:17 -04:00
Stephen von Takach
a132190cad fix(uefi MemoryDescriptor): padding after memory type
not 100% certain, just noticed that this is implemented slightly differently in rust
https://docs.rs/uefi/0.11.0/src/uefi/table/boot.rs.html#715
2021-10-25 16:43:23 -04:00
ominitay
3f6eef22e4 Fix documentation for Random.int
Documentation incorrectly stated that Random.int 'Returns a random int `i`
such that `0 <= i <= maxInt(T)`.' This commit amends this.
2021-10-25 13:34:28 -04:00
Robin Voetter
df167af0b6
Revert 83bdbb2 and a587dd0 (#10028) 2021-10-25 14:00:10 +02:00