1028 Commits

Author SHA1 Message Date
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
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
ominitay
295451dfe5
std: Replace use of stage1 function pointers 2022-09-29 21:45:30 +03:00
Andrew Kelley
62ecc154d9
Merge pull request #12904 from Vexu/ptrcast
stage2: pointer casting fixes and improvements
2022-09-20 22:02:36 -04:00
Meghan
521c753fda std: fix os.linux.S function signatures to use mode_t 2022-09-20 17:54:32 -04:00
Veikka Tuominen
541b3e3a31 Sema: check pointer qualifiers before implicit cast
Closes #12881
2022-09-20 00:50:13 +03:00
Yusuf Bham
c9f145a50b std.os.uefi: mark BlockIoProtocol and EfiBlockMedia as public 2022-09-09 16:48:54 +03:00
Jakub Konka
3a4c69c018 x86_64: implement Windows x64 calling convention 2022-09-07 22:42:56 +02:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Andrew Kelley
4a27d2aac6 std.os.linux.bpf: fix compile error 2022-08-19 16:45:16 -07:00
Andrew Kelley
445b33cfc0 fix std.os.windows.PathSpace.span
it was returning a pointer to a parameter.
2022-08-19 16:45:16 -07:00
Andrew Kelley
e67a43a673
Merge pull request #12410 from ifreund/sig-err-dfl-ign-fix
std: fix definition of SIG_IGN, SIG_DFL, etc.
2022-08-11 15:05:07 -04:00
Andrew Kelley
a82d7c2063 std: add missing error to windows.WriteFile
I encountered this error today when testing the self-hosted compiler on
Windows.
2022-08-11 06:22:05 -04:00
Isaac Freund
b78f3bf1f1
std: fix definition of SIG_IGN, SIG_DFL, etc.
POSIX specifies that the sa_handler field of the sigaction struct may
be set to SIG_IGN or SIG_DFL. However, the current constants in the
standard library use the function pointer signature corresponding to
the sa_sigaction field instead.

This may not cause issues in practice because the fields usually occupy
the same memory in a union, but this isn't required by POSIX and there
may be systems we do not yet support that do this differently.

Fixing this also makes the Zig interface less confusing to use after
reading the man page.
2022-08-11 12:09:34 +02:00
Meghan Denny
0879cbeed2 remove 'builtin.stage2_arch', Sema is smart enough now 2022-08-07 16:07:08 -07:00
Stephen Gregoratto
b3950d4a88 Update Linux syscall list for 5.19
New changes: memfd_secret implemented for RISC-V.
2022-08-05 15:36:32 +03:00
Ryan Liptak
1a1b7a3afd Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watch
From https://man7.org/linux/man-pages/man7/inotify.7.html

> **IN_MASK_CREATE** (since Linux 4.18)
>
> Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-31 13:00:16 -07:00
Vincent Rischmann
d99c32c2e1
io_uring: add new flags and opcodes 2022-07-23 17:21:17 +03:00
Andrew Kelley
f550c29c4e LLVM: fix lowering of structs with underaligned fields
When lowering a struct type to an LLVM struct type, keep track of
whether there are any underaligned fields. If so, then make it a packed
llvm struct. This works because we already insert manual padding bytes
regardless.

We could unconditionally use an LLVM packed struct; the reason we bother
checking for underaligned fields is that it is a conservative choice, in
case LLVM handles packed structs less optimally. A future improvement
could simplify this code by unconditionally using packed LLVM structs
and then make sure measure perf is unaffected.

closes #12190
2022-07-21 22:51:17 -07:00
Vincent Rischmann
47c58cba59
Fix io_uring tests (#12134)
* io_uring: fix the timeout_remove test

The test does a IORING_OP_TIMEOUT followed with a IORING_OP_TIMEOUT_REMOVE
and assumed we would get the CQEs in the same order.

Linux v5.18 changed how this works and we now get them in the reverse order.

The documentation doesn't explicitly say which CQE we should get first
so just make the test work with both cases.

* io_uring: fix the remove_buffers test

The original test was buggy but accidentally worked with kernels < 5.18

The test assumed that IORING_OP_REMOVE_BUFFERS removed from the start of
but in fact the documentation doesn't specify which buffer is removed,
only that a certain number of buffers are removed.

Starting with the kernel 5.18 the check for the `used_buffer_id` fails.
Turns out that previous kernels removed buffers in such a way that the
remaining buffer for this read would always be 0, however this isn't
true anymore.

Instead of checking a specific value just check that the `used_buffer_id`
corresponds to a valid ID.
2022-07-16 10:05:11 -05:00
Andrew Kelley
c34392b24e std.os.linux.io_uring: work around LLVM bug
See #12014
2022-07-05 21:54:05 -07:00
Jonathan Marler
93ac87c1bd Mark fstype argument to mount as optional
The fstype argument to the mount system call can be null.  To see an
example run "strace -e trace=mount unshare -m":

```
mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0
...
```
2022-07-05 15:04:31 -04:00
Andrew Kelley
314ce5465d std: better definition for std.os.linux.epoll_event
The previous definition depends on a non-lang-spec-compliant memory
layout for packed structs, which happens to trigger #11989 in stage2.

This commit changes the struct to be an extern struct with an
align(4) field. However, stage1 cannot handle this, so conditional
compilation logic is used to select different struct definitions
depending on stage1 vs stage2.

This works around #11989 but does not solve the underlying problem -
putting an extern union inside a packed struct will still trigger the
assert.

After this, both stage1 and stage2 std lib tests run assertion-clean
with a debug LLVM 13.
2022-07-03 22:18:05 -07:00
Philipp Lühmann
bb2929ba08
zig fmt: fix idempotency with newlines surrounding doc comment
Fixes: https://github.com/ziglang/zig/issues/11802
2022-06-28 21:38:28 +02:00
Andrew Kelley
0b8bd9b2b4 std.os.linux.clone: upgrade to stage2 fn ptr semantics 2022-06-27 18:27:06 -07:00
Jonathan Marler
523fae420b add const to msghdr_const iov and control pointers
alongside the typical msghdr struct, Zig has added a msghdr_const
type that can be used with sendmsg which allows const data to
be provided.  I believe that data pointed to by the iov and control
fields in msghdr are also left unmodified, in which case they can
be marked const as well.
2022-06-07 15:23:44 -04:00