544 Commits

Author SHA1 Message Date
Ryan Liptak
a11cdb6a34 os.realpathW: Reduce the number of OpenFile calls for directories
Same as a190582b26a82f96da7488eff37e9676cdb937bc but for os.realpathW instead of fs.Dir.realpathW
2023-08-19 22:29:46 -07:00
Ryan Liptak
e078324dbe Add NetworkNotFound to ReadLinkError
This matches how other filesystem functions were made to handle BAD_NETWORK_PATH/BAD_NETWORK_NAME in https://github.com/ziglang/zig/pull/16568. ReadLink was the odd one out, but that is no longer the case.
2023-08-18 18:07:16 -07:00
Ryan Liptak
8f5f1ff25a fs tests: Test multiple different path types in most tests
(which path types will depend on which the target supports)
2023-08-17 00:59:19 -07:00
Ryan Liptak
3f9294c735 Windows: Fix TooManyParentDirs handling for paths that shouldn't be cwd-relative
Previously, a relative path like `..` would:
- Attempt to be normalized (i.e. remove . and .. without any path resolution), but would error with TooManyParentDirs
- This would make wToPrefixedFileW run it through `RtlGetFullPathName_U` to do the necessary path resolution, but `RtlGetFullPathName_U` always resolves relative paths relative to the CWD

Instead, when TooManyParentDirs occurs, we now look up the path of the passed in `dir` (if it's non-null) and append the relative path to it before giving it to `RtlGetFullPathName_U`. If `dir` is null, then we just give it RtlGetFullPathName_U directly and let it resolve it relative to the CWD.

Closes #16779
2023-08-11 18:58:40 -07:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
Andrew Kelley
b5df1bfcdb Revert "os: expand sched_getaffinity wrapper and update freebsd's cpuset api flags."
This reverts commit dbdafb6cc503ce5820713dfa79cc956438b7957a.
2023-07-31 11:23:38 -07:00
Andrew Kelley
86388e3c32 Revert "std.os: sysctl* wrappers, better warning at compile time"
This reverts commit c66151a22619b4f3ce028076c67f495ff5f99d2c.
2023-07-31 11:20:31 -07:00
Andrew Kelley
a92be49851 Revert "Merge pull request #15317 from devnexen/darwin_rand_nativegen"
This reverts commit a11113097730693fb915114cec79df9cb4adcc93, reversing
changes made to 9f3f9fb40f605de2f2bdcd0ce7a396e06b8b8c0d.
2023-07-31 11:13:27 -07:00
Andrew Kelley
182bec8771 Revert "std.os: adding linux's sched_setaffinity and its wrapper"
This reverts commit c7bf8bab38f8b89c1371eedb9229e00a29b5ca5b.
2023-07-31 11:01:42 -07:00
Andrew Kelley
86a5edca62 Revert "std.os: implementing sched_setaffinity wrapper for freebsd"
This reverts commit 05268bb9677ef0545cca6c788169b2707842dc8d.
2023-07-31 10:58:03 -07:00
Andrew Kelley
aff65e74e1 Revert "std.os: gethostname non libc linking using uname like linux"
This reverts commit f8991ba3d48a23b7c73079a017d69d3ead23d398.
2023-07-31 10:54:51 -07:00
Ryan Liptak
9a3adeea6e windows.OpenFile/DeleteFile: Add NetworkNotFound as a possible error
When calling NtCreateFile with a UNC path, if either `\\server` or `\\server\share` are not found, then the statuses `BAD_NETWORK_PATH` or `BAD_NETWORK_NAME` are returned (respectively).

These statuses are not translated into `error.FileNotFound` because they convey more information than the typical FileNotFound error. For example, if you were trying to call `Dir.makePath` with an absolute UNC path like `\\MyServer\MyShare\a\b\c\d`, then knowing that `\\MyServer\MyShare` was not found allows for returning after trying to create the first directory instead of then trying to create `a\b\c`, `a\b`, etc. when it's already known that they will all fail in the same way.
2023-07-27 09:35:29 -07:00
Ryan Liptak
442933936a os.renameatW: Handle OBJECT_NAME_COLLISION from NtSetInformationFile
Partially addresses #16374
2023-07-23 19:09:36 -07:00
Mathew R Gordon
11695745e5 getenv: remove unnessary small key block
The code removed does unnecessary copying in order to create a null-terminated pointer, just to pass it to libc getenv. It only does this for `small keys`, which are under 64 bytes in size.

Instead of going out of the way to add a null byte to a function that takes normal slices, this should just be handled by the loop below, which scans c.environ to find the value
2023-07-18 11:44:23 +02:00
Mathew R Gordon
bf827d0b55
std: Make getenv return 0-terminated slice 2023-07-17 10:57:41 +00:00
dweiller
a7707d8279 std.os.sigprocmask: @bitCast flags parameter 2023-07-11 23:03:21 -07:00
Robin Voetter
a1b583dc24
std: make panic and abort for amdhsa call trap 2023-07-01 21:23:45 +02: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
Andrew Kelley
b20ccff515 std.os: update logic for 64-bit symbol choice
musl v1.2.4 dropped the "64"-suffixed aliases for legacy "LFS64" ("large
file support") interfaces, so this commit changes the corresponding Zig
logic to call the correct names.
2023-06-20 12:55:38 -04: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
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
Andrew Kelley
96acc204b2
Merge pull request #16052 from mikdusan/bsd-getdents
fix bad return types for BSDs getdents and debitrot openbsd
2023-06-17 13:01:52 -07:00
Gregory Mullen
abfa215882 add additional errno (INTR) to tcset,getpgrp calls
Missed this originally because I was only able to trigger it when
SA_RESTART was missing from the sigaction handlers. I'm unconvinced this
is actually a sane way for stdlib to behave (see #15664). But this does
duplicate the existing behavior throughout os.zig which IMO should be
prioritized here.
2023-06-16 22:02:36 -07:00
Jacob G-W
4dac9f54dd plan9: flesh out stdlib enough to allow not using simplified start logic 2023-06-16 08:34:30 -04:00
Michael Dusan
40fc71bf71
openbsd: fix std.c.getdents and debitrot
- fix getdents return type usize → c_int
- special-case process.zig to use sysctl instead of sysctlbyname
- use struct/field pattern for sysctl HW_* constants
2023-06-15 14:48:20 -04:00
Marcos O
ff835cce10
windows.sendto fix (#15831) 2023-06-14 16:24:16 +00:00
Evin Yulo
137b115681 os.connect: mark ECONNABORTED as unreachable
closes #13677
2023-06-13 11:16: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
David CARLIER
f8991ba3d4 std.os: gethostname non libc linking using uname like linux 2023-05-22 12:45:18 +03:00
David CARLIER
05268bb967 std.os: implementing sched_setaffinity wrapper for freebsd 2023-05-14 10:21:42 +03: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
David CARLIER
c7bf8bab38 std.os: adding linux's sched_setaffinity and its wrapper 2023-05-13 21:18:18 +03:00
Gregory Mullen
aa9ea61216 Add tc{set,get}pgrp to std.os.linux 2023-05-11 19:43:06 +03:00
Veikka Tuominen
a111130977
Merge pull request #15317 from devnexen/darwin_rand_nativegen
std: add CCRandomGenerateBytes macOs native api.
2023-05-05 19:52:05 +03:00
Linus Groh
94e30a756e std: fix a bunch of typos
The majority of these are in comments, some in doc comments which might
affect the generated documentation, and a few in parameter names -
nothing that should be breaking, however.
2023-04-30 18:16:04 -07:00
Andrew Kelley
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Andrew Kelley
396bd51c48 enable debugging infrastructure when using C backend
Thanks to @jacobly0's recent enhancements to the C backend, this stuff
works now.
2023-04-26 20:56:21 -07:00
Andrew Kelley
792bbfa301 Sema: fix memcpy alias safety incorrect math
Previously it was not multiplying by the element ABI size. Now, it uses
ptr_add instructions which do math based on the element type.
2023-04-25 11:23:41 -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
David Carlier
c66151a226 std.os: sysctl* wrappers, better warning at compile time 2023-04-24 03:59:35 +03:00
David CARLIER
6248ac535b os: getrandom wrapper favoring it for macOs/iOs only 2023-04-22 21:01:12 +01:00
David CARLIER
dbdafb6cc5 os: expand sched_getaffinity wrapper and update freebsd's cpuset api flags. 2023-04-22 13:54:57 +03:00
Andrew Kelley
dfe3440540 std.os.sendto: use ws2_32 on Windows
closes #9971
2023-04-09 20:08:18 -04: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
Jacob Young
83a208c355 x86_64: implement large cmp 2023-04-02 04:49:53 -04:00
Veikka Tuominen
5e161c102d
Merge pull request #14841 from squeek502/is-cygwin-pty-stuff
`os.isCygwinPty`: Fix a bug, replace kernel32 call, and optimize
2023-03-21 15:03:33 +02:00
Jakub Konka
a23ef3783b os.zig: expose ptrace wrapper for darwin and linux 2023-03-18 21:52:40 +01:00
mllken
da0509750a std.os: handle EPERM errno for bind 2023-03-16 17:41:58 +02:00
Jakub Konka
e1e414e62a std: move os/darwin.zig and related to c/darwin.zig
Move to c/darwin.zig as they really are libSystem/libc imports/wrappers.

As an added bonus, get rid of the nasty `usingnamespace`s which are now
unneeded.

Finally, add `os.ptrace` but currently only implemented on darwin.
2023-03-16 11:42:30 +01:00
Andrew Kelley
e098b287e1 std.fs.File.writevAll: fix behavior for 0-length vectors
The OS layer expects pointer addresses to be inside the application's
address space even if the length is zero. Meanwhile, in Zig, slices may
have undefined pointer addresses when the length is zero. So this
function now modifies the iov_base fields when the length is zero.

This is a companion commit to b4893eb05565b2cb033c6ed88617d73faf878455.
2023-03-15 10:48:15 -07:00