252 Commits

Author SHA1 Message Date
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Stevie Hryciw
04f3067a79 run zig fmt on everything checked by CI 2022-11-18 19:22:42 +00:00
Veikka Tuominen
41b7e40d75
Merge pull request #13418 from ryanschneider/signal-alignment-13216
std.os: fix alignment of Sigaction.handler_fn
2022-11-09 17:36:40 +02:00
Ali Chraghi
aea617c60b std.os: take advantage of the freebsd's copy_file_range 2022-11-05 15:43:39 -04:00
Ryan Schneider
7f1f2e653d std.os: fix alignment of Sigaction.handler_fn
Fixes #13216
2022-11-04 08:00:50 -07:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
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
Louis Pearson
8d4778b4f9
Support compiling for the android NDK (#13245) 2022-10-21 18:32:56 -04:00
Ali Chraghi
fb366f3cd4 std.c: fix incorrect return types
Closes #12964
2022-10-13 13:21:19 +02:00
ominitay
295451dfe5
std: Replace use of stage1 function pointers 2022-09-29 21:45:30 +03:00
Bill Nagel
eeeda53423 add missing darwin types 2022-09-23 12:25:40 +03:00
billzez
dfcadd22bb
fix android definition of pthread_rwlock_t (#12830) 2022-09-16 20:20:24 -05:00
Stephen Gregoratto
7ccb94fac8 Audit FreeBSD structs to match header files/ABI
The big outliers were `Stat` and `mcontext_t`. Also adds doc-comments
from the headers where possible.
2022-09-14 20:05:54 -04:00
Sébastien Marie
8bcb962ada openbsd: fix sigcontext struct and avoid defining fxsave64
`sc_fpstate` member of `struct sigcontext` is a `struct fxsave64 *`.
use *anyopaque to represent it.

avoid to defining `fxsave64` as it is a packed struct with some arrays.
2022-08-26 17:30:07 +02:00
zooster
4055e6055b
AstGen: disallow leading zeroes in int literals and int types
This makes `0123` and `u0123` etc. illegal.

I'm now confident that this is a good change because
I actually caught two C header translation mistakes in `haiku.zig` with this.
Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by
requiring `0o` as the prefix and now also disallowing leading zeroes in integers.

For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`).

Fixes #11963
Fixes #12417
2022-08-18 19:54:51 +03: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
Kim SHrier
397e6547a9 add FreeBSD support to std.os.getFdPath
This implementation uses the F_KINFO fcntl command added in FreeBSD
13 release. FreeBSD 12 users get a compile error.

Co-authored-by: Stephen Gregoratto <dev@sgregoratto.me>
2022-07-15 10:16:31 +03:00
Veikka Tuominen
122c76a167 Sema: allow void as an extern union field & fix invalid extern unions 2022-07-11 20:30:16 +03:00
Andrew Kelley
9c5056788f std: update bsd bits to new fn ptr semantics 2022-07-04 13:02:30 -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
Yuto Oguchi
43373e61fa
std.c: Fix incorrect dirent structure (#11602)
d_name is a null-terminated string, but it is not guaranteed that the
last byte of the array is null.
2022-05-26 20:15:51 -04:00
Andrew Kelley
e0a0df5a8a
Merge pull request #11598 from aiotter/master
Add functions from `dirent.h` to std.c
2022-05-26 20:11:54 -04:00
aiotter
552ef5f2e4 std.c: Implement dirent on std/c/linux.zig 2022-05-17 15:23:55 +09:00
Isaac Freund
1392c24166 std.os: Add memfd_create for FreeBSD
This is minorly breaking as e.g. std.os.linux.MFD_CLOEXEC is now
std.os.linux.MFD.CLOEXEC.
2022-05-16 17:43:44 -04:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
aiotter
ad7f725dba std.c: Move Darwin-unspecific functions from std/c/darwin.zig to std/c.zig 2022-05-07 00:02:15 +09:00
aiotter
83d8378139 std.c: Add C APIs to read directories 2022-05-06 23:54:13 +09:00
protty
e3cbea934e
std.Thread.Futex improvements (#11464)
* atomic: cache_line

* Thread: Futex rewrite + more native platform support

* Futex: tests compile

* Futex: compiles and runs test

* Futex: broadcast test

* Futex: fix PosixImpl for tests

* Futex: fix compile errors for bsd platforms

* Futex: review changes + fix timeout=0 + more comments
2022-04-19 19:42:15 -05:00
Veikka Tuominen
101aac92c2 stage2: fix bugs preventing stage2 from building stage3 with LLVM 2022-04-15 23:32:26 +03:00
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