6850 Commits

Author SHA1 Message Date
xEgoist
0733c8c5ca windows: replace GetPhysicallyInstalledSystemMemory with ntdll.
`GetPhysicallyInstalledSystemMemory` uses SMBios to grab the physical
memory size which can lead to unecessary allocation and inacurate
representation of the total memory. Using `System_Basic_Information`
help to retrieve the physical memory which is not reserved for the
kernel/tables. This aligns better with the linux side as `/proc/meminfo`
does the same thing.
2023-04-14 13:43:03 -04:00
David CARLIER
7b908e173f std: add shm_create_largepage for FreeBSD, completing MFD* constants. 2023-04-14 13:41:22 -04:00
Frank Denis
b42562be74
std.crypto.aegis: support 256-bit tags (#15276) 2023-04-14 11:20:36 +02:00
David Carlier
56d800ff7e std add getrandom to solato solaris based systems 2023-04-14 08:11:13 +03:00
Frank Denis
9adee806e3
secp256k1: Endormorphism.splitScalar() can return an error (#15270)
Fixes #15267
2023-04-14 04:06:00 +00:00
David CARLIER
4a0508e56c std: add kinfo_vmentry for FreeBSD 2023-04-13 23:46:03 -04:00
Andrew Kelley
e2fe1907ec add c_char type
closes #875
2023-04-13 02:47:16 -04:00
Andrew Kelley
60bd13bdf2 never use C pointers!!
you maniacs, you absolute monsters. degenerates. hooligans. criminals.

issue #2984 is coming for you.
2023-04-12 15:21:03 -07:00
Michael Dusan
490a411fd4 openbsd: fix thread name buffer size
OpenBSD 7.3 changed its implementation of
pthread_get_name_np/pthread_set_name_np to wrap new libc functions
getthrname/setthrname and lowered the max buffer size from 32 to 24.

This is not a backwards-compatible change because if we were to put in
comptime version logic to use size 32 when target < 7.3 the binaries
would be undefined when running on >= 7.3. It also could simply be that
OpenBSD has a policy to not support older binaries running on newer
releases? Regardless, the safest course is to simply use the smallest
known buffer size.

As an aside, this bug manifested as a "hung" std.Thread test because 7.3
pthread API never checks for error result when wrapping getthrname/setthrname.
This is not a problem in std.Thread when we use the correct max buffer
size because ERANGE/EINVAL become unreachable.
2023-04-12 15:36:03 -04:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Andrew Kelley
3c3cee2cfa fix build logic due to state mutations and break the API accordingly
* remove setName, setFilter, and setTestRunner. Please set these
   options directly when creating the CompileStep.
 * removed unused field
 * remove computeOutFileNames and inline the logic, making clear the
   goal of avoiding state mutations after the build step is created.
2023-04-11 08:42:14 -07:00
Andrew Kelley
5a8b1bde5b std.Build.CompileStep: remove output_dir
Build scripts must instead use the FileSource abstraction rather than
telling the compiler directly where to output files.

closes #14951
2023-04-11 08:41:51 -07:00
Andrew Kelley
c96cb98ad1 CLI: remove --enable-cache option
This use case is now handled instead by the --listen option.

closes #15025
closes #15072
2023-04-11 08:41:24 -07:00
Andrew Kelley
7221e9560e std.Build.RunStep: don't close stdin
Instead, ignore stdin. Otherwise this interfers with a sub-process which
expects to have a stdin file descriptor open.
2023-04-10 18:35:14 -07:00
Andrew Kelley
60eabc0eca std.Build.CompileStep: remove run() and install()
These functions are problematic in light of dependencies because they
run and install, respectively, for the *owner* package rather than for
the *user* package. By removing these functions, the build script is
forced to provide the *Build object to associate the new step with,
making everything less surprising.

Unfortunately, this is a widely breaking change.

see #15079
2023-04-10 18:35:14 -07:00
Andrew Kelley
38698f4f6a std.Build.CompileStep: delete install_step field
This was used to ensure that an artifact would only be installed once,
but this is not only unnecessary, but actively harmful, in the face of
dependencies.

see #15079
2023-04-10 18:35:14 -07:00
Andrew Kelley
d2ad3f5074 std.Build.CompileStep: remove redundant dest_builder field
The destination *Build object is already known to be step.owner, while
the source object is artifact.step.owner.
2023-04-10 18:35:14 -07:00
Andrew Kelley
311d50f9dc
Merge pull request #14827 from adriandelgado/log10-int
std.math: port `int_log10` from Rust
2023-04-10 13:01:28 -04:00
GethDW
2c639d6570 std.MultiArrayList: add support for tagged unions. 2023-04-10 12:15:05 -04:00
Andrew Kelley
aeae71f462
Merge pull request #15068 from Snektron/spirv-test-runner-support
spirv: test runner support
2023-04-10 10:44:35 -04:00
Andrew Kelley
dfe3440540 std.os.sendto: use ws2_32 on Windows
closes #9971
2023-04-09 20:08:18 -04:00
Andrew Kelley
95ac94b7ac std.debug: fix segfault/panic race condition
closes #7859
closes #12207
2023-04-09 14:09:52 -04:00
Andrew Kelley
2ee328995a
Merge pull request #15123 from truemedian/http-server
std.http: add http server
2023-04-09 10:44:52 -04:00
Robin Voetter
a7563e453d
spirv: minimal start code
For SPIR-V, only export the main function if it is actually declared. Kernel
entry points will often have parameters and more than one kernel declared.

In general, SPIR-V binaries should mostly be compiled as libraries and not as
executables. However, this start code is required so that we can build test
executables.

Note that a call to isSpirV() would emit the code for that function, even though
the call is at comptime. To save that function from being emitted the checks
are just inlined manually.
2023-04-09 01:51:55 +02:00
Robin Voetter
f12beb857a
amdgpu,nvptx: unify kernel calling conventions
AmdgpuKernel and NvptxKernel are unified into a Kernel calling convention.
There is really no reason for these to be separate; no backend is allowed to
emit the calling convention of the other. This is in the same spirit as the
.Interrupt calling convention lowering to different LLVM calling conventions,
and opens the way for SPIR-V kernels to be exported using the Kernel calling
convention.
2023-04-09 01:51:54 +02:00
Robin Voetter
ba60d456b4
spirv: cannot build libc
SPIR-V cannot build libc, ssp, compiler-rt, etc at the time of this commit, so
prevent trying to build them.
2023-04-09 01:51:48 +02:00
Robin Voetter
12ff362654
spirv: make genericName match target name.
Changes the 'generic name' of the target to spirv, from spir-v.
2023-04-09 01:51:48 +02:00
Robin Voetter
6dc1fafe98
std: add generic target for spirv
This adds a general target for SPIR-V compilation. Previously there was not
any target machine defined for SPIR-V.

TODO is to reword the features for this target. We don't really need the full
list of capabilities in the features, we should only put a few features here
which we can actually use during code generation.
2023-04-09 01:51:47 +02:00
David CARLIER
2e2d37917d std: add FreeBSD's procctl api. 2023-04-08 18:31:01 +03:00
Nameless
7f9a4625fd
std.http: reenable protocol read tests, add missing branch in findHeaders end 2023-04-08 09:59:37 -05:00
Nameless
ef6d58ed3b
std.http: add documentation 2023-04-08 09:59:36 -05:00
Nameless
8250a92544
update package manager to use req.do(), fix chunked trailer reading 2023-04-08 09:59:36 -05:00
Nameless
52c78f4974
fix bugs, waitForCompleteHead -> do, move redirecting to do instead of read
fix for 32bit arches

curate error sets for api facing functions, expose raw errors in client.last_error

fix bugged dependency loop, disable protocol tests (needs mocking)

add separate mutex for bundle rescan
2023-04-08 09:59:36 -05:00
Nameless
aecbfa3a1e
add buffering to connection instead of the http protocol, to allow passing through upgrades 2023-04-08 09:59:36 -05:00
Nameless
08bdaf3bd6
std.http: add http server
* extract http protocol into protocol.zig, as it is shared between client and server
* coalesce Request and Response back into Client.zig, they don't contain
  any large chunks of code anymore
* http.Server is implemented as basic as possible, a simple example below:

```zig
fn handler(res: *Server.Response) !void {
    while (true) {
        defer res.reset();

        try res.waitForCompleteHead();
        res.headers.transfer_encoding = .{ .content_length = 14 };
        res.headers.connection = res.request.headers.connection;
        try res.sendResponseHead();
        _ = try res.write("Hello, World!\n");

        if (res.connection.closing) break;
    }
}

pub fn main() !void {
    var server = Server.init(std.heap.page_allocator, .{ .reuse_address = true });
    defer server.deinit();

    try server.listen(try net.Address.parseIp("127.0.0.1", 8080));

    while (true) {
        const res = try server.accept(.{ .dynamic = 8192 });

        const thread = try std.Thread.spawn(.{}, handler, .{res});
        thread.detach();
    }
}
```
2023-04-08 09:59:35 -05:00
Nameless
fde05b10b3 tls.Client: don't read if we don't need more data 2023-04-08 03:37:05 -04:00
mateusz
0866396308
std.json: allow returning custom errors from custom stringify 2023-04-07 15:01:09 +03:00
Andrew Kelley
9f957184a1 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-06 13:58:54 -07:00
alion02
8853005672 Fix crash on some Windows machines 2023-04-06 07:26:07 +02:00
Andrew Kelley
f289277599 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-05 22:05:31 -07:00
jim price
3487514626 std.os: add mincore syscall
The mincore syscall is available on some UNIX like operating systems
and allows a user to determine if a page is resident in memory.
2023-04-06 00:57:23 -04:00
David CARLIER
3e467c778a std: add os_log/signpost api (sort of linux's perf event equivalent)
subset.
2023-04-06 07:31:06 +03:00
Nikita Ronja
d92b5fcfb0 Add NetBSD termios constants to std.c.netbsd 2023-04-06 03:46:44 +03:00
David CARLIER
080136e4ad std: add madvise flags to freebsd 2023-04-05 13:54:01 +03:00
David CARLIER
f86f531e9c std: add a subset of the apple's QOS api 2023-04-05 09:01:35 +02:00
Jacob Young
ad5fb4879b std: fix memory bugs
This fixes logged errors during CI based on the new GPA checks.
2023-04-05 08:23:07 +02:00
Jakub Konka
5ea6e78943
Merge pull request #15162 from jacobly0/x86_64-start
x86_64: get enough things working to enable full `start.zig` logic
2023-04-05 03:02:42 +02:00
Ganesan Rajagopal
49b56f88b9
GPA: Catch invalid frees
* GPA: Catch invalid frees

Fix #14791: Catch cases where an invalid slice is passed to free().
This was silently ignored before but now logs an error. This change
uses a AutoHashMap to keep track of the sizes which seems to be an
overkill but seems like the easiest way to catch these errors.

* GPA: Add wrong alignment checks to free/resize

Implement @Inkryption's suggestion to catch free/resize with the wrong
alignment. I also changed the naming to match large allocations.
2023-04-04 13:11:25 +03:00
David CARLIER
771d07268f std: freebsd MAP* constants update, MAP_ALIGNED_SUPER and the MAP_ALIGNED macro. 2023-04-04 12:57:16 +03:00
Jacob Young
c91929090d start: disable extra start logic on various x86_64 subtargets 2023-04-03 15:19:07 -04:00