7060 Commits

Author SHA1 Message Date
David CARLIER
f8991ba3d4 std.os: gethostname non libc linking using uname like linux 2023-05-22 12:45:18 +03:00
Michael Dusan
19c96c09f3 std.c: openbsd sigcontext/ucontext fix enum 2023-05-22 11:31:57 +03:00
Chris Heyes
df909da5d8
std.crypto: expose Fe isOdd & add basic parity tests for each pcurve (#15734)
* std Secp256k1 Scalar: expose Fe isOdd & add basic parity test

* std.crypto: also add Scalar.isOdd convenience fn for p256 and p384 curves
2023-05-21 13:00:48 +02:00
Andrew Kelley
b7cb88384c
Merge pull request #15407 from mlugg/feat/pkg-dedup
Deduplicate uses of the same package across dependencies

closes #15755
2023-05-20 22:58:20 -07:00
mlugg
38b83d9d93 Zir: eliminate field_call_bind and field_call_bind_named
This commit removes the `field_call_bind` and `field_call_bind_named` ZIR
instructions, replacing them with a `field_call` instruction which does the bind
and call in one.

`field_call_bind` is an unfortunate instruction. It's tied into one very
specific usage pattern - its result can only be used as a callee. This means
that it creates a value of a "pseudo-type" of sorts, `bound_fn` - this type used
to exist in Zig, but now we just hide it from the user and have AstGen ensure
it's only used in one way. This is quite silly - `Type` and `Value` should, as
much as possible, reflect real Zig types and values.

It makes sense to instead encode the `a.b()` syntax as its own ZIR instruction,
so that's what we do here. This commit introduces a new instruction,
`field_call`. It's like `call`, but rather than a callee ref, it contains a ref
to the object pointer (`&a` in `a.b()`) and the string field name (`b`). This
eliminates `bound_fn` from the language, and slightly decreases the size of
generated ZIR - stats below.

This commit does remove a few usages which used to be allowed:
- `@field(a, "b")()`
- `@call(.auto, a.b, .{})`
- `@call(.auto, @field(a, "b"), .{})`

These forms used to work just like `a.b()`, but are no longer allowed. I believe
this is the correct choice for a few reasons:
- `a.b()` is a purely *syntactic* form; for instance, `(a.b)()` is not valid.
  This means it is *not* inconsistent to not allow it in these cases; the
  special case here isn't "a field access as a callee", but rather this exact
  syntactic form.
- The second argument to `@call` looks much more visually distinct from the
  callee in standard call syntax. To me, this makes it seem strange for that
  argument to not work like a normal expression in this context.
- A more practical argument: it's confusing! `@field` and `@call` are used in
  very different contexts to standard function calls: the former normally hints
  at some comptime machinery, and the latter that you want more precise control
  over parts of a function call. In these contexts, you don't want implicit
  arguments adding extra confusion: you want to be very explicit about what
  you're doing.

Lastly, some stats. I mentioned before that this change slightly reduces the
size of ZIR - this is due to two instructions (`field_call_bind` then `call`)
being replaced with one (`field_call`). Here are some numbers:

+--------------+----------+----------+--------+
| File         | Before   | After    | Change |
+--------------+----------+----------+--------+
| Sema.zig     | 4.72M    | 4.53M    | -4%    |
| AstGen.zig   | 1.52M    | 1.48M    | -3%    |
| hash_map.zig | 283.9K   | 276.2K   | -3%    |
| math.zig     | 312.6K   | 305.3K   | -2%    |
+--------------+----------+----------+--------+
2023-05-20 12:27:48 -07:00
Meghan
7077e90b3f std.meta: allow ArgsTuple to be used on functions with comptime parameters
any comptime parameter sets `.is_generic` to be true but in many cases these will still be discrete types available in `.params`
2023-05-20 11:21:06 +03:00
David CARLIER
ccfb0d408d std.c: adding ptrace for netbsd. 2023-05-20 11:06:11 +03:00
Motiejus Jakštys
b61d0debd6 multi-writer: test with a non-comptime stream
Since #14819 this test failed with:

    $ ../../../build/stage3/bin/zig test multi_writer.zig
    multi_writer.zig:26:57: error: unable to evaluate comptime expression
                var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init();
                                                        ~~~~^~~~~~~~
    referenced by:
        Writer: multi_writer.zig:19:52
        writer: multi_writer.zig:21:36
        remaining reference traces hidden; use '-freference-trace' to see all reference traces

Thanks @jacobly for hints how to fix this on IRC.
2023-05-19 09:13:49 -07:00
David CARLIER
b9d2e0e308 std.os: add linux timer api 2023-05-19 03:41:10 +03:00
Andrew Kelley
7cf2cbb33e std.crypto.tls.Client.readvAdvanced: fix bugs
* When there is buffered cleartext, return it without calling the
   underlying read function. This prevents buffer overflow due to space
   used up by cleartext.
 * Avoid clearing the buffer when the buffered cleartext could not be
   completely given to the result read buffer, and there is some
   buffered ciphertext left.
 * Instead of rounding up the amount of bytes to ask for to the nearest
   TLS record size, round down, with a minimum of 1. This prevents the
   code path from being taken which requires extra memory copies.
 * Avoid calling `@memcpy` with overlapping arguments.

closes #15590
2023-05-18 03:26:16 -07:00
mlugg
f65e8c7862 Deduplicate uses of the same package across dependencies 2023-05-18 00:27:21 -07:00
IntegratedQuantum
6e05620117 Document the sorting order in std.sort. 2023-05-17 18:26:49 -07:00
Andrew Kelley
c1add1e19e
Merge pull request #15459 from motiejus/build-id-full
stage2: implement `--build-id` styles
2023-05-17 07:19:15 -07:00
Andrew Kelley
728ce2d7c1 tweaks to --build-id
* build.zig: the result of b.option() can be assigned directly in many
   cases thanks to the return type being an optional
 * std.Build: make the build system aware of the
   std.Build.Step.Compile.BuildId type when used as an option.
   - remove extraneous newlines in error logs
 * simplify caching logic
 * simplify hexstring parsing tests and use a doc test
 * simplify hashing logic. don't use an optional when the `none` tag
   already provides this meaning.
 * CLI: fix incorrect linker arg parsing
2023-05-16 20:39:01 -07:00
Motiejus Jakštys
df5085bde0 stage2: implement --build-id styles 2023-05-16 20:38:39 -07:00
David CARLIER
40e8c2243c std.c: darwin's *copyfile api update. 2023-05-17 06:06:41 +03:00
Frank Denis
c6966486e3
crypto.AegisMac: fix a regression from s/mem.copy/@memcpy/ (#15733)
In an update whose size is not a multiple of the block size,
we would end up calling @memcpy() with arguments of different sizes.
2023-05-16 23:51:47 +00:00
Cortex
c269e16c3b
std.mem.byteSwapAllFields: add suppport for nested structs (#15696) 2023-05-16 19:10:44 -04:00
David CARLIER
b754068fbc std.c: add ptrace for freebsd support. 2023-05-16 22:47:51 +03:00
Tw
e584dd8062 std.mem.zeroInit: zero hidden padding for extern struct
Signed-off-by: Tw <tw19881113@gmail.com>
2023-05-16 10:33:04 +03:00
David CARLIER
b677b36278 std.c: add netbsd's accept_filter_data for ACCEPT_FILTER sock opt. 2023-05-16 04:31:15 +03:00
Tristan Ross
de6cafa80f std: expose fmt methods and structs for parsing 2023-05-15 12:11:11 +03:00
David CARLIER
2952fb9758 std.c: add rfork for freebsd 2023-05-15 03:10:34 +03:00
David CARLIER
05268bb967 std.os: implementing sched_setaffinity wrapper for freebsd 2023-05-14 10:21:42 +03:00
Josh Wolfe
018b743c7a
std: Rewrite low-level json api to support streaming (#15602) 2023-05-13 14:31:53 -04:00
David CARLIER
c7bf8bab38 std.os: adding linux's sched_setaffinity and its wrapper 2023-05-13 21:18:18 +03:00
xdBronch
4652729217 std.simd.suggestVectorSizeForCpu: fix missing argument in body 2023-05-13 13:35:50 +03:00
Veikka Tuominen
68bacad804
Merge pull request #15643 from Vexu/fixes
make `@call` compile errors match regular calls
2023-05-13 12:52:16 +03:00
David CARLIER
6f418c11e1 linux adding some NUMA support 2023-05-13 12:13:02 +03:00
David CARLIER
cceadf52ba std.c: further darwin's host statistics data 2023-05-13 11:55:43 +03:00
Andrew Kelley
88d275199c
Merge pull request #15240 from Snektron/spirv-basic
spirv: attempting to get the 'basic' behavior tests running
2023-05-12 14:46:20 -07:00
David CARLIER
6547d23312 std.c: adding basic darwin's host_statistics data. 2023-05-12 20:20:31 +03:00
InKryption
3c2841c202 std.math.atan: fix mistyped magic constant
Co-authored-by: WiserOrb <diego99.masotti@gmail.com>
2023-05-11 15:56:42 -07:00
Andrew Kelley
6c41d43519
Merge pull request #15641 from jacobly0/cache-race
Cache: fix race condition
2023-05-11 12:51:56 -07:00
Ali Chraghi
ccc490ef68
setup spirv backend in behavior tests 2023-05-11 20:31:52 +02:00
Robin Voetter
5e62ba1347
opencl: define size of C types
Define the size of the c types according the OpenCL specification.

Note that OpenCL does not define the size of long double. Clang generates
fp128, even though there is no extension that allows such types. The
llvm-spirv translator simply crashes.
2023-05-11 20:31:50 +02:00
Gregory Mullen
aa9ea61216 Add tc{set,get}pgrp to std.os.linux 2023-05-11 19:43:06 +03:00
Andrew Kelley
7f7bd206dc
Merge pull request #15519 from dweiller/issue-15482
Optimize lowering of `s[start..][0..len]`
2023-05-11 08:59:44 -07:00
Andrew Kelley
3bb3d39fb4
Merge pull request #15487 from truemedian/http-tests
std.http: more http fixes, add standalone http server test
2023-05-11 08:37:42 -07:00
Veikka Tuominen
f0fdaf32d3 fix incorrect use of mutable pointers to temporary values 2023-05-11 17:23:06 +03:00
Veikka Tuominen
d761e6cc7d fix formatting in darwin.zig 2023-05-11 14:59:19 +03:00
David CARLIER
20cc69318f std.c: darwin adding more host_info api data 2023-05-11 11:21:07 +03:00
Jacob Young
6e292f66db Cache: fix unnecessary cache misses
With the old logic, it was possible for a bunch of processes to queue up
to update a cache entry, and then each to do so one at a time.  Now, it
rechecks whether there still a cache miss or another process has
completed the work in the interim.
2023-05-11 00:55:40 -04:00
Jacob Young
fae6290387 Cache: fix race condition
When checking a cache entry with no input files for a hit, if
`createFile` returned `error.WouldBlock` we would forget about the fact
that the file has been created, and all future checks will assume that a
cache hit has happened, even though one never has or does, leading to
rare `FileNotFound` errors trying the access the protected files.

This fix works by writing an extra byte to the manifest file to
distinguish hits and misses when there no input files to write.
2023-05-11 00:55:40 -04:00
Meghan
ac385bd8a6 std.fmt.parseIntSizeSuffix: add R and Q
https://www.nist.gov/pml/owm/metric-si-prefixes

https://www.npl.co.uk/si-prefix
2023-05-10 20:11:18 +03:00
David CARLIER
cd7e2bf57a std.c: adding freebsd's ioctl base operands. 2023-05-10 19:14:51 +03:00
Kyle Coffey
ebc3773542
Add std.mem.indexOfNone
This introduces a parallel set of functions to the std.mem.indexOfAny
functions. They simply invert the logic, yielding the first/last index
which is *not* contained in the "values" slice.

Inverting this logic is useful when you are attempting to determine the
initial span which contains only characters in a particular set.

* Document the `indexOfNone` family.

These descriptions are somewhat brief, but the functions themselves are
also simple enough to describe in such a way.
2023-05-10 17:47:58 +03:00
Evin Yulo
6d7bb255a4 Add std.fmt.parseIntSizeSuffix and use for --maxrss
Fixes #14955
2023-05-10 16:31:51 +03:00
Bogdan Romanyuk
c4dbfd5ae1 std.enums: make Ext parameter optional
According to #8169 optional generic functions work fine in comptime so it's possible
2023-05-10 16:15:41 +03:00
Ali Chraghi
05ceac52c9 std.Build: support #cmakedefine01 pattern 2023-05-10 16:10:03 +03:00