8068 Commits

Author SHA1 Message Date
xdBronch
7a46c20a79 switch to mem.span
Co-authored-by: erikarvstedt <36110478+erikarvstedt@users.noreply.github.com>
2023-12-08 15:58:08 +02:00
xdBronch
e9bd10cfda add getName helper to inotify_event 2023-12-08 15:58:08 +02:00
Jakub Konka
56deb5b054 macho: rename flag to EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 2023-12-06 23:29:08 +01:00
Jakub Konka
79316ee10b lib/std/macho: add missing LC defs and missing N_NO_DEAD_STRIP desc for nlists 2023-12-06 22:25:44 +01:00
Frank Denis
f276bb107e verify_buffer is not expected to be sentinel-terminated 2023-12-01 20:04:52 +01:00
Frank Denis
9831dc9e0c TLS: The 0x1306 TLS identifier was updated to TLS_AEGIS_256_SHA512
Following the recommendations from [1], the AEGIS specification
and the TLS registry [2] were updated to recommend SHA512 for the
traffic secrets.

[1] https://eprint.iacr.org/2023/913.pdf
[2] https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
2023-12-01 18:00:15 +01:00
Jacob Young
bf5ab54510 test: test with -fstrip and fix failures
Closes #17513
2023-12-01 04:34:50 +00:00
David Rubin
1e42a3de89
Remove all usages of std.mem.copy and remove std.mem.set (#18143) 2023-11-29 16:03:02 -05:00
tjog
22d7c7d295
std.debug: optimized printLineFromFileAnyOs (#18142)
* std.debug: optimized printLineFromFileAnyOs

Uses mem.indexOfScalar to speed line iteration instead of byte for byte.
Also prints the whole line in a single write (or up to a page size at a
time)

Closes #18099

* add test cases for printLineFromFileAnyOs
2023-11-29 14:58:56 -05:00
Carter Snook
a98d4a66e9 std.net: replace @ptrCast with slice syntax 2023-11-27 23:14:07 -05:00
Carter Snook
a0fbc6815c std.zig.system: remove explicit usize cast
The cast seems to no longer be necessary after changes in interactions
between `u64` and `usize`.
2023-11-27 23:13:30 -05:00
Andrew Kelley
70d51be3a2 std.zig.render: add ability to append strings after nodes 2023-11-26 19:41:00 -07:00
Lauri Tirkkonen
19af8aac82 os: expect ETIMEDOUT, ECONNRESET, ENOTCONN from recvfrom & read family
reads on eg. connected TCP sockets can fail with ETIMEDOUT, and ENOTCONN
happens eg. if you try to read a TCP socket that has not been connected
yet.

interestingly read() was already handling CONNRESET & TIMEDOUT, but
readv(), pread(), and preadv() were somewhat inconsistent.
2023-11-26 21:35:36 -05:00
Daniel A.C. Martin
280140595f fix: Prevent segfault when using add.Module()
This duplicates the source file string (as is done in other places such
as `addAssemblyFile()`) in order to prevent a segfault when the supplied
string is freed by the caller. This is still seen when the caller makes
use of a defer statement.
2023-11-26 21:33:28 -05:00
Michael Dusan
50bbb9d960 bsd: debitrot atomic and debug
closes #18119
2023-11-26 14:28:22 -05:00
David Rubin
069a079ddc complete todo 2023-11-26 14:27:39 -05:00
Andrew Kelley
7103088e4a
Merge pull request #18105 from Vexu/translate-c
Use Aro's tokenizer in `translate-c`
2023-11-26 02:22:51 -05:00
Bogdan Romanyuk
2ff707be78
AstGen: check allowed non-function builtins with declarative field (#18120) 2023-11-26 02:21:58 -05:00
Veikka Tuominen
74010fecc7 translate-c: use Aro's tokenizer 2023-11-25 12:28:19 +02:00
Andrew Kelley
648f592db1
Merge pull request #18109 from nektro/std-compiler
compiler: move BuiltinFn and AstRlAnnotate to std.zig namespace
2023-11-25 04:11:46 -05:00
Andrew Kelley
e834e95d71 Revert "std.SinglyLinkedList: add sort function"
This reverts commit 8b10970836480a43a3bbb1276cb258c2a8b613f2.

This implementation has the following problems:

* It does not provide context to the less than function. This will be an
  API break in order to fix.
* It uses recursion, causing unbounded stack memory usage - likely
  depending on user input, which is extra problematic.
* Sorting linked lists is generally an inefficient operation;
  encouraging it by having a standard library function for it may
  lead to suboptimal software being written in Zig.

Furthermore, there is almost no benefit to providing a sort function as
a method, when a third party implementation can easily be passed a
linked list to then be sorted.
2023-11-24 22:33:50 -07:00
Meghan Denny
121d995fcb frontend: move AstRlAnnotate to std.zig namespace 2023-11-24 17:09:08 -08:00
Meghan Denny
84d58aaa1f frontend: move BuiltinFn to std.zig namespace 2023-11-24 17:04:52 -08:00
Justus Klausecker
8b10970836
std.SinglyLinkedList: add sort function 2023-11-24 23:49:12 +00:00
Luca Ivaldi
3acb0e30a0
std.fmt: fix overflow when formatting comptime_float 2023-11-24 18:31:12 +02:00
John Benediktsson
54f4abae2f
Deprecate math.doNotOptimizeAway, use mem.doNotOptimizeAway (#18011) 2023-11-23 15:06:32 -05:00
Andrew Kelley
464ce8ac67
Merge pull request #18091 from squeek502/no-shell32-no-ole32
Remove Zig's internal depedency on `shell32.dll` and `ole32.dll`
2023-11-23 14:49:56 -05:00
Ryan Liptak
0bc4ee1792 Remove std.os.windows.ole32/shell32 2023-11-23 03:06:47 -08:00
Andrew Kelley
2bffd81015
Merge pull request #18085 from ziglang/std-atomics
rework std.atomic
2023-11-23 04:55:28 -05:00
Ryan Liptak
2c326d4390 std.os.windows: Add HKEY_CLASSES_ROOT 2023-11-23 01:11:53 -08:00
Ryan Liptak
d42418d614 Replace shell32.SHGetKnownFolderPath usage with LOCALAPPDATA env var
Removes the dependency on shell32.dll. This is a stop gap solution until a proper SHGetKnownFolderPath Zig implementation is written
2023-11-23 01:11:53 -08:00
Ryan Liptak
fcc071c9bd Remove unnecessary branch on absolute path
Also remove the TODO--it was added in fd067fbe8b14c445ed764da15fff5163156126df, but the current code no longer used that workaround, so this TODO didn't seem relevant anymore.
2023-11-23 03:45:17 -05:00
Andrew Kelley
f4e426a06c
Merge pull request #18076 from ziglang/revert-iterable-dir
std.fs: Absorb `IterableDir` into `Dir`
2023-11-23 01:44:07 -05:00
Andrew Kelley
6fc20b3b09 std.os.windows: remove volatile from inline asm
This inline assembly has no side effects.
2023-11-23 00:52:35 -05:00
Andrew Kelley
70931dbdea rework std.atomic
* move std.atomic.Atomic to std.atomic.Value
* fix incorrect argument order passed to testing.expectEqual
* make the functions be a thin wrapper over the atomic builtins and
  stick to the naming conventions.
* remove pointless functions loadUnchecked and storeUnchecked. Instead,
  name the field `raw` instead of `value` (which is redundant with the
  type name).
* simplify the tests by not passing every possible combination. Many
  cases were iterating over every possible combinations but then not
  even using the for loop element value!
* remove the redundant compile errors which are already implemented by
  the language itself.
* remove dead x86 inline assembly. this should be implemented in the
  language if at all.
2023-11-22 19:08:55 -07:00
Andrew Kelley
edb2f72988 std: remove atomic.Queue
This was originally supposed to be a lock-free queue, but I gave up on
that and made it be a thread-safe queue instead.

Putting the mutex directly inside the queue data structure makes it
non-composeable. Instead, the recommendation is to use a normal queue
protected by an external mutex.
2023-11-22 16:39:37 -07:00
Andrew Kelley
6bd97ab640 std: remove atomic.Stack
This was originally supposed to be a lock-free stack, but I gave up on
that and made it be a thread-safe stack which is implemented poorly
using spin locks. Nobody should use this data structure.

The alternative is a normal stack protected by a mutex.
2023-11-22 16:38:26 -07:00
Andrew Kelley
0a536a7c90 std.fs.File: flatten struct 2023-11-22 15:24:57 -07:00
Andrew Kelley
e00e9c0fbf std.fs: extract AtomicFile to separate file 2023-11-22 15:24:57 -07:00
Andrew Kelley
c95e2e65fa std.fs: extract Dir into separate file 2023-11-22 15:24:57 -07:00
Andrew Kelley
e357550610 update for the std.fs.Dir changes 2023-11-22 15:24:57 -07:00
Andrew Kelley
1fa2e911d9 std.atomic: remove some APIs
* remove `std.atomic.Ordering`
  - it is provided by the language with `std.builtin.AtomicOrder`.
* remove `std.atomic.fence`
  - it is provided by the language with `@fence`.
* remove `std.atomic.compilerFence`
  - if this is desired, it should be a language feature, not a standard
    library function with inline asm.
2023-11-22 14:27:49 -07:00
Andrew Kelley
519ba9bb65 Revert "Merge pull request #12060 from Vexu/IterableDir"
This reverts commit da94227f783ec3c92859c4713b80a668f1183f96, reversing
changes made to 8f943b3d33432a26b7e242c1181e4220ed400501.

I was against this change originally, but decided to approve it to keep
an open mind. After a year of trying it in practice, I firmly believe
that the previous way of doing it was better.
2023-11-22 12:35:33 -07:00
Andrew Kelley
49d6dd3ecb std.crypto.ff: simplify implementation
* Take advantage of multi-object for loops.
* Remove use of BoundedArray since it had no meaningful impact on safety
  or readability.
* Simplify some complex expressions, such as using `!` to invert a
  boolean value.
2023-11-22 11:32:14 -07:00
Andrew Kelley
7b3556a8cf std.fs: make deleteTree use ArrayList instead of BoundedArray
We definitely want ArrayList in the standard library. Do we want
BoundedArray? Maybe, maybe not. But that makes ArrayList a more stable
dependency for std.fs.
2023-11-22 11:32:14 -07:00
Andrew Kelley
f6549a956d std.ArrayList: add initBuffer to the unmanaged array list
This is useful when you want to have an array list backed by a fixed
slice of memory and no Allocator will be used.

It's an alternative to BoundedArray as you will see in the following
commit.
2023-11-22 11:32:14 -07:00
Andrew Kelley
d5e21a4f1a std: remove meta.trait
In general, I don't like the idea of std.meta.trait, and so I am
providing some guidance by deleting the entire namespace from the
standard library and compiler codebase.

My main criticism is that it's overcomplicated machinery that bloats
compile times and is ultimately unnecessary given the existence of Zig's
strong type system and reference traces.

Users who want this can create a third party package that provides this
functionality.

closes #18051
2023-11-22 13:24:27 -05:00
Hong Shick Pak
994e191643
std.Uri: fix parsing edge case panic 2023-11-22 07:40:30 +00:00
Mikko Kaihlavirta
ea4a07701e add missing timeval struct 2023-11-22 01:15:11 +02:00
Andrew Kelley
be6f76655f
Merge pull request #18055 from ziglang/zig-init 2023-11-21 11:59:24 -05:00