Commit Graph

7486 Commits

Author SHA1 Message Date
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
Jakub Konka
35f9c84449 macos: add missing getopt.h header 2023-04-13 00:19:33 +02: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
Loris Cro
602029bb2f
Autodoc usingnamespace (#15216)
* autodoc: init support for usingnamespace decls

* autodoc: don't build autodoc when building zig2.c

* autodoc: usingnamespace decls support in frontend (#15203)

* autodoc: init support for usingnamespace decls

* autodoc: usingnamespace decls support in frontend

---------

Co-authored-by: Krzysztof Wolicki <46651553+der-teufel-programming@users.noreply.github.com>
2023-04-12 01:14:02 +00: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
406706fe6b init-exe/init-lib template: fix use of install() and run()
And while we're at it, make the unit tests be actually executed.
2023-04-10 18:35:14 -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
Andrew Kelley
aa45854ec3 zig.h: fix typo for zig_trap definition 2023-04-08 09:54:32 -07: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
13aa7871b2
Merge pull request #15101 from motiejus/glibc_compat
glibc: add backwards compatibility for some symbols
2023-04-06 17:15:58 -04:00
Andrew Kelley
9f957184a1 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-06 13:58:54 -07:00
Andrew Kelley
ef5afbfcf4 zig.h: f16 fix for compiler_rt
See #15092
2023-04-06 08:40:02 -07:00
Andrew Kelley
fc9ab4144c update libcxx to LLVM 16.0.1 2023-04-05 23:22:29 -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
Jacob Young
5870ffeb82 compiler_rt: change the abi of f16 on mac to depend on the other type 2023-04-05 22:05:10 -07:00
Jacob Young
243848167b compiler_rt: attempt to fix f16 abi on mac with llvm 16 2023-04-05 22:05:06 -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