Commit Graph

112 Commits

Author SHA1 Message Date
xackus
15f55b2805 os.flock: FreeBSD can return EOPNOTSUPP 2021-09-25 15:55:15 -04:00
Stephen Gregoratto
87fd502fb6 Initial bringup of the Solaris/Illumos port 2021-09-24 14:06:16 -04:00
Andrew Kelley
cca57042df std: fix regressions from this branch
Also move some usingnamespace test cases from compare_output to
behavior.
2021-09-01 17:54:07 -07:00
Andrew Kelley
7884d84315 std.os.windows: reorg to avoid usingnamespace
Down to 19 uses of `usingnamespace`.
2021-09-01 17:54:06 -07:00
Andrew Kelley
7f03cfe161 std.os: more reorganization efforts
* std lib tests are passing on x86_64-linux with and without -lc
 * stage2 is building from source on x86_64-linux
 * down to 38 remaining uses of `usingnamespace`
2021-09-01 17:54:06 -07:00
Andrew Kelley
3deda15e21 std.os reorganization, avoiding usingnamespace
The main purpose of this branch is to explore avoiding the
`usingnamespace` feature of the zig language, specifically with regards
to `std.os` and related functionality.

If this experiment is successful, it will provide a data point on
whether or not it would be practical to entirely remove `usingnamespace`
from the language.

In this commit, `usingnamespace` has been completely eliminated from
the Linux x86_64 compilation path, aside from io_uring.

The behavior tests pass, however that's as far as this branch goes. It is
very breaking, and a lot more work is needed before it could be
considered mergeable. I wanted to put a pull requset up early so that
zig programmers have time to provide feedback.

This is progress towards closing #6600 since it clarifies where the
actual "owner" of each declaration is, and reduces the number of
different ways to import the same declarations.

One of the main organizational strategies used here is to do namespacing
with real namespaces (e.g. structs) rather than by having declarations
share a common prefix (the C strategy). It's no coincidence that
`usingnamespace` has similar semantics to `#include` and becomes much
less necessary when using proper namespaces.
2021-09-01 17:54:06 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Takeshi Yoneda
1e20a62126 WASI,libc: enable tests.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-07-27 09:01:00 +09:00
Andrew Kelley
e32530b6a3 std.fs.File: update doc comments regarding locking
Update to accomodate the differences in Windows, which is now advisory
file locking, and include details about which operating systems have
atomic locking flags.
2021-06-29 14:25:04 -07:00
Andrew Kelley
06129d7e3d std: implement a cross platform file locking abstraction
This modifies the lock semantics from using AccessMode to using
NtLockFile/NtUnlockFile.

This is a breaking change.
2021-06-29 14:25:04 -07:00
Andrew Kelley
488f68069b implement std.fs.File.setLock for Windows 2021-06-29 14:25:04 -07:00
Andrew Kelley
6ba6b98b72 std add fs.File.setLock
Windows implementation is still missing.
2021-06-29 14:25:04 -07:00
Andrew Kelley
c9cc09a3bf Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux.zig
 * lib/std/os/windows/bits.zig
 * src/Module.zig
 * src/Sema.zig
 * test/stage2/test.zig

Mainly I wanted Jakub's new macOS code for respecting stack size, since
we now depend on it for debug builds able to pass one of the test cases
for recursive comptime function calls with `@setEvalBranchQuota`.

The conflicts were all trivial.
2021-05-12 16:41:20 -07:00
LemonBoy
c065e12dbe std: Add more tests, fix broken code
It turns out that nothing in the test suite was exercising
preadv/pwritev and so the previous commits silently broke them.

Adding tests revealed readvAll and preadvAll were also broken and not
covered by any test.
2021-05-11 12:33:48 +02:00
Andrew Kelley
015cd79f89 stage2: implement caching for ZIR code
Notably this exposed an issue with the language having to do with the
secret safety tag on untagged unions. How can we have our cake and eat
it too? Not solved in this commit. I will file a language proposal to
tackle this issue soon.

Fixes a compile error in `std.fs.File.readvAll`.
2021-04-25 00:02:58 -07:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Edward Dean
83a2665772 Fixed error types for GetSeekPosError 2021-04-04 17:04:46 -07:00
Andrew Kelley
68e7726478 std.fs.net.Stream: add writev and writevAll
I noticed that the write function does not properly use non-blocking
I/O. This file needs to be reworked for evented I/O to properly take
advantage of non-blocking writes to network sockets.
2021-02-16 11:01:17 -07:00
Julian Maingot
4c5f69a065 update error return doc
Docs were out of sync with code
2021-01-18 11:04:33 -08:00
Andrew Kelley
d68adc5382 std.EarlyEOFReader: rename to LimitedReader 2021-01-11 16:51:56 -07:00
daurnimator
01d1a8a783 std: use fifo.pump in writeFileAllUnseekable 2021-01-11 16:48:56 -07:00
daurnimator
8695b9fbe7 std: use reader.skipBytes to avoid infinite loop in writeFileAllUnseekable
skipBytes correctly handles EOF for us
2021-01-11 16:47:48 -07:00
Jay Petacat
1595ce273e Remove deprecated stream aliases 2021-01-08 16:54:56 -05:00
Andrew Kelley
e1811f72eb stage2: link.C: use pwritev 2021-01-05 17:41:14 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
luna
6a75cfd0f6
cast sendto to SendError inside send (#7481)
* cast sendto to SendError inside send

* remove WouldBlock from SendToError

* add missing ENOTCONN mapping

* remove SystemResources duplicate

* move NetworkUnreachable to SendError

* add NetworkSubsystemFailed to SendError

* Use zig's implicit error set casting

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-12-22 16:47:11 -05:00
luna
0c33624a45
create SendToError (#7417)
* add SendToError

* remove error catch

* add missing SendToError entries

* add mappings to new errors for posix

* map windows sendto() errors
2020-12-15 14:56:42 -05:00
Luna
5f7b97e84c add AddressFamilyNotSupported to SendError 2020-12-07 16:40:03 -05:00
christian-stephen
abc729a5f9 Add readAllArrayListAligned to Reader which can accept an arbitrary alignment 2020-11-27 17:00:50 -08:00
Andrew Kelley
ede41759be std.fs.File.writeFileAll: support unseekable files
With this commit, the function tries to use more efficient syscalls, and
then falls back to non-positional reads.

The motivating use case for this change is to support something like the
following:

try io.getStdOut().writeFileAll(dest_file, .{});
2020-11-03 15:25:43 -07:00
Andrew Kelley
b2b0bf0506 fixups for the previous commit
* std.fs.File.copyRange and copyRangeAll return u64 instead of usize -
   the returned value is how much of the `len` is transferred, so the
   types should match. This removes the need for an `@intCast`.
 * fix typo that removed a subtraction
 * Fix the size of codegen.AnyMCValue which gave me a compile error when
   I tried to build self-hosted for i386-linux.
 * restore the coercion to u64 of syms_sect.sh_info. We want to make
   sure the multiplication happens with 64 bits and not the smaller type
   used by the ELF format.
 * fix another offset parameter in link/Elf.zig to be u64 instead of usize
 * add a nice little TODO note to help out Jakub
 * FmtError already has FileTooBig in it; we just need to return it.
2020-10-07 00:39:13 -07:00
Timon Kruiper
bd7eab573a Fix building the zig compiler for 32-bit targets 2020-10-06 23:39:58 -07:00
Loris Cro
dc01ef7388
Remove noop check
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-09-25 23:21:20 +02:00
Loris Cro
7fec5b3def pwritev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
7a07c62a07 pwrite
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:21 +02:00
Loris Cro
18f6629bd8 writev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:03 +02:00
Loris Cro
9075f8e5a1 write
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:05:41 +02:00
Loris Cro
59ecdaea12 preadv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:43 +02:00
Loris Cro
bd9f2369d5 pread
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:05 +02:00
Loris Cro
bc35435ca6 readv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:03:12 +02:00
Loris Cro
08364ac773 read
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:00:55 +02:00
Andrew Kelley
c41cd3e13a std.fs.File: fix typo in writeFileAll 2020-09-10 18:53:20 -07:00
Christian Wesselhoeft
ea9b38c93c fs/file.zig: Update reader to use type alias
This is a minor cosmetic change which updates `reader` and `inStream`
to match `writer` and `outStream` below.
2020-09-10 15:42:24 -04:00
LemonBoy
90743881cf std: Minor changes to the fs module
* Add a size_hint parameter to the read{toEnd,File}AllocOptions fns
* Rename readAllAlloc{,Options} to readToEndAlloc{,Options} as they
  don't rewind the file before reading
* Fix missing rewind in test case
2020-09-04 10:17:00 +02:00
LemonBoy
73a8c9beaa std: Don't trust stat() size in readAllAlloc fns
Some files such as the ones in /proc report a st_size of zero, try to
read the file anyway if we hit that case.
2020-09-02 11:11:57 +02:00
daurnimator
129d3e274d
std: use O_NOCTTY flag 2020-08-24 02:28:31 +10: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
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04: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
923c0feda1 Add std.fs.File.readAllAlloc tests
This commit adds some unit tests for `std.fs.File.readAllAlloc`
function. It also updates the docs of `Reader.readNoEof`
which were outdated, and swaps `inStream()` for  `reader()` in
`File.readAllAlloc` with the former being deprecated.
2020-06-22 20:03:21 -04:00