Commit Graph

719 Commits

Author SHA1 Message Date
Sébastien Marie
2a0a11aa66 openbsd: make dl_phdr_info cross arches
introduce Addr and Half definition to std.elf, and use them for dl_phdr_info
2020-10-25 20:46:28 -04:00
Koakuma
cbc8750502 Separate libc stat and kernel stat definitions 2020-10-25 23:52:08 +07:00
Koakuma
3ce9428e3d Various formatting fixes 2020-10-25 21:53:16 +07:00
Koakuma
1a362ea5b0 Fix sparc64 bits definitions 2020-10-25 21:38:39 +07:00
Koakuma
785153d756 Fix SA_* constants for sparc64 2020-10-25 20:39:32 +07:00
Koakuma
f018201009 Predict error-less path on syscalls 2020-10-25 20:07:18 +07:00
Koakuma
2e7a4758b3 Add back ppc input/output/clobber definitions
Accidentally removed when rebasing, this adds it back.
2020-10-25 13:39:22 +07:00
Koakuma
1d3abb761d "zig fmt" on lib/std/os/linux.zig 2020-10-25 13:38:08 +07:00
Koakuma
e7369ada93 Fix boolean operator in if clause 2020-10-24 21:33:40 +07:00
Koakuma
73e62f22ec Fix sigaction(2) call on sparc64 2020-10-24 20:05:37 +07:00
Koakuma
cdbf66e36e Add sparc64-specific values for the various SA_ and SIG_ constants 2020-10-24 20:05:34 +07:00
Koakuma
268516d5d9 Fix constants 2020-10-24 20:04:18 +07:00
Koakuma
238f253de9 Move comptime out 2020-10-24 20:03:41 +07:00
Koakuma
300cfbf252 Add TLS implementation for sparc64 2020-10-24 20:03:40 +07:00
Koakuma
6146f81c6e Add pipe(2) support 2020-10-24 20:03:37 +07:00
Koakuma
dba009fd21 Account for the delay slot 2020-10-24 20:01:32 +07:00
Koakuma
c29da84c0e Add sp loading 2020-10-24 20:01:29 +07:00
Koakuma
23433fb317 Fix register naming 2020-10-24 19:59:05 +07:00
Koakuma
de06b0a635 Add sparc64 linux bits 2020-10-24 19:59:04 +07:00
Koakuma
e5a11020cc Add sparc64 syscall interface 2020-10-24 19:59:04 +07:00
Andrew Kelley
569f7ce49e Merge branch 'improve-windows-networking'
of https://github.com/BarabasGitHub/zig into
BarabasGitHub-improve-windows-networking

Conflicts:
 lib/std/os.zig

This commit resolves conflicts with the changes to std.os which removed
the EAGAIN error handling interactions with the event loop. The solution
to the conflict was to apply EAGAIN => return error.WouldBlock into the
improved windows networking branch.
2020-10-22 16:59:15 -07:00
Andrew Kelley
e02655798f
Merge pull request #6743 from LemonBoy/someppc64stuff
Some ppc64 stuff
2020-10-22 17:39:26 -04:00
LemonBoy
0c355bef9e std: Slim down the error code path in initStaticTLS
Calling @panic made the executable ~30x times bigger, use a simple
`abort()` and let the user figure out what went wrong.

Supporting ARMv6 (and earlier?) platforms is not a priority.

Closes #6676
2020-10-21 23:35:06 -04:00
LemonBoy
96fe971051 std: Minor changes to startup code
* Smaller startup sequence for ppc64
* Terminate the frame-pointer chain when executing _start
* Make the stack traces work on ppc64
* Make the stack traces coloured on ppc64, some ioctls numbers are
  different and the whole set of constants should be audited.
2020-10-19 15:15:43 +02:00
Andrew Kelley
05b1a7414e code cleanups
* in selfExePath, return errors instead of defaulting to bogus data
 * less invasive edits to the logic of link/Elf.zig
 * less indentation
2020-10-17 17:52:09 -07:00
Andrew Kelley
03f7cffce9 Merge branch 'openbsd-minimal' of https://github.com/semarie/zig into semarie-openbsd-minimal 2020-10-17 17:34:43 -07:00
Sebastien Marie
35a7247a2c
Merge branch 'master' into openbsd-minimal 2020-10-17 17:38:23 +02:00
Jan Prudil
aadccc4206 Make std.meta.Int accept a signedness parameter 2020-10-17 14:09:59 +02:00
Andrew Kelley
d87bd3d8af fixups regarding windows wide strings
* remove GetModuleHandleA from kernel32.zig. use of A functions
   considered harmful.
 * make it a compile error to expose WinMain instead of wWinMain. same
   thing.
 * start code declares wWinMainCRTStartup instead of WinMainCRTStartup
   when it has the choice.
2020-10-15 19:37:55 -07:00
Andrew Kelley
c7c38e7279 Merge branch '5002-fix-entrypoint-with-winmain' of https://github.com/AnthonyYoManz/zig into AnthonyYoManz-5002-fix-entrypoint-with-winmain 2020-10-15 18:22:12 -07:00
Andrew Kelley
a66449c1ed
Merge pull request #6616 from fengb/darwin-rusage
Darwin rusage
2020-10-15 20:49:54 -04:00
Vignesh Rajagopalan
2ab0c7391a Rename .macosx to .macos 2020-10-12 18:56:25 -04:00
Sébastien Marie
f33a610c84 add minimal openbsd support 2020-10-11 08:23:36 +00:00
Benjamin Feng
9de0f15b8e Rename ix_rss -> ixrss 2020-10-08 15:31:36 -05:00
Benjamin Feng
fd3f676cdb Pull in Darwin definitions for rusage 2020-10-08 15:19:52 -05:00
Tadeo Kondrak
2b4b03d301
Update zig files for opaque type syntax 2020-10-06 22:08:25 -06:00
Joran Dirk Greef
e9ba12f456 Test the range of user_data bits 2020-10-05 09:36:07 +02:00
xackus
1b4296831a simplify api and add smoke test 2020-10-04 23:57:49 +02:00
xackus
4ec26be424 implement {get, set}rlimit for linux 2020-10-04 23:56:10 +02:00
Joran Dirk Greef
9be2941091 Split openat/close test into two separate tests
If an older kernel fails the `openat` test because of `AT_FDCWD`
then we don't want to skip the `close` test.
2020-10-04 17:48:05 +02:00
Joran Dirk Greef
958ff087f2 Use const wherever possible 2020-10-04 16:57:04 +02:00
Joran Dirk Greef
72bdfa5bdd Skip openat test only for older kernels that do not fully support AT_FDCWD 2020-10-04 16:05:52 +02:00
Joran Dirk Greef
9091fcbe9d Improve openat/accept test debugging 2020-10-04 15:11:09 +02:00
Joran Dirk Greef
6a53f4be4b Add openat(), close(), connect(), send(), recv(), as well as tests
Removes non-essential .hardlink_with_next_sqe() and .drain_previous_sqes().
2020-10-04 13:15:39 +02:00
Joran Dirk Greef
3d2de6cfba Use load relaxed semantics when reading the SQPOLL wakeup flag 2020-10-04 13:14:57 +02:00
Joran Dirk Greef
69a55fc560 Allow for advanced non-sequential SQE allocation schemes
Decouples SQE queueing and SQE prepping methods to allow for non-sequential
SQE allocation schemes as suggested by @daurnimator.

Adds essential SQE prepping methods from liburing to reduce boilerplate.

Removes non-essential .link_with_next_sqe() and .use_registered_fd().
2020-10-04 13:01:41 +02:00
Joran Dirk Greef
e32c7d06e5 Limit entries to u12, add errors for invalid entries, use mem.zeroInit 2020-10-04 12:49:48 +02:00
Joran Dirk Greef
61ec6cb6d3 Expose available kernel features 2020-10-04 12:48:08 +02:00
Joran Dirk Greef
c5b4fcaa1c Add IORING_FEAT_POLL_32BITS 2020-10-03 17:43:08 +02:00
Joran Dirk Greef
a9b107045f Use load acquire semantics when reading the SQPOLL wakeup flag
Ensures that the wakeup flag is read after the tail pointer has been
written. It's important to use memory load acquire semantics for the
flags read, otherwise the application and the kernel might not agree on
the consistency of the wakeup flag, leading to I/O starvation.

Refs: 6768ddcc56
Refs: https://github.com/axboe/liburing/issues/219
2020-10-03 14:34:42 +02:00
Joran Dirk Greef
95def89c23 Handle EBADFD (ring fd in bad state) in enter() 2020-10-03 14:34:01 +02:00
Andrew Kelley
fe117d9961
Merge pull request #6250 from ziglang/stage2-zig-cc
move `zig cc`, `zig translate-c`, `zig libc`, main(), and linking from stage1 to stage2
2020-09-30 04:28:19 -04:00
Ryan Liptak
254ee89def Windows: Handle ACCESS_DENIED in DeviceIoControl
This was causing the Dir.readLink test to fail for me locally with error.Unexpected NTSTATUS=0xc0000022. Not sure if PRIVILEGE_NOT_HELD is actually possible or not.
2020-09-29 20:54:45 -04:00
Andrew Kelley
af64fd2f42 Merge remote-tracking branch 'origin/master' into stage2-zig-cc
This merges in the revert that fixes the broken Windows build of master
branch.
2020-09-29 17:26:09 -07:00
Jakub Konka
bb636cb3bf Revert "Fix for Windows: std.os.windows.DeleteFile()" 2020-09-29 19:35:44 -04:00
Andrew Kelley
750b00c642 Merge remote-tracking branch 'origin/master' into stage2-zig-cc 2020-09-29 00:27:48 -07:00
Jakub Konka
e60939bfaa
Merge pull request #6397 from suirad/fix-5537
Fix for Windows: std.os.windows.DeleteFile()
2020-09-27 21:59:29 +02:00
Woze Parrrot
ed357f9897 uefi system_table 2020-09-27 03:15:18 -04:00
Suirad
43cd9eb110 Add clarification comment 2020-09-25 18:11:31 -05:00
Suirad
f78652484a Stdlib fix for os.windows.deleteFile to fail with
a proper error when attempting to delete a directory that isnt empty
2020-09-25 18:09:05 -05:00
Andrew Kelley
0c70bb4fce Merge remote-tracking branch 'origin/master' into stage2-zig-cc 2020-09-21 21:16:46 -07:00
Joran Dirk Greef
5f99d2c240 Define SPLICE, PROVIDE_BUFFERS, REMOVE_BUFFERS and TEE opcodes and flags 2020-09-21 20:15:14 +02:00
Joran Dirk Greef
2d8df2b745 Use @intCast instead of @truncate 2020-09-21 12:03:52 +02:00
Joran Dirk Greef
7719abbf54 Add flags to queue_fsync() signature as per liburing 2020-09-21 11:09:37 +02:00
Joran Dirk Greef
57603fd26d Use @intCast instead of @truncate on io_uring_enter() result 2020-09-21 11:09:09 +02:00
Joran Dirk Greef
575ed941d7 Cache mask instead of dereferencing mask pointer 2020-09-21 11:07:11 +02:00
Joran Dirk Greef
843c104fc9 Add io_uring syscalls to os.bits.linux.mips.SYS
As per lib/libc/musl/arch/mips/bits/syscall.h.in:

```c
```
2020-09-21 10:39:58 +02:00
Joran Dirk Greef
a853f00410 Add IORING_FEAT_FAST_POLL 2020-09-20 19:51:23 +02:00
Joran Dirk Greef
77903f8d4e Test structs and offsets 2020-09-20 18:45:44 +02:00
Joran Dirk Greef
e51728a1b4 Make enter(), flush_sq(), sq_ring_needs_enter(), cq_ring_needs_flush() public
These will also be needed by any custom helpers
2020-09-20 15:54:31 +02:00
Joran Dirk Greef
40293a0643 Add safety checks 2020-09-20 15:41:22 +02:00
Joran Dirk Greef
f22eea82c4 Fix opcode support detection for read/write test 2020-09-20 15:33:48 +02:00
Joran Dirk Greef
b672dc7abf Use os.fd_t instead of i32 and assert against c_int for syscall safety 2020-09-20 14:59:40 +02:00
Joran Dirk Greef
abebacda32 Handle all possible syscall errors and bring errors in line with os.zig 2020-09-20 14:21:44 +02:00
Joran Dirk Greef
4bc1b7a7ac Fix io_uring_sqe to use the names of the first member of each union
Now we're really future-proof... no more `opflags` creeping in.

When anonymous unions land, we can start using `accept_flags` etc.

Until then, code using this struct won't break when the kernel adds features.

Refs: https://github.com/ziglang/zig/issues/6349
Refs: https://github.com/ziglang/zig/issues/985
2020-09-19 18:50:24 +02:00
Joran Dirk Greef
92407bfcd7 Upgrade check_errno() to an exhaustive switch (safer) 2020-09-19 18:29:50 +02:00
Joran Dirk Greef
ba18420b27 Zero the SQE slot and assign, instead of initializing with default values 2020-09-19 18:17:06 +02:00
Joran Dirk Greef
e7ae6f2fad Remove default values from io_uring_sqe struct 2020-09-19 18:14:41 +02:00
Joran Dirk Greef
f4df2f091a Allow the kernel to drive feature detection 2020-09-19 17:31:39 +02:00
Joran Dirk Greef
64ae9a6a87 Rename to error.SubmissionQueueFull 2020-09-19 16:54:44 +02:00
Joran Dirk Greef
c1f9d10b6a Remove unused import aliases 2020-09-19 16:51:35 +02:00
Joran Dirk Greef
9fabae2a28 Return error.UnsupportedKernel for ENOSYS 2020-09-19 16:47:05 +02:00
Joran Dirk Greef
cb591285d7 Use linux.IORING_SQ_CQ_OVERFLOW 2020-09-19 16:20:21 +02:00
Joran Dirk Greef
31533eb743 Move to std/os/linux 2020-09-19 16:18:04 +02:00
Joran Dirk Greef
873d1c80b3 Add splice_fd_in to io_uring_sqe and future-proof for anonymous unions 2020-09-19 16:15:17 +02:00
Ryan Liptak
5e3fa0e94f Add rename to std.fs API
- Moves fs.rename functions to fs.renameAbsolute to match other functions outside of fs.Dir
- Adds fs.Dir.rename that takes two paths relative to the given Dir
- Adds fs.rename that takes two separate Dir's that the given paths are relative to (for renaming across directories without having to make the second path relative to a single directory)
- Fixes FileNotFound error return in std.os.windows.MoveFileExW
- Returns error.RenameAcrossMountPoints from renameatW
  + Matches the RenameAcrossMountPoints error return in renameatWasi/renameatZ
2020-09-17 17:22:26 -04:00
Joran Dirk Greef
d966fe6319 Add IORING_SQ_CQ_OVERFLOW to std/os/bits/linux.zig 2020-09-17 19:53:34 +02:00
Andrew Kelley
f82b1831f7 std: handle sharing violation when deleting a file on windows 2020-09-15 15:24:13 -07:00
Matt Knight
88dacd3b70
changed to opaque 2020-09-13 09:53:20 -07:00
Matt Knight
1afbf4fb21
removed all those kern aliases 2020-09-13 09:43:49 -07:00
Matt Knight
cb5f76bb1c
got booleans wrong 2020-09-13 09:24:56 -07:00
Matt Knight
b043a31889
added helper definitions 2020-09-12 23:45:35 -07:00
Isaac Freund
b6f4601545
std: add securebits definitions for linux 2020-09-11 22:32:23 +02:00
Isaac Freund
7b961a876b
std: add prctl definition for linux 2020-09-11 22:32:22 +02:00
Andrew Kelley
800c5de2ae update the stack trace test case for lines added to start.zig 2020-09-10 14:40:33 -07:00
Andrew Kelley
2315331d23
Merge pull request #5527 from shawnanastasio/ppc64le
Implement support for powerpc64{,le}
2020-09-10 15:56:27 -04:00
Bas van den Berg
127fa80090 implement poll for windows with WSAPoll (only available on vista and higher) 2020-09-10 20:20:27 +02:00
Jens Goldberg
5bf3e54018 Add the Linux TCP socket options 2020-09-08 13:00:07 -04:00
Andrew Kelley
f6f0e09456
Merge pull request #6267 from mattnite/btf
BPF: add BTF
2020-09-08 12:59:31 -04:00
Bas van den Berg
44f877d18b change socklen_t to u32 and add appropriate casts when calling WSA 2020-09-08 12:24:39 +02:00
Bas
4a6ca735d9
Merge branch 'master' into improve-windows-networking 2020-09-08 11:56:59 +02:00
Matt Knight
a496f94be9 added map create, update, delete, and prog load 2020-09-07 15:42:41 -04:00
Matthew Knight
db7a238297
BPF: add some more documentation (#6268)
* added documentation for ringbuffers, which context type maps to which program type, and added some formatting
2020-09-07 15:41:29 -04:00
Matt Knight
b878a64a5f
added license comments 2020-09-07 12:26:41 -07:00
Matt Knight
cf3194804e
changed enums to lower case 2020-09-07 07:17:21 -07:00
Matt Knight
e7547eeefa
fixed missing 'packed' keyword 2020-09-06 22:31:35 -07:00
Matt Knight
caaa9ad2af
added btf 2020-09-06 21:44:16 -07:00
Matt Knight
67817b230f
fixed improper builtin import 2020-09-06 17:09:25 -07:00
Matt Knight
cf06817768
improved compile error message 2020-09-06 16:21:05 -07:00
Matt Knight
a993c7dd1b
removed redundant pseudo insn 2020-09-06 16:19:49 -07:00
Matt Knight
295f09eadc
implemented and testing op codes for instructions documented in the unofficial bpf insn reference 2020-09-06 16:12:27 -07:00
Veikka Tuominen
41bbadbb9a
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
2020-09-05 13:58:02 +03:00
Andrew Kelley
1034459170
Merge pull request #6243 from ifreund/uid-gid-cleanup
std: clean up usage of uid_t/gid_t, add seteuid/setegid to std.os
2020-09-03 18:05:59 -04:00
Vexu
1df0f3ac24
update uses of deprecated type field access 2020-09-03 18:10:40 +03:00
Isaac Freund
01a365f1b0
std: ensure seteuid/setegid do not change saved id 2020-09-03 15:16:26 +02:00
Isaac Freund
e8a2aecd2f
std: fix linux uid_t, use uid_t/gid_t in std.os
- correct uid_t from i32 to u32 on linux
- define uid_t and gid_t for OSes missing definitions
- use uid_t/gid_t instead of plain u32s throughout std.os
2020-09-03 15:08:37 +02:00
Bas van den Berg
0a40a61548 os.send(to) and os.recv(from) functions made to work on windows. 2020-09-03 13:23:48 +02:00
Jens Goldberg
68818983ae Split the sync tests into sync and fsync 2020-09-03 09:52:26 +00:00
Jens Goldberg
e747d2ba17 Add C declarations and tests for the sync functions 2020-09-03 07:49:18 +00:00
Aransentin
25f6663304 Add the sync functions 2020-09-02 22:16:40 +00:00
Bas van den Berg
d80554cedf Made some changes and additions to the networking to make it work on windows. 2020-09-02 23:53:29 +02:00
Sahnvour
ac85befbb4 handle lack of privilege to create symbolic links on windows 2020-08-30 06:52:53 +02:00
wozeparrot
00301bbdd3 fix SimpleTextInputProtocol 2020-08-29 20:24:59 +03:00
Matthew Knight
0fa3cfdb4a
Bpf: move under os/linux instead of bits (#6126)
* moved bpf syscall, added some bpf instructions and tests

* had to move bpf out of bits so that a freestanding target could import it

* removed line

* fixed imports
2020-08-22 15:08:01 -04:00
Matt Knight
80fabe1850 fixed bpf namespace 2020-08-21 11:40:35 -07:00
Matt Knight
bc1536f4bf decided to split up loading of 64-bit immediates 2020-08-21 11:40:35 -07:00
Matt Knight
7f1378909b moved bpf syscall, added some bpf instructions and tests 2020-08-21 11:40:35 -07:00
heidezomp
1ca49b92c6 add UTIME_NOW and UTIME_OMIT constants for use in utimensat/futimens
copied from lib/libc/include/generic-musl/sys/stat.h
2020-08-20 17:02:58 -04:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
23c427b5fb windows: match the same error code for EBADF 2020-08-19 20:51:06 -07:00
StrangeBug
59711becc7 Add handler for INVALID_HANDLE to prevent infinite loop when stderr is not available. 2020-08-19 20:49:25 -07:00
Matthew Knight
d605af511a
added bpf() syscall and some supporting structs (#6061)
* added bpf syscall and some supporting structs

* moved bpf to bits and added flags
2020-08-17 22:17:04 -04:00
Andrew Kelley
ae2c88754d std: signalfd: fix the types of things; add test 2020-08-17 16:19:57 -07:00
Luna
2deb07a001 rename signalfd4 to signalfd 2020-08-17 16:05:35 -07:00
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04:00
Jakub Konka
901bf0a2e2 Convert prefix from u8 to u16 programmatically 2020-08-10 20:44:22 +02:00
Jakub Konka
73b9f65746 Validate DOS path before returning
And some other minor refactors which address more review comments.
2020-08-10 16:39:02 +02:00
Jakub Konka
cd8e6b66d0 Address some review comments 2020-08-09 10:47:52 +02:00
Jakub Konka
310aa87198 Fix alignment issue 2020-08-07 23:21:06 +02:00
Jakub Konka
bdda8fa7a8 Redo GetFinalPathNameByHandle using DeviceIoControl
This commit reimagines `std.os.windows.GetFinalPathNameByHandle`
using `DeviceIoControl` to query the OS mount manager for the DOS
(symlink) paths for the given NT volume name. In particular,
it uses `IOCTL_MOUNTMGR_QUERY_POINTS` ioctl opcode to query the
manager for the available moount points.
2020-08-07 11:33:05 +02:00
Jakub Konka
e8abfef2aa Add docs 2020-08-06 23:56:37 +02:00
Jakub Konka
2628a8846e Use NtQueryInformationFile unless unavailable
Favour newer API which uses `NtQueryInformationFile` with class flags
`FileNormalizedNameInformation` and `FileVolumeNameInformation`
instead of lower-level `NtQueryObject`. `NtQueryObject` is still
used as a fallback in case the former are unavailable.
2020-08-06 23:56:37 +02:00
Jakub Konka
747d46f22c Initial draft of GetFinalPathNameByHandle
This commit proposes an initial draft of `GetPathNameByHandle` function
which wraps NT syscalls and strives to emulate (currently only
partially) the `kernel32.GetFinalPathNameByHandleW` function.
2020-08-06 23:56:37 +02:00
Andrew Kelley
cf4936bcb0 std.os tests: improve robustness of "symlink with relative paths" 2020-08-04 23:45:53 -07:00
Andrew Kelley
d159ba9295 zig fmt 2020-08-04 23:04:20 -07:00
Jakub Konka
4d9eff4bdb Add prelim openW and openatW
Added POSIX functions targeting Windows pass `open` and `openat`
smoke tests.
2020-07-31 16:41:25 +02:00
Jakub Konka
a694f575ad Add some os.open and os.openat smoke tests 2020-07-31 16:33:02 +02:00
Jakub Konka
390194431e Use NtCreateFile directly in ReadLink
This shaves off one syscall (we use one instead of two if we were to
use `windows.OpenFile` wrapper). Clean up flag generation in `OpenFile`.
Hopefully, we're in a much better place to *almost* support `openW`
and `openatW`.
2020-07-31 16:32:21 +02:00
Jakub Konka
8981b18fee Move delete file logic into windows.DeleteFile fn
This way, we can remove more `kernel32` calls such as `RemoveDirectoryW`
or `DeleteFileW`, and use `std.os.windows.DeleteFile` instead which
is purely NT-based.
2020-07-31 16:31:51 +02:00
Jakub Konka
66bbe4ec4c Refactor internal Win routines to reuse OpenFile
This covers mainly `ReadLink` and `CreateSymolicLink` functions.
2020-07-31 16:31:44 +02:00
Jakub Konka
a89d5cfc3e Remove CreateDirectoryW and CreateFileW calls
Replace them with `std.os.windows.OpenFile` instead. To allow
creation/opening of directories, `std.os.windows.OpenFileOptions`
now features a `.expect_dir: bool` member which is meant to emualate
POSIX's `O_DIRECTORY` flag.
2020-07-31 16:31:23 +02:00
Jakub Konka
547e520359 Split DeviceIoControl path into two fn call paths
As discussed in the previous commit, it would be better to avoid
function pointers to syscalls and explicitly split the control
path into two function calls instead. This commit addresses that
for `std.os.windows.DeviceIoControl`.
2020-07-29 14:17:49 +02:00
Jakub Konka
4fdfaf69c8 Add Zig wrapper for kernel32.DeviceIoControl
This commit adds a Zig wrapper for `kernel32.DeviceIoControl` which
applies ReactOS logic for deciding whether to use
`ntdll.NtDeviceIoControlFile` or `ntdll.NtFsControlFile` based on the
value of passed `IO_CONTROL_CODE`. The decision logic is based on the
logic found in ReactOS found in the following [link].

Thanks to Daurnimator for finding this bit in ReactOS!

[link]: https://doxygen.reactos.org/d3/d74/deviceio_8c.html
2020-07-29 01:19:10 +00:00
Jakub Konka
f0ed2ed67f Replace DeviceIoControl with FsControlFile
This commit replaces `windows.DeviceIoControl` with
`windows.FsControlFile` which is a wrapper around the NT-based
syscall `ntdll.NtFsControlFile`.
2020-07-27 19:45:23 +00:00
luna
a6626802f9
Add signalfd support (#5322)
* add signalfd_siginfo to linux bits

* Cast sigaddset's shift value to u5

* linux: add signalfd4

* os: add signalfd
2020-07-22 17:26:27 -04:00
Jakub Konka
65581b37cb Enable std.os.symlinkat tests on Windows 2020-07-22 08:51:23 +02:00
Jakub Konka
3d41d3fb6e Draft out ReadLinkW using NT primitives 2020-07-22 08:51:23 +02:00
Jakub Konka
4887350bf4 Finish drafting CreateSymolicLink using NT calls 2020-07-22 08:51:23 +02:00
Jakub Konka
99f0e64fa0 Draft out dir symlinks branch 2020-07-22 08:51:23 +02:00
Jakub Konka
c53bcd027f Start drafting CreateSymbolicLink using ntdll syscalls 2020-07-22 08:51:23 +02:00
Jakub Konka
e0b77a6b77 Ensure Dir.deleteTree does not dereference symlinks
Otherwise, the behaviour can lead to unexpected results, resulting
in removing an entire tree that's not necessarily under the root.
Furthermore, this change is needed if are to properly handle dir
symlinks on Windows. Without explicitly requiring that a directory
or file is opened with `FILE_OPEN_REPARSE_POINT`, Windows automatically
dereferences all symlinks along the way. This commit adds another
option to `OpenDirOptions`, namely `.no_follow`, which defaults to
`false` and can be used to specifically open a directory symlink on
Windows or call `openat` with `O_NOFOLLOW` flag in POSIX.
2020-07-22 08:51:22 +02:00
Jakub Konka
3c8ceb674e Fix Windows build 2020-07-22 08:51:22 +02:00
Jakub Konka
fc7d87fef1 Move symlink to fs.symlinkAbsolute with SymlinkFlags
This way `std.fs.symlinkAbsolute` becomes cross-platform and we can
legally include `SymlinkFlags` as an argument that's only used on
Windows. Also, now `std.os.symlink` generates a compile error on
Windows with a message to instead use `std.os.windows.CreateSymbolicLink`.
Finally, this PR also reshuffles the tests between `std.os.test` and
`std.fs.test`.
2020-07-22 08:51:22 +02:00
Jakub Konka
22362568cf Refactor 2020-07-22 08:51:22 +02:00
Jakub Konka
3ab5e6b1a9 Ensure we use Win32 prefix in Win32 calls 2020-07-22 08:51:22 +02:00
Jakub Konka
cc9c5c5b0e Handle relative/absolute symlinks; add more tests 2020-07-22 08:51:22 +02:00
Jakub Konka
a8a02dfbfa Add smoke test for dir symlinks 2020-07-22 08:51:22 +02:00
Jakub Konka
30f1176a54 Add SymlinkFlags needed to create symlinks to dirs on Win 2020-07-22 08:51:22 +02:00
Jakub Konka
4894de2b32 Fix readlink smoke test 2020-07-22 08:51:22 +02:00
Jakub Konka
99e3e29e2e Refactor 2020-07-22 08:51:22 +02:00
Jakub Konka
c47cb8d09f Fix unlinkatW to allow file symlink deletion on Windows 2020-07-22 08:51:22 +02:00
Jakub Konka
ae8abedbed Use NtCreateFile to get handle to reparse point 2020-07-22 08:51:22 +02:00
Jakub Konka
d17c9b3591 Fix incorrect byte format of REPARSE_DATA_BUFFER struct 2020-07-22 08:51:22 +02:00
Jakub Konka
9b00dc941b Use windows.CreateFileW to open the reparse point 2020-07-22 08:51:22 +02:00
Jakub Konka
49b5815364 Add windows.ReadLink similar to OpenFile but for reparse points only 2020-07-22 08:51:22 +02:00
Jakub Konka
92d11fd4e9 Debug readlinkW using OpenFile 2020-07-22 08:51:22 +02:00
Jakub Konka
791795a63a Finish symlink implementation on Windows 2020-07-22 08:51:22 +02:00
Jakub Konka
515c663cd6 Add readlink smoke test 2020-07-22 08:51:22 +02:00
Jakub Konka
cc83d92b0b Start drafting out os.readlink on Windows 2020-07-22 08:51:22 +02:00
Anthony Arian
3658dd5e89 Merge branch 'master' of https://github.com/ziglang/zig into 5002-fix-entrypoint-with-winmain 2020-07-20 10:25:54 +01:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Shawn Anastasio
ec0d775524 Implement std.os for powerpc64{,le} 2020-07-01 16:10:49 -05:00
Andrew Kelley
0cfe8e5d6f
Merge pull request #5064 from marler8997/newAllocator
new allocator interface
2020-06-27 18:21:00 -04:00
Ryan Liptak
626b5eccab Move fs-specific tests from os/test.zig to fs/test.zig
The moved tests do not use `std.os` directly and instead use `std.fs` functions, so it makes more sense for them to be in `fs/test.zig`
2020-06-27 10:17:08 +00:00
Jonathan Marler
dc9648f868 new allocator interface 2020-06-26 13:34:48 -06:00
Jakub Konka
be78b7b648 Implement fstatat targeting WASI
Also, add more informative `@compileError` in a few `std.os` functions
that would otherwise yield a cryptic compile error when targeting
WASI. Finally, enhance docs in a few places and add test case for
`fstatat`.
2020-06-24 21:00:21 +02:00
Jakub Konka
c950f0c6c3 Enhance std.os.readlinkat coverage
Adds Windows stub (still needs to be implemented on Windows),
adds WASI implementation, adds unit test testing basic chain of
ops: create file -> symlink -> readlink.
2020-06-22 09:40:06 +02:00
Jakub Konka
64078ca924 Enhance std.os.symlinkat coverage
Fixes `std.os.symlinkat` compile errors, adds Windows stub (still
needs to be implemented), adds WASI implementation.
2020-06-22 09:14:51 +02:00
Nameless
56220449ab Add errors to windows.WSAStartup and WSACleanup 2020-06-21 00:13:06 -04:00
Andrew Kelley
da549a72e1 zig fmt 2020-06-20 18:39:15 -04:00
Anthony Arian
5e48ed4a8d Implement WinMain Callers that Pass Valid Params 2020-06-15 22:46:16 +01:00
Ryan Liptak
f839d34baa std.os.windows.OpenFile: Handle FILE_IS_A_DIRECTORY status
Fixes #5533
2020-06-04 22:53:23 -04:00
Ryan Liptak
95a5f6bf2d Windows: Handle ERROR_DIRECTORY in std.fs.deleteDirAbsolute when called on a file path
ERROR_DIRECTORY (267) is returned from kernel32.RemoveDirectoryW if the path is not a directory. Note also that os.DirectDirError already includes NotDir

Before: error.Unexpected: GetLastError(267): The directory name is invalid.
After: error: NotDir
2020-06-04 22:52:53 -04:00
Andrew Kelley
7fd937fef4 cleanups
* improve docs
 * add TODO comments for things that don't have open issues
 * remove redundant namespacing of struct fields
 * guard against ioctl returning EINTR
 * remove the general std.os.ioctl function in favor of the specific
   ioctl_SIOCGIFINDEX function. This allows us to have a more precise
   error set, and more type-safe API.
2020-06-02 15:28:46 -04:00
Luna
6623efd7d4 Change ioctl's request type to i32 2020-06-02 14:56:19 -04:00
Luna
7c71054286 Replace syscall3 to os.ioctl 2020-06-02 14:56:19 -04:00
Luna
c8468bed42 Add std.os.ioctl 2020-06-02 14:56:19 -04:00
Luna
aebf28eba3 Make ifru fields sentinel-terminated 2020-06-02 14:56:06 -04:00
Luna
c60daa255f Replace C types in declarations 2020-06-02 14:56:06 -04:00
Luna
10ea2db5cb Replace C shorts by integer types 2020-06-02 14:56:06 -04:00
Luna
cb649b769c Fix ifreq definition 2020-06-02 14:56:06 -04:00
Luna
2c641c93da Only resolve scope id when needed 2020-06-02 14:56:06 -04:00
Luna
9c200035f3 Add some interface structs to linux bits 2020-06-02 14:56:06 -04:00
Andrew Kelley
c6764fd254
Merge pull request #5475 from marler8997/windowsDns
support name resolution on windows
2020-06-01 15:33:05 -04:00
Alexandros Naskos
215a0d61ab Fix evented builds on windows with runtime safety on 2020-06-01 14:22:45 -04:00
Jonathan Marler
58fb5b29b6 more windows network fixes
* support posix SOCK_NONBLOCK and SOCK_CLOEXEC flags on windows
* fix bugs in os.socket and os.connect to return at the correct place
2020-05-31 10:07:51 -06:00
Veikka Tuominen
899d79f8f0
Merge pull request #5478 from vrischmann/fix-iouring
linux: fix IOSQE_BIT decl and io_uring_sqe flags
2020-05-31 16:59:04 +03:00
Vincent Rischmann
636d3ba780
linux: fix IOSQE_BIT decl and io_uring_sqe flags 2020-05-30 16:05:46 +02:00
Alexandros Naskos
dbdacb0938
Fix WSARecvFrom signature
The lpFromLen should be a pointer.
2020-05-30 16:46:32 +03:00
Jonathan Marler
2eaab1e65e more windows network support, including dns 2020-05-29 22:38:48 -06:00
Andrew Kelley
7c8d0cc678 fix pwrite on 32-bit linux 2020-05-25 19:59:39 -04:00
Andrew Kelley
3052fd84c8 fix regression in std.os.windows.fromSysTime 2020-05-25 00:37:47 -04:00
Andrew Kelley
53d011fa1a (breaking) std.time fixups and API changes
Remove the constants that assume a base unit in favor of explicit
x_per_y constants.

nanosecond calendar timestamps now use i128 for the type. This affects
fs.File.Stat, std.time.nanoTimestamp, and fs.File.updateTimes.

calendar timestamps are now signed, because the value can be less than
the epoch (the user can set their computer time to whatever they wish).

implement std.os.clock_gettime for Windows when clock id is
CLOCK_CALENDAR.
2020-05-24 21:40:08 -04:00
Jethro Nederhof
f83fd47b14 os/bits/freebsd audit 2020-05-24 10:08:43 +10:00
Jethro Nederhof
b504169fef FreeBSD: missing networking constants 2020-05-24 10:08:43 +10:00
Greg Anders
64955deb72 Add poll definitions for Darwin 2020-05-22 13:21:34 -04:00
Jakub Konka
2a59ecd7ec Integrate getTestDir with tmpDir logic 2020-05-18 17:10:49 +02:00
Jakub Konka
fae4af9e1c Make mode_t a 0-byte type in WASI 2020-05-18 17:09:52 +02:00
Jakub Konka
d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
Vincent Rischmann
e5ffb94911 linux: remove duplicated fields 2020-05-17 02:42:59 -04:00
daurnimator
45f7c78bfc
std: fix RTLD_ constants on OSX 2020-05-08 22:34:18 +10:00
Andrew Kelley
ba43492c0e
Merge pull request #5268 from tadeokondrak/remove-callconv-redundant-syntax
Remove syntax redundant with callconv
2020-05-07 12:42:26 -04:00
Jens Goldberg
20c1696865 Removed GetModuleHandleA from user32
GetModuleHandleA is an kernel32 function and already defined there, it doesn't belong in user32.
2020-05-07 12:38:46 -04:00
Jens Goldberg
25810bc1e6 Removed duplicate WM_ACTIVATE 2020-05-07 12:38:46 -04:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Andrew Kelley
8a8beefa36 solve the problem with Darwin shims in std.os instead
* implement SOCK_NONBLOCK and SOCK_CLOEXEC Darwin shims in std.os
 * revert changes to std.net
 * remove os.accept and rename os.accept4 to os.accept
2020-05-02 17:36:28 -04:00
Andrew Kelley
7998e2b0f4 Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-io 2020-05-02 14:16:59 -04:00
Chris Heyes
8ebcca6734
Get evented io code paths to build on macOS (#5233)
* Get evented io code paths to build on macOS
* Use mode_t instead of usize where appropriate
2020-05-02 14:14:46 -04:00
Andrew Kelley
43f7856bac fix regressions in windows std lib tests 2020-05-02 01:25:22 -04:00
Andrew Kelley
2272a07ca0 std.event.Loop: promote the fs thread to be available for all OS's 2020-05-02 00:41:19 -04:00
Andrew Kelley
45bce27b8f cleanup and fixes. behavior tests passing with evented I/O 2020-05-01 23:17:28 -04:00
Andrew Kelley
988031c07c Merge branch 'windows-evented-io' of https://github.com/FireFox317/zig into FireFox317-windows-evented-io 2020-05-01 19:02:16 -04:00
Cato Auestad
5418efa1e5 Added socket bits for Darwin 2020-05-01 14:28:33 -04:00
Jakub Konka
b23a87953a Fast-forward std.os.bits.wasi to match preview1 snapshot ABI
`wasi_snapshot_preview1` introduced a couple of ABI changes. This
commit fast-forwards the types and consts defined in `std.os.bits.wasi`
to match those changes.
2020-04-30 13:28:50 -04:00
Jakub Konka
611a1436f0 Update WASI snapshot to preview1
This commit updates the WASI imports to use `wasi_snapshot_preview1`
instead of the old `wasi_unstable`. There are some minor ABI
differences between the two, however, the main motivator for using
the latest "stable" snapshot (aka preview1) is that, at least in
Wasmtime, there has been a lot of improvement work put into preview1
and unfortunately I might add, the improvements were not (in full)
backported to `wasi_unstable` snapshot.

Also, this commit removes the optional bound on the pointer to
`environ_get` syscall.
2020-04-30 01:52:12 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Tadeo Kondrak
17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
Andrew Kelley
1e04e85200 std: support / in Windows paths 2020-04-27 13:39:06 -04:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
LemonBoy
155e631aa6 std: Implement progress for Windows
Use the Win32 API instead of using the VT escape sequences.
2020-04-22 12:58:02 +02:00
Vexu
b6fe839248
update std lib to decls being disallowed between fields 2020-04-18 23:56:05 +03:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
Jakub
1e23a3cd91 Added gdi32.zig and More user32 definitions 2020-04-14 16:20:48 -04:00
Heppoko
a3b2de1d1e
fix file protocol structure definitions (#5015) 2020-04-12 16:45:11 -04:00
daurnimator
8e9e126d41 std: add some basic windows user32 definitions 2020-04-12 02:28:52 -04:00
Andrew Kelley
a6e288d5fe
Merge pull request #4711 from leroycep/feature-file-locks
Add lock option to File.OpenFlags and File.CreateFlags
2020-04-10 15:00:45 -04:00
LeRoyce Pearson
317f06dc77 Add lock_nonblocking flag for creating or opening files
Also, make windows share delete access. Rationale: this is how it works
on Unix systems, mostly because locks are (usually) advisory on Unix.
2020-04-07 18:00:12 -06:00
LeRoyce Pearson
117d15ed7a Fix file locking on windows
The share_access bitfield was being ORed with what was supposed to be
parts of the default value, meaning that the share_access would be
more permissive than expected.
2020-04-07 16:49:37 -06:00
Michael Neumann
2b9cef1e04 Add missing constants for DragonFly 2020-04-07 17:23:20 +02:00
LeRoyce Pearson
4dd0822a36 Add LOCK_* constants to BSD os/bits 2020-04-02 23:50:12 -06:00