Commit Graph

186 Commits

Author SHA1 Message Date
Andrew Kelley 3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -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
Jacob Young f571438fc0 Unrevert "Sema: preserve extern struct field alignment"
This unreverts commit 1a2468abfc.
2023-06-30 23:24:52 -04:00
Jacob Young 1a2468abfc Revert "Sema: preserve extern struct field alignment"
This reverts commit 4620972d08.
2023-06-29 00:23:19 -04:00
Alex Kladov 4620972d08 Sema: preserve extern struct field alignment
In

    extern struct { x: u32, y: u16 }

we actually know that y's alignment is `@alignOf(u32)`, and not just
`@alignOf(u16)`.

closes: #16134
2023-06-28 16:36:32 +02:00
Eric Joldasov 0a868dacdd std.cstr: deprecate namespace
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-25 14:51:03 -07:00
mlugg f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov 50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
r00ster91 2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Andrew Kelley 629f0d23b5 Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
Ali Chraghi 3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
Ryan Liptak 2129f28953 Update all std.mem.split calls to their appropriate function
Everywhere that can now use `splitScalar` should get a nice little performance boost.
2023-05-13 13:45:05 -07:00
Ryan Liptak 815e53b147 Update all std.mem.tokenize calls to their appropriate function
Everywhere that can now use `tokenizeScalar` should get a nice little performance boost.
2023-05-13 13:45:04 -07:00
dweiller bd3360e03d convert s[start..start+len] to s[start..][0..len] 2023-05-07 15:55:21 +10:00
Andrew Kelley 125221cce9 std: update to use @memcpy directly 2023-04-28 13:24:43 -07:00
Andrew Kelley 6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Andrew Kelley a5c910adb6 change semantics of @memcpy and @memset
Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
2023-04-25 11:23:40 -07:00
Jon 529064856a std.net.StreamServer.Options: add reuse_port 2023-04-24 12:23:22 +03:00
hequn f56f3c5824 Enable IPv4 mapped address conversion in linux version getAddressList (#14916)
It seems like the original code of setsockopt is not effective because
i catch the EINVAL branch when uncomment this code, it should call
setsockopt before the bind call.

This should fix issue #14900.

Co-authored-by: Qun He <hawkbee@qq.com>
2023-03-17 15:58:02 -04:00
Nameless 0a4130f364 std.http: handle relative redirects 2023-03-09 14:55:13 -06:00
Nameless 8d86194b6e add error sets to tcpConnect* and tls.Client.init 2023-03-09 14:54:26 -06:00
Andrew Kelley aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Isaac Freund 186e805838 std.net.Address: clarify unix socket getOsSockLen 2023-01-23 14:49:06 +01:00
Isaac Freund faf2fd18d3 std: eliminate pointless meta.assumeSentinel() usage
This fixes a bug in std.net caused during the introduction of
meta.assumeSentinel due to the unfortunate semantics of mem.span()

This leaves only 3 remaining uses of meta.assumeSentinel() in the
standard library, each of which could be a simple @ptrCast([*:0]T, foo)
instead. I think this function should likely be removed.
2023-01-23 12:19:53 +01:00
Jarred Sumner a9eb463202 Make res nullable in getaddrinfo 2023-01-19 23:08:15 +02:00
Andrew Kelley 86308ba1e1 std.net.getAddressList: call WSAStartup on Windows 2023-01-17 00:08:42 -07:00
praschke 3ab43988c1 std.net: check for localhost names before asking DNS
the old implementation asks DNS before checking if it shouldn't.
additionally, it did not catch absolute 'localhost.' names.
2023-01-10 18:09:07 -05:00
Andrew Kelley e4a9b19a14 std.crypto.tls.Client: rework the read function
Here's what I landed on for the TLS client. It's 16896 bytes
(max_ciphertext_record_len is 16640). I believe this is the theoretical
minimum size, give or take a few bytes.

These constraints are satisfied:
 * a call to the readvAdvanced() function makes at most one call to the
   underlying readv function
 * iovecs are provided by the API, and used by the implementation for
   underlying readv() calls to the socket
 * the theoretical minimum number of memcpy() calls are issued in all
   circumstances
 * decryption is only performed once for any given TLS record
 * large read buffers are fully exploited

This is accomplished by using the partial read buffer to storing both
cleartext and ciphertext.
2023-01-02 16:57:16 -07:00
Andrew Kelley 940d368e7e std.crypto.tls.Client: fix the read function
The read function has been renamed to readAdvanced since it has slightly
different semantics than typical read functions, specifically regarding
the end-of-file. A higher level read function is implemented on top.

Now, API users may pass small buffers to the read function and
everything will work fine. This is done by re-decrypting the same
ciphertext record with each call to read() until the record is finished
being transmitted.

If the buffer supplied to read() is large enough, then any given
ciphertext record will only be decrypted once, since it decrypts
directly to the read() buffer and therefore does not need any memcpy. On
the other hand, if the buffer supplied to read() is small, then the
ciphertext is decrypted into a stack buffer, a subset is copied to the
read() buffer, and then the entire ciphertext record is saved for the
next call to read().
2023-01-02 16:57:16 -07:00
Andrew Kelley 920e5bc4ff std.crypto.Tls: discard ChangeCipherSpec messages
The next step here is to decrypt encrypted records
2023-01-02 16:57:15 -07:00
Andrew Kelley d2f5d0b199 std.crypto.Tls: parse the ServerHello handshake 2023-01-02 16:57:15 -07:00
Andrew Kelley ba44513c2f std.http reorg; introduce std.crypto.Tls
TLS is capable of sending a Client Hello
2023-01-02 16:57:15 -07:00
Veikka Tuominen 622311fb9a update uses of overflow arithmetic builtins 2022-12-27 15:13:14 +02:00
r00ster91 6b7d9b34e8 api(std.ascii): remove deprecated decls 2022-12-09 21:57:17 +01:00
Andrew Kelley ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Nick Cernis 8a5818535b Make invalidFmtError public and use in place of compileErrors for bad format strings (#13526)
* Export invalidFmtErr

To allow consistent use of "invalid format string" compile error
response for badly formatted format strings.

See https://github.com/ziglang/zig/pull/13489#issuecomment-1311759340.

* Replace format compile errors with invalidFmtErr

- Provides more consistent compile errors.
- Gives user info about the type of the badly formated value.

* Rename invalidFmtErr as invalidFmtError

For consistency. Zig seems to use “Error” more often than “Err”.

* std: add invalid format string checks to remaining custom formatters

* pass reference-trace to comp when building build file; fix checkobjectstep
2022-11-12 21:03:24 +02:00
r00ster cff5d9c805 std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
Veikka Touminen 819c868bbf std.net.getAddressList: fix segfault on bad hostname
Fixes #12065
2022-07-23 13:54:24 +03:00
Veikka Tuominen 413577c881 std: adjust for stage2 semantics 2022-06-07 21:27:07 +03:00
Veikka Tuominen 6d44c0a16c std: update tests to stage2 semantics 2022-06-03 20:21:20 +03:00
Jakub Konka ba0f72363a Merge pull request #10576 from schmee/macos-resolve-ip
Use libc if_nametoindex for macOS when parsing IPs
2022-01-15 00:47:12 +01:00
John Schmidt c992164dc7 Check for isDarwin() instead of linked libc 2022-01-14 13:44:38 +01:00
bryfry 0d45c72d3e Use allocPrintZ to avoid needing assumeSentinel 2022-01-14 00:17:38 -05: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
Ali Chraghi 005e869abd update function name in error 2021-12-02 12:35:17 -08:00
Lee Cannon 1093b09a98 allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon 85de022c56 allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley 902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07: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