60 Commits

Author SHA1 Message Date
Jan Prudil
aadccc4206 Make std.meta.Int accept a signedness parameter 2020-10-17 14:09:59 +02:00
Andrew Kelley
5c16022c81 rename WaitpidRet to WaitPidResult 2020-10-16 18:14:39 -07:00
stf
3921cb0d8d std.os.waitpid: also return pid of child
closes #6581
2020-10-16 17:26:50 -07:00
Clayton Voges
8c4031fd87 replaced inStream() with reader()
`inStream()` is now deprecated and deserves replacing.
2020-10-15 19:30:21 -04:00
Alexandros Naskos
65991092f7 Correctly set uid and gid to void instead of null on wasi 2020-10-04 21:21:25 -04:00
Andrew Kelley
29fd130093 std.ChildProcess: bypass libc exit() in fork child error case
Comment reproduced here:

If we're linking libc, some naughty applications may have
registered atexit handlers which we really do not want to
run in the fork child. I caught LLVM doing this and it
caused a deadlock instead of doing an exit syscall. In
the words of Avril Lavigne, "Why'd you have to go and
make things so complicated?"
2020-09-28 22:17:50 -07:00
Andrew Kelley
dffdb2844e track all TODO comments in BRANCH_TODO file
Before merging, do this for every item in the file:
 * solve the issue, or
 * convert the task to a github issue and update the comment
   to link to the issue (and remove "TODO" text from the comment).
Then delete the file.

Related: #363
2020-09-14 18:06:19 -07:00
Daniel Ludwig
a8a806e925 std.ChildProcess: use "\Device\Null" on Windows 2020-09-06 18:25:33 -04:00
Veikka Tuominen
41bbadbb9a
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
2020-09-05 13:58:02 +03:00
Vexu
1df0f3ac24
update uses of deprecated type field access 2020-09-03 18:10:40 +03: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
daurnimator
1bb30c5e22 std.ChildProcess: pass CLOEXEC when creating error pipe 2020-08-30 14:21:14 -04:00
LemonBoy
ff4fde767f std: Open the eventfd fd with CLOEXEC flag
Make sure the fd we use to communicate with the parent process is not
leaked to the child process.

Closes #5966
2020-08-30 00:22:54 -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
Jakub Konka
f6ae2505d9 Fix opening NUL device on Windows 2020-07-31 19:16:04 +02: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
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
Andrew Kelley
9dac8a5be9 update windows impl of child process to new File API 2020-05-02 04:31:26 -04:00
Andrew Kelley
6546c74825 child process: no need to remove O_CLOEXEC before execve 2020-05-02 03:38:05 -04:00
Andrew Kelley
beebcbb677 Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-io 2020-05-02 01:53:24 -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
2bae942800 add ZIR compare output test case to test suite 2020-05-01 06:47:20 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
LeRoyce Pearson
733f1c25bd Fix compile errors in stage2 2020-04-02 23:39:25 -06:00
Andrew Kelley
2e806682f4
(breaking) std.Buffer => std.ArrayListSentineled(u8, 0)
This new name (and the fact that it is a function returning a type) will
make it more clear which use cases are better suited for ArrayList and
which are better suited for ArrayListSentineled.

Also for consistency with ArrayList,
 * `append` => `appendSlice`
 * `appendByte` => `append`

Thanks daurnimator for pointing out the confusion of std.Buffer.
2020-04-01 13:30:07 -04:00
Andrew Kelley
553f0e0546
fixups and revert a few things 2020-04-01 11:56:39 -04:00
daurnimator
37e6a64690
std: use Buffer.outStream in std/child_process.zig 2020-04-01 10:36:38 -04:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Andrew Kelley
bd14a81e30
fix std.ChildProcess on Windows 2020-03-10 21:09:49 -04:00
Andrew Kelley
ba0e3be5cf
(breaking) rework stream abstractions
The main goal here is to make the function pointers comptime, so that we
don't have to do the crazy stuff with async function frames.

Since InStream, OutStream, and SeekableStream are already generic
across error sets, it's not really worse to make them generic across the
vtable as well.

See #764 for the open issue acknowledging that using generics for these
abstractions is a design flaw.

See #130 for the efforts to make these abstractions non-generic.

This commit also changes the OutStream API so that `write` returns
number of bytes written, and `writeAll` is the one that loops until the
whole buffer is written.
2020-03-10 15:32:32 -04:00
daurnimator
8f627593eb
Use in_stream.readAllAlloc where sensible 2020-03-06 18:49:12 -05:00
Andrew Kelley
4616af0ca4
introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Vexu
538d9a5dd8
remove uses of @ArgType and @IntType 2020-02-24 23:39:03 +02:00
Andrew Kelley
44c14749a1
expand argv[0] when spawning system C compiler
Some C compilers, such as Clang, are known to rely on
argv[0] to find the path to their own executable,
without even bothering to resolve PATH. This results
in the message:

error: unable to execute command: Executable "" doesn't exist!

So we tell ChildProcess to expand argv[0] to the absolute path
to give them a helping hand.
2020-02-17 00:58:30 -05:00
Andrew Kelley
4b02a39aa9
self-hosted libc detection
* libc_installation.cpp is deleted.
   src-self-hosted/libc_installation.zig is now used for both stage1 and
   stage2 compilers.
 * (breaking) move `std.fs.File.access` to `std.fs.Dir.access`. The API
   now encourages use with an open directory handle.
 * Add `std.os.faccessat` and related functions.
 * Deprecate the "C" suffix naming convention for null-terminated
   parameters. "C" should be used when it is related to libc. However
   null-terminated parameters often have to do with the native system
   ABI rather than libc. "Z" suffix is the new convention. For example,
   `std.os.openC` is deprecated in favor of `std.os.openZ`.
 * Add `std.mem.dupeZ` for using an allocator to copy memory and add a
   null terminator.
 * Remove dead struct field `std.ChildProcess.llnode`.
 * Introduce `std.event.Batch`. This API allows expressing concurrency
   without forcing code to be async. It requires no Allocator and does
   not introduce any failure conditions. However it is not thread-safe.
 * There is now an ongoing experiment to transition away from
   `std.event.Group` in favor of `std.event.Batch`.
 * `std.os.execvpeC` calls `getenvZ` rather than `getenv`. This is
   slightly more efficient on most systems, and works around a
   limitation of `getenv` lack of integration with libc.
 * (breaking) `std.os.AccessError` gains `FileBusy`, `SymLinkLoop`, and
   `ReadOnlyFileSystem`. Previously these error codes were all reported
   as `PermissionDenied`.
 * Add `std.Target.isDragonFlyBSD`.
 * stage2: access to the windows_sdk functions is done with a manually
   maintained .zig binding file instead of `@cImport`.
 * Update src-self-hosted/libc_installation.zig with all the
   improvements that stage1 has seen to src/libc_installation.cpp until
   now. In addition, it now takes advantage of Batch so that evented I/O
   mode takes advantage of concurrency, but it still works in blocking
   I/O mode, which is how it is used in stage1.
2020-02-16 13:25:30 -05:00
Andrew Kelley
0b5bcd2f56
more std lib async I/O integration
* `zig test` gainst `--test-evented-io` parameter and gains the ability
   to seamlessly run async tests.
 * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when
   using evented I/O
 * `std.io.getStdErr()` gives a File that is blocking even in evented
   I/O mode.
 * Delete `std.event.fs`. The functionality is now merged into `std.fs`
   and async file system access (using a dedicated thread) is
   automatically handled.
 * `std.fs.File` can be configured to specify whether its handle is
   expected to block, and whether that is OK to block even when in
   async I/O mode. This makes async I/O work correctly for e.g. the
   file system as well as network.
 * `std.fs.File` has some deprecated functions removed.
 * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
   to `std.os` and `std.fs.File`. They are all integrated with async
   I/O.
 * `std.fs.Watch` is still bit rotted and needs to be audited in light
   of the new async/await syntax.
 * `std.io.OutStream` integrates with async I/O
 * linked list nodes in the std lib have default `null` values for
   `prev` and `next`.
 * Windows async I/O integration is enabled for reading/writing file
   handles.
 * Added `std.os.mode_t`. Integer sizes need to be audited.
 * Fixed #4403 which was causing compiler to crash.

This is working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.
2020-02-06 18:05:50 -05:00
Michaël Larouche
7ee0e779af Fix std.child_process.ChildProcess.spawnWindow when looking in PATH environment variable, it applied cwd+app_name instead of just using the app_name 2020-01-14 15:12:30 -05:00
daurnimator
03e1241b88
std: avoid an allocation in inner loop 2020-01-10 15:03:51 +11:00
daurnimator
6fb636050f
std: fix off by one error in windows process creation 2020-01-10 15:00:14 +11:00
daurnimator
2662e50d27
std: sentinel terminated pointers for utf16 apis 2019-12-29 10:35:05 +11:00
LemonBoy
9d9b0720f5 Fix for the error codepath in ChildProcess 2019-12-16 10:57:29 +01:00
LemonBoy
c257f892fd Revert "Revert "Use eventfd in ChildProcess on Linux""
This reverts commit 2c7a2aefbfd0dbab190f912b4fbcbda96fb5ac44.
2019-12-16 10:56:53 +01:00
Andrew Kelley
2c7a2aefbf
Revert "Use eventfd in ChildProcess on Linux"
This reverts commit b169f7b0d51fa9e7cf570479079369b9736093ff.

This caused `integer cast truncated bits` at
std/child_process.zig:801:12

Can be reproduced on my machine simply by running `make`.
2019-12-16 01:39:41 -05:00
LemonBoy
b169f7b0d5 Use eventfd in ChildProcess on Linux
Closes #819
2019-12-15 14:43:37 -05:00
Andrew Kelley
b7be57766b
Merge pull request #3715 from daurnimator/towards-afd
Misc windows additions+fixes
2019-12-02 16:12:55 -05:00
Andrew Kelley
3644e85091 fix regressions on windows 2019-12-01 21:31:00 -05:00
daurnimator
21ca54f560
std: add alertable argument for windows.WaitForSingleObject 2019-11-27 13:00:59 +11:00
Andrew Kelley
bdf3680be1
zig fmt 2019-11-25 13:53:13 -05:00
Andrew Kelley
d2cb740dd9 add missing null terminator in windows file path helper function 2019-11-25 01:10:30 -05:00
Andrew Kelley
34b1ebefaa
Merge remote-tracking branch 'origin/master' into null-terminated-pointers 2019-11-24 20:28:46 -05:00