Commit Graph

222 Commits

Author SHA1 Message Date
Andrew Kelley 6d73f89bf1 stage2: disable default panic handler when linking -lc
It's failing to compile std.os.dl_iterate_phdr correctly.
2022-03-20 00:36:44 -07:00
Veikka Tuominen 12f3c461a4 Sema: implement zirSwitchCaptureElse for error sets 2022-03-19 15:49:27 +02:00
Jakub Konka 648afbc839 macos: update Mach routines for accessing page info 2022-03-17 10:42:11 +01:00
Jakub Konka dd55b72949 std: introduce posix_spawn as an alt to fork-exec
Currently, the new API will only be available on macOS with
the intention of adding more POSIX systems to it incrementally
(such as Linux, etc.).

Changes:
* add `posix_spawn` wrappers in a separate container in
  `os/posix_spawn.zig`
* rewrite `ChildProcess.spawnPosix` using `posix_spawn` targeting macOS
  as `ChildProcess.spawnMacos`
* introduce a `posix_spawn` specific `std.c.waitpid` wrapper which
  does return an error in case the child process failed to exec - this
  is required for any process that was spawned using `posix_spawn`
  mechanism as, by definition, the errors returned by `posix_spawn`
  routine cover only the `fork`-equivalent; `pre-exec()` and `exec()`
  steps are covered by a catch-all error `ECHILD` returned by `waitpid`
  on unsuccessful execution, e.g., no such file error, etc.
2022-03-16 19:40:44 +01:00
Koakuma cb3b1dd6dd c/linux: Fix stat struct definition for SPARCv9
The libc interface uses `stat` instead of `stat64` struct.
This fixes, among other things, `zig fmt` accidentally setting the
formatted file's permission to 000.
2022-03-13 16:48:02 -04:00
Jakub Konka 4a2100e820 std: more c/darwin.zig fixes 2022-03-13 15:42:40 +01:00
Jakub Konka 633c4a2a60 macos: add Mach task abstraction
`std.os.darwin.MachTask` wraps `mach_port_t` and can be used to issue
kernel calls tied to the wrapped Mach kernel port/task.
2022-03-13 13:35:39 +01:00
Jakub Konka 2036af94e9 macos: add kernel return values 2022-03-13 10:49:09 +01:00
Jakub Konka a60292dfb3 macos: add more mach primitives 2022-03-13 09:42:24 +01:00
Jakub Konka b0dc61fae2 macos: add mach_* syscalls for process mgmt 2022-03-10 22:39:04 +01:00
Cody Tapscott 58f961f4cb stdlib: Add emulated CWD to std.os for WASI targets
This adds a special CWD file descriptor, AT.FDCWD (-2), to refer to the
current working directory. The `*at(...)` functions look for this and
resolve relative paths against the stored CWD. Absolute paths are
dynamically matched against the stored Preopens.

"os.initPreopensWasi()" must be called before std.os functions will
resolve relative or absolute paths correctly. This is asserted at
runtime.

Support has been added for: `open`, `rename`, `mkdir`, `rmdir`, `chdir`,
`fchdir`, `link`, `symlink`, `unlink`, `readlink`, `fstatat`, `access`,
and `faccessat`.

This also includes limited support for `getcwd()` and `realpath()`.
These return an error if the CWD does not correspond to a Preopen with
an absolute path. They also do not currently expand symlinks.
2022-03-03 14:31:49 -07:00
Al Hoang db82c1b982 add constant for haiku
* re-enable zig build on haiku
2022-02-26 10:53:13 +02:00
protty 5d30e8016d time: introduce Instant (#10972) 2022-02-24 18:51:44 -05:00
Veikka Tuominen 65aa333197 fix formatting in openbsd.zig
CI was failing for unrelated reasons so this went unnoticed
2022-02-20 11:58:42 +02:00
Dante Catalfamo ec59a04138 Add OpenBSD auth functions 2022-02-20 09:58:58 +02:00
Anthony Carrico 078aa5f7b2 Adds Linux support for POSIX file locking with fcntl
On Linux, locking fails with EAGAIN (vs. EACCES on other systems).
This commit also adds FcntlErrors for EDEADLK and ENOLCK.
2022-02-15 13:22:50 +02:00
Veikka Tuominen 90f2a8d9c5 Merge pull request #10486 from ominitay/metadata
std: Implement cross-platform metadata API
2022-02-14 12:33:49 +02:00
ominitay b2610649fc std.c.*: add birthtime function to Stat
Adds a birthtime function to the `Stat` structs of Unices which support this. This is done to match the `atime`, `mtime`, and `ctime` functions.
2022-02-13 20:40:45 +00:00
ominitay d978fdaa67 std.c.Wasi.Stat: use timespec 2022-02-13 20:40:44 +00:00
ominitay 3dd3c5063b std.c.haiku: move Stat.crtime to Stat.birthtime 2022-02-13 20:40:44 +00:00
ominitay f23005eba7 std.c.darwin.Stat: use timespec
Uses timespec for times in `Stat` instead of two `isize` fields per time. This matches the <sys/stat.h> header file.
2022-02-13 20:40:44 +00:00
m 65299c37d1 validate in Windows using VirtualQuery 2022-02-11 22:15:46 +01:00
m bd8d6a8342 std: validate frame-pointer address in stack walking 2022-02-11 15:28:36 +01:00
John Schmidt 05cf69209e debug: implement segfault handler for macOS aarch64
Tested on a M1 MacBook Pro, macOS Monterey 12.2.
2022-02-07 16:34:05 -05:00
Andrew Kelley 8a94971980 std: fix i386-openbsd failing to build from source
closes #9705
2022-02-07 12:20:25 -07:00
Žiga Željko 5210b9074c os,wasi: use wasi-libc if available 2022-01-31 22:54:30 +01:00
joachimschmidt557 fa84625aeb std: Add some missing termios types to c/linux.zig and os.zig 2022-01-23 17:12:07 +01:00
John Schmidt 305a7def13 Implement segfault handler for macOS x86_64 2022-01-18 15:10:49 -05:00
johnLate 4addb26bba Fix os.rusage when linking with c library on Linux
Fixes ziglang#10543 on Linux.
2022-01-17 16:52:36 +02:00
John Schmidt 66fe5bb0d8 Use libc if_nametoindex if available when parsing IPs
Fixes https://github.com/ziglang/zig/issues/10521 and makes a couple of
additional tests pass when linking libc.
2022-01-12 19:32:46 +01:00
Dante Catalfamo 3bd0575cfe Add BSD Authentication constants (#10376) 2021-12-22 00:59:53 -05:00
Isaac Freund 9f9f215305 stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
Zapolsky Anton 2dae860de3 Added an explicit type for the termios constants (#10266)
Adds the `tcflag_t` type to the termios constants.
This is made to allow bitwise operations on the termios
constants without an integer cast, e.g.:

```zig
var raw = try std.os.tcgetattr(std.os.STDIN_FILENO);
raw.lflag &= std.os.linux.ECHO | std.os.linux.ICANON;
```
instead of

```zig
var raw = try std.os.tcgetattr(std.os.STDIN_FILENO);
raw.lflag &= ~@intCast(u32, std.os.linux.ECHO | std.os.linux.ICANON);
```

Contributes to #10181
2021-12-04 16:24:55 -05:00
Andrew Kelley 2a0adef583 Merge pull request #9910 from mikdusan/dragonfly
dragonfly: port Thread.setname/getname
2021-12-03 17:29:55 -08:00
Andrew Kelley 902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Andrew Kelley 36c8adf589 Merge pull request #10073 from hoanga/haiku-support-build2
more haiku support
2021-11-24 18:42:30 -08:00
Dante Catalfamo 12140ead43 Change darwin c.VMIN -> c.V.MIN to match Linux 2021-11-21 16:43:16 -05:00
Dante Catalfamo 54bcd1cd51 Add OpenBSD termios constants to std.c.openbsd (#10178) 2021-11-20 01:34:53 -08:00
Al Hoang be541ca5e1 haiku follow up cleanup of constants 2021-11-19 22:04:09 -06:00
Felix "xq" Queißner 2fefd4ea8e Fixes invalid errno definition for ***-linux-android 2021-11-18 12:58:28 -05:00
Al Hoang 4ec83133e9 haiku constants cleanup and update 2021-11-15 00:29:27 -06:00
Al Hoang cfb9bf59c1 update mmap flags, use defines 2021-11-15 00:29:27 -06:00
Al Hoang 59e91f4b25 ensure zig fmt 2021-11-15 00:29:27 -06:00
Al Hoang 426f54026b updates for haiku stdc
* add team_info, area_info
* update signature for get_next_image_info
* add error checks for haiku system calls
* update and cleanup of haiku constants
2021-11-15 00:29:26 -06:00
Andrew Kelley a78e61acf9 std: expose rusage constants under rusage namespace 2021-11-01 15:55:22 -07:00
pfg 1de6f9a267 std: add missing termios def to std/c/linux.zig
Fixes #9707
2021-10-30 18:32:26 +02:00
Michael Dusan d621f4322b dragonfly: port std.Thread.setname/getname 2021-10-09 03:52:28 -04:00
Andrew Kelley 6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Stephen Gregoratto 87fd502fb6 Initial bringup of the Solaris/Illumos port 2021-09-24 14:06:16 -04:00
Stephen Gregoratto 506f24cac2 Set the Storage socket sizes to be system defined
Some systems (Solaris, OpenBSD, AIX) change their definitions of
sockaddr_storage to be larger than 128 bytes. This comment adds a new
constant in the `sockaddr` that defines the size for every system.

Fixes #9759
2021-09-16 13:32:55 +03:00