Commit Graph

73 Commits

Author SHA1 Message Date
Pierre Tachoire df9fdb1861 std.net.listen: no REUSEPORT with unix socket
On Linux, set REUSEPORT option on an unix socket returns a EOPNOTSUPP error.
See https://github.com/torvalds/linux/commit/5b0af621c3f6ef9261cf6067812f2fd9943acb4b
2025-01-26 18:40:34 +01:00
Andrew Kelley 6129ecd4fe std.net, std.http: simplify 2024-02-23 02:37:11 -07:00
Veikka Tuominen a4f27e8987 remove std.io.Mode 2024-02-01 15:22:36 +02:00
Andrew Kelley cd7960ea75 std: disable flaky tcp server test
Tracking issue: #18315
2023-12-19 12:01:09 -07:00
Artem Kolichenkov 90a19f7411 std.net: add explicit error sets for IP parsing
Inferred errors in switch statements prevented IP address parsing at comptime.
Adding explicit error sets fixes it.

Closes #18276
2023-12-16 16:15:51 +00:00
Jan Philipp Hafer 70664547ce std.net.test: cleanup socket stream 2023-12-15 21:15:35 +02:00
Jan Philipp Hafer 27b34a5b77 std.net: enable forcing non-blocking mode for accept
Justification: It is common for non-CPU bound short routines to do
non-blocking accept to eliminate unnecessary delays before subscribing
to data, for example in hardware integration tests.
2023-11-21 18:04:33 +02:00
mlugg 51595d6b75 lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young 509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Jacob Young 98cd378208 x86_64: fix behavior of getValue
Old behavior renamed to `getValueIfFree`.
2023-10-26 21:45:58 -04:00
Jacob Young b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
Jacob Young 8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Jacob Young 27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley 6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young 32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Jacob Young 2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Luis Cáceres 8976ad7ecb std.net: Fix IPv6 address parsing for single digit
This fixes the case where IPv6 address parsing incorrectly succeeded on
input such as `1`, which now returns error.Incomplete.
2023-09-06 11:14:24 +03:00
Dominic 5a3eca5d4c Disallow named test decls with duplicate names 2023-05-08 10:59:06 +03:00
DraagrenKirneh e9cbdb2cfd Add a random generated prefix to the unix socket_path to guard against multiple tests/threads running the same test at the same time 2023-05-02 23:31:29 +03:00
Jon 529064856a std.net.StreamServer.Options: add reuse_port 2023-04-24 12:23:22 +03:00
mlugg ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Andrew Kelley aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Andrew Kelley fad95741db AstGen: fix loop control flow applying to wrong loop
In the case of 'continue' or 'break' inside the 'else' block of a
'while' or 'for' loop.

Closes #12109
2022-07-13 16:10:41 -07:00
Andrew Kelley c248af3bdc LLVM: fix lowering of untagged union types
The LLVM backend was calculating the amount of padding solely based
on the payload size. However, in the case where there is no union
tag, this fails to take into account alignment.

Closes #11857
2022-06-30 02:43:05 -04:00
Veikka Tuominen 413577c881 std: adjust for stage2 semantics 2022-06-07 21:27:07 +03:00
John Schmidt c992164dc7 Check for isDarwin() instead of linked libc 2022-01-14 13:44:38 +01:00
John Schmidt 66fe5bb0d8 Use libc if_nametoindex if available when parsing IPs
Fixes https://github.com/ziglang/zig/issues/10521 and makes a couple of
additional tests pass when linking libc.
2022-01-12 19:32:46 +01:00
Lee Cannon 85de022c56 allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley 6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Kirjastonhoitaja e1bf350b4d net.Address: Fix writing 0-bytes when formatting Unix addresses
The entire 'path' array would get written to the formatting function,
when it should instead be treated as a regular zero-terminated string.

Note that this doesn't handle abstract paths on Linux, those paths
*start* with a \0 byte and are hence treated as empty strings instead.
But fixing that would require more adjustments than just formatting, in
particular to getOsSockLen().
2021-09-16 11:35:12 +02:00
Andrew Kelley d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Frank Denis 2ccd023c6a Ip4Address parser: reject 0-prefixed components (#9538)
Some parsers interpret these as octal, some don't, and the confusion can lead to vulnerabilities.

Return error.NonCanonical when parsing IPv4 addresses with 0 prefixes.
2021-08-09 22:44:23 +02:00
kprotty 0a1def7833 changes to accomodate std.Thread update 2021-06-30 21:48:59 -05:00
Veikka Tuominen fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
LemonBoy 566adc2510 std: Swap arguments in Thread.spawn
Beside the new order being consistent with the ThreadPool API and making
more sense, this shuffling allows to write the context argument type in
terms of the startFn arguments, reducing the use of anytype (eg. less
explicit casts when using comptime_int parameters, yay).

Sorry for the breakage.

Closes #8082
2021-02-28 14:03:19 +01:00
LemonBoy 34720da3d0 Apparently unix sockets are supported on Windows
Starting from Windows 10 build 17063.
2021-01-11 21:43:15 +01:00
LemonBoy d0beb4badb Let the kernel pick a random port
Avoid errors if the socket enters the TIME_WAIT state and we need to
re-execute this test before the OS releases it.

This problem was not really a problem before since the accept()-ed
socket was never closed on the server-side.
2021-01-11 21:43:14 +01:00
LemonBoy 676d7fc63c std: Add a small test for i/o on unix sockets 2021-01-11 21:43:13 +01:00
LemonBoy 89d6317b93 std: Decouple network streams from fs.File
The overlap between files and sockets is minimal and lumping them
together means supporting only a small subset of the functionalities
provided by the OS.
Moreover the socket and file handles are not always interchangeable: on
Windows one should use Winsock's close() call rather than the one used
for common files.
2021-01-11 21:43:09 +01:00
Jay Petacat a9b505fa77 Reduce use of deprecated IO types
Related: #4917
2021-01-07 23:48:58 -08:00
Frank Denis 6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
LemonBoy 7f46672193 More fixups for Windows targets
* Use closeSocket on sockets instead of plain old close, the latter
  doesn't work on them.
* Use winsocket2 everywhere, mingw has no BSD sockets.
2020-10-28 10:03:23 +01:00
LemonBoy 8044ed4c66 std: Add basic smoke test for net functionality 2020-10-27 21:52:47 +01:00
Andrew Kelley 4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Ian Simonson 983f93c840 Test case for tcpConnectToHost fix 2020-06-07 22:39:35 +10:00
Andrew Kelley 7fd937fef4 cleanups
* improve docs
 * add TODO comments for things that don't have open issues
 * remove redundant namespacing of struct fields
 * guard against ioctl returning EINTR
 * remove the general std.os.ioctl function in favor of the specific
   ioctl_SIOCGIFINDEX function. This allows us to have a more precise
   error set, and more type-safe API.
2020-06-02 15:28:46 -04:00
Luna c7b790ded6 net.test: only call resolveIp6 when os is linux 2020-06-02 14:56:06 -04:00
Luna 15efe03d1f Add tests for overflow 2020-06-02 14:56:06 -04:00
Luna 2fa9cf51ff Plug resolveIp6 into IPv6 tests 2020-06-02 14:56:06 -04:00