Commit Graph

1052 Commits

Author SHA1 Message Date
Jakub Konka
d3b1cdf508
Merge pull request #13659 from ziglang/arm-win-cpu-features
windows: add native CPU and features detection for Armv8 chips
2022-11-28 21:36:56 +01:00
Ryan Liptak
4e078941d0 os.windows.OpenFile: Add USER_MAPPED_FILE as a possible error
Ran into this when using a program that uses CreateFileMapping and then trying to call `std.fs.createFile` on the mapped file. More info can be found here:

https://stackoverflow.com/questions/41844842/when-error-1224-error-user-mapped-file-occurs

Before:

```
error.Unexpected NTSTATUS=0xc0000243
C:\Users\Ryan\Programming\Zig\zig\lib\std\os\windows.zig:138:40: 0x7ff74e957466 in OpenFile (test.exe.obj)
        else => return unexpectedStatus(rc),
                                       ^
```

After:

```
FAIL (AccessDenied)
C:\Users\Ryan\Programming\Zig\zig\lib\std\os\windows.zig:137:30: 0x7ff7f5b776ea in OpenFile (test.exe.obj)
        .USER_MAPPED_FILE => return error.AccessDenied,
                             ^
```
2022-11-28 18:56:11 +01:00
Jakub Konka
2528189101 windows: fix signature of kernel32.RegOpenKeyExW to use *HKEY 2022-11-28 17:09:03 +01:00
Jakub Konka
d64d7aaac7 windows: drive the registry helper with actual value set for reg entries 2022-11-28 17:07:34 +01:00
Jakub Konka
57bda6524b windows: make registry helper generic over value types 2022-11-28 17:07:34 +01:00
Jakub Konka
f348fbc024 windows: revert changes to definition of HKEY 2022-11-28 17:07:34 +01:00
Jakub Konka
7ea2c7fbcd windows: use RtlQueryRegistryValues to query reg in a single syscall 2022-11-28 17:07:34 +01:00
Jakub Konka
153afed877 windows: impl some primitives for getting registry keys 2022-11-28 17:07:34 +01:00
Jakub Konka
e74b6f0a4b windows: detect couple more aarch64 CPU features 2022-11-28 17:07:34 +01:00
Jakub Konka
6edf9127fe windows: add missing enum values for ProcessorFeatures enumeration 2022-11-28 17:07:34 +01:00
Jakub Konka
625415d738 windows: add zig impl of IsProcessorFeaturePresent syscall 2022-11-28 17:07:34 +01:00
Jakub Konka
1eac3c57ec windows: add processor feature enumeration 2022-11-28 17:07:33 +01:00
bfredl
0196010b0c linux.bpf: expose map_get_next_key
Returning a bool allows to conveniently use it as the condition
of a while loop.

Also remove restriction that ST cannot be double-word.
While imm is only 32-bit, this value is extended into a 64-bit
memory location.
2022-11-27 02:07:49 -05:00
Cody Tapscott
a0af3c7a19 std.os: Fix std.os.chdir for WASI
Test coverage was lacking for chdir() on WASI, allowing this to
regress.

This change makes os.chdir() compile again, and improves the test
logic to use our standard CWD support for WASI.
2022-11-26 22:06:15 +02:00
Ali Chraghi
fca776f8f5 os: windows: fix unhandled error 2022-11-19 22:48:32 +02:00
Stevie Hryciw
04f3067a79 run zig fmt on everything checked by CI 2022-11-18 19:22:42 +00:00
Björn Linse
a09a5ad574 stdlib: make linux.PERF.TYPE non-exhaustive
perf_event_attr.type needs to take a runtime defined value to enable
dynamic PMU:s, such as kprobe and uprobe. This value can exceed
predefined values defined in the linux headers.

reference: perf_event_open(2) man page
2022-11-16 19:02:24 -05:00
Hayden Pope
ceb9fedb47 std.os.linux: Add setitimer and getitimer syscalls 2022-11-15 02:38:28 -05: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
Veikka Tuominen
41b7e40d75
Merge pull request #13418 from ryanschneider/signal-alignment-13216
std.os: fix alignment of Sigaction.handler_fn
2022-11-09 17:36:40 +02:00
bfredl
95f989a05b Fixes to linux/bpf/btf.zig
- the meaning of packed structs changed in zig 0.10. adjust accordingly.
  Use "extern struct" for the cases that directly map to C structs.

- Add new type info kinds, like enum64 and DeclTag

- change the Type enum to use the canonical names from libbpf.
  This is more predictable when comparing with external BPF
  documentation (than invented synonyms that need to be guessed)
2022-11-09 17:14:22 +02:00
r00ster91
b83e4d9656 std.os.linux.T: translate more MIPS values
This fixes the broken terminal for me and thus fixes #13198.
2022-11-06 16:33:50 +02:00
Ryan Schneider
a68b27c252 std.os: improve sigaction test coverage. 2022-11-04 08:07:44 -07:00
Ryan Schneider
7f1f2e653d std.os: fix alignment of Sigaction.handler_fn
Fixes #13216
2022-11-04 08:00:50 -07:00
Ryan Schneider
64b3ffd8ff std.os: Add IGN coverage to sigaction tests
* Should start failing on aarch64 and other word-aligned CPUs.
2022-11-04 08:00:50 -07:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
Nameless
40e84a27d6
change uefi packed structs to new integer backed syntax (#13173)
* std.os.uefi: integer backed structs, add tests to catch regressions

device_path_protocol now uses extern structs with align(1) fields because
the transition to integer backed packed struct broke alignment

added comptime asserts that device_path_protocol structs do not violate
alignment and size specifications
2022-10-30 15:08:32 -04:00
Andrew Kelley
209a0d2a83
Merge pull request #13153 from squeek502/iterator-filename-limits
Windows: Fix Iterator name buffer size not handling all possible file name components
2022-10-29 23:50:37 -04:00
Ryan Liptak
db80225a97 fs: Some NAME_MAX/MAX_NAME_BYTES improvements 2022-10-29 14:30:46 -07:00
Ryan Liptak
33fdc43714 std.fs: Add MAX_NAME_BYTES
Also add some NAME_MAX or equivalent definitions where necessary
2022-10-29 14:30:43 -07:00
Jacob Young
48a2783969 cbe: implement optional slice representation change 2022-10-29 05:58:41 -04:00
daurnimator
f2401a0756 Add sockaddr_vm for vSocckets on Linux 2022-10-27 20:51:35 -04:00
daurnimator
c0c8ee5ae9 Add reboot syscall
Only linux for now
2022-10-27 20:39:35 -04:00
Jacob Young
15df64ade8 std: add cbe hacks to more targets
These are needed because clang doesn't support anything in naked
functions, not even assembly register inputs.
2022-10-25 05:11:29 -04:00
Jacob Young
4765294ca4 cbe: get enough things working to support basic programs
* Enable advanced start support.
 * Enable advanced test_runner support.
 * Zig Language Reference's Hello World now works.
2022-10-25 05:11:29 -04:00
David Gonzalez Martin
680d3cd1fc UEFI: Querying memory map size with no allocation
This makes possible to query the memory map size from EFI firmware
without making any allocation beforehand. This makes possible to be
precise about the size of the allocation which will own a copy of
the memory map from the UEFI application.
2022-10-21 12:17:41 +02:00
Andrew Kelley
9ee4530b9b std.os.windows.OpenFile: handle INVALID_HANDLE ntstatus 2022-10-18 16:52:43 -07:00
Yujiri
8aa21ade8c add tcdrain on linux 2022-10-17 18:01:05 -04:00
bfredl
c750d95417 os.linux: some fixes to BPF module
- For ALU operations, src should be allowed to be an explicit Reg.
- Expose AluOp and JmpOp as public types.
  This makes code generation using BPF as a backend easier,
  as AluOp and JmpOp can be used directly as part of an IR
2022-10-16 11:36:11 -04:00
Ryan Liptak
8bb2e96ac3 std.os.windows: Change HKEY to *opaque {}
The definition of HKEY__ as a struct with an unused int field is only the case in the Windows headers when `STRICT` is defined. From https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict:

> When STRICT is defined, data type definitions change as follows:
>
> -  Specific handle types are defined to be mutually exclusive; for example, you will not be able to pass an HWND where an HDC type argument is required. Without STRICT, all handles are defined as HANDLE, so the compiler does not prevent you from using one type of handle where another type is expected.

Zig's `opaque {}` already gives this benefit to us, so the usage of a struct with an unused field is unnecessary, and it was causing HKEY to have an alignment of 4, which is a problem because there are HKEY constants like HKEY_LOCAL_MACHINE (0x80000002) that are not 4-byte aligned. Without this change, the compiler would not allow something like HKEY_LOCAL_MACHINE to be defined since it enforces pointer alignment.
2022-10-14 15:23:13 -04:00
Jacob Young
f5f28e0d2c io_uring: ignore SOCK_NONEMPTY for reproducible tests
Fixes #12670
2022-10-13 14:58:06 +02:00
Ali Chraghi
fb366f3cd4 std.c: fix incorrect return types
Closes #12964
2022-10-13 13:21:19 +02:00
Andrew Kelley
d08191e146
Merge pull request #12897 from r00ster91/uefi
std.os.uefi: fix some mistakes
2022-10-12 05:28:13 -04:00
mllken
42a3b60c33 io_uring: allow for nullable arguments 2022-10-11 17:49:30 +02:00
Eric Milliken
0b7b4b7e97
std: add linux support for packet sockaddr 2022-10-11 18:46:24 +03:00
r00ster91
47e72132e2 fix: wrong amount of arguments passed to function
I don't know why that one argument was discarded. Is there a reason? It failed to compile.
2022-10-07 19:33:29 +02:00
r00ster91
a56a51e48f fix: wrong return type for _poll
See page 1055 of <https://uefi.org/sites/default/files/resources/UEFI_Spec_2_3_1.pdf>.
2022-10-07 19:33:29 +02:00
r00ster91
4440391d81 fix: wrap function pointers in std.meta.FnPtr 2022-10-07 19:33:29 +02:00
Luuk de Gram
8bbb022500 std: WASI - update to latest snapshot preview 1
This implements the new addition to the API: `sock_accept`.
Reference commit of WASI spec:
0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52

For full details:
0ba0c5e2e3

For entire spec at this commit:
0ba0c5e2e3/phases/snapshot/docs.md
2022-10-03 22:48:57 -04:00
zooster
db5562deb0 std.os.windows: fix HANDLER_ROUTINE callconv 2022-10-03 13:05:38 +03:00