123 Commits

Author SHA1 Message Date
protty
2ba68f9f4c
std.Thread.Futex addition (#9070)
* std.Thread.Futex: implementation + tests

* std.Thread.Futex: fix darwin compile errors

* std.Thread.Futex: fix wait() documentation typo

* std.Thread.Futex: fix darwin version check

* std.Thread.Futex: remove unnecessary comptime keyword
2021-06-12 08:51:37 -05:00
Vincent Rischmann
c71e8a30cd os/linux: add fadvise 2021-06-09 18:15:50 +03:00
Kenta Iwasaki
278e5d398e x: replace std.builtin with std.Target.current 2021-06-01 18:24:43 +09:00
lithdew
9ba65592d6 os: have sendmsg, recvmsg flags be c_int 2021-06-01 18:22:58 +09:00
Isaac Freund
5b850d5c92
Run zig fmt on src/ and lib/std/
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-20 17:14:18 +02: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
8bb58fb428 std: Fix offset param splitting for preadv/pwritev
The kernel interface expects the offset as a low+high pair even on BE
systems.
2021-05-11 15:49:53 +02:00
LemonBoy
780f510ac0 std: Fix fallocate offset type 2021-05-11 12:33:48 +02:00
LemonBoy
31f1cc9a0d std: Harmonize use of off_t between libc and Zig impls
Let's follow the libc/kernel convention and use an i64 for offsets, we
bitcast as needed and avoid the useless conditional casts.
2021-05-11 12:33:48 +02:00
Andrew Kelley
b6bb0ee1ac Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux/tls.zig
 * test/behavior/align.zig
 * test/behavior/atomics.zig
 * test/behavior/vector.zig
2021-05-08 10:53:22 -07:00
Andrew Kelley
fc40d23723 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * lib/std/array_list.zig
 * lib/std/c/ast.zig
 * lib/std/c/parse.zig
 * lib/std/os/bits/linux.zig
2021-05-05 10:48:22 -07:00
LemonBoy
afbcb6209d std: Initial bringup for Linux on Thumb2
There are some small problems here and there, mostly due to the pointers
having the lsb set and disrupting the fn alignment tests and the
`@FrameSize` implementation.
2021-05-04 18:52:53 +02:00
Andrew Kelley
d788181a3b
fix typo
Co-authored-by: Maciej Walczak <14938807+xackus@users.noreply.github.com>
2021-05-01 18:07:26 -04:00
LemonBoy
718b43504e std: Fix pwrite/pread syscalls on SPARC targets 2021-05-01 15:46:28 +02:00
Andrew Kelley
e86cee258c Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted the change that makes `suspend;` illegal in the
parser.
2021-04-24 10:44:41 -07:00
Andrew Kelley
507a8096d2 std: fix compile errors caught by stage2 AstGen
* `comptime const` is redundant
 * don't use `extern enum`; specify a tag type.
   `extern enum` is only when you need tags to alias. But aliasing tags
   is a smell. I will be making a proposal shortly to remove `extern enum`
   from the language.
 * there is no such thing as `packed enum`.
 * instead of `catch |_|`, omit the capture entirely.
 * unused function definition with missing parameter name
 * using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
LemonBoy
d82eb8dd40 std: Split syscall parameters for PowerPC targets 2021-04-21 16:31:29 +02:00
Hubert Jasudowicz
d605f02756 std: Add process_vm_readv/writev wrappers 2021-04-19 16:12:28 +02:00
Hubert Jasudowicz
5134fb72ef std: Add pidfd wrappers 2021-04-17 01:13:16 +02:00
Mahdi Khanalizadeh
d1a41feddc linux: fix number of arguments for tgkill syscall 2021-04-16 17:09:15 +02:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Benjamin Feng
df910b33f4 Add ppc Linux bits 2021-04-10 22:47:22 -05:00
daurnimator
1f17221bc4 std: add sendmsg 2021-02-28 21:57:43 +02:00
Tau
840331ee48 Rebase link(at) properly 2021-02-21 12:04:40 +02:00
Tadeo Kondrak
5dfe0e7e8f
Convert inline fn to callconv(.Inline) everywhere 2021-02-10 20:06:12 -07:00
LemonBoy
134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Andreas Linz
7e63f7ad03
Truncate user and group ids for 64 bit Linux systems (#7466)
* Truncate user and group ids

Calls to `getuid`, `getgid` and their `eid` variants fail to compile on
64bit Linux systems because the return value of the syscall is of
`usize` and needs to be truncated to fit the size of `uid_t` that is 32
bit.

Thanks to @FireFox317 for figuring this out in Zig's Discord channel!

* Add a regression test for user and group ids

* Replace @truncate with @intCast

This should be safe because `uid_t` will be 32-bit.

* Add missing import for getauxval

* Add missing package names

* Revert "Add missing import for getauxval"

This reverts commit 38f93dc89effdf657f2b81a56b96527ce4083f52.

* Skip user and group test if builtin.link_libc
2020-12-23 11:16:27 +02:00
Andrew Kelley
53987c932c std.crypto.random: introduce fork safety
Everybody gets what they want!

 * AT_RANDOM is completely ignored.
 * On Linux, MADV_WIPEONFORK is used to provide fork safety.
 * On pthread systems, `pthread_atfork` is used to provide fork safety.
 * For systems that do not have the capability to provide fork safety,
   the implementation falls back to calling getrandom() every time.
 * If madvise is unavailable or returns an error, or pthread_atfork
   fails for whatever reason, it falls back to calling getrandom() every
   time.
 * Applications may choose to opt-out of fork safety.
 * Applications may choose to opt-in to unconditionally calling
   getrandom() for every call to std.crypto.random.fillFn.
 * Added `std.meta.globalOption`.
 * Added `std.os.madvise` and related bits.
 * Bumped up the size of the main thread TLS buffer. See the comment
   there for justification.
 * Simpler hot path in TLS initialization.
2020-12-18 15:54:01 -07:00
LemonBoy
629cc6cf28 std: Further siginfo refinements
* Define siginfo and sigaction for Darwin
* Define sigaction/handler union for maximum libc compatibility
* Minor correction to some type definitions
2020-12-12 16:44:10 +01:00
LemonBoy
beae3cea17 std: Improve sigaction interface
Add a smoke test to prevent regressions.
2020-12-12 13:57:25 +01:00
Vexu
7e30e83900
small fixes and zig fmt 2020-12-09 13:54:26 +02:00
Koakuma
41c40f4bbe Fix fork() on Linux/sparc64
fork() on Linux/sparc64 seems to return its result in two registers,
with %o0 always holding the current process' PID, and the parent/child
status returned in %o1. Add some glue code to convert those into
the libc-style return value.
2020-11-27 23:02:22 +07:00
Žiga Željko
2fbe9519ac std: add support for ppoll 2020-11-21 14:06:04 -08:00
LemonBoy
e374ae3598 std: Use newfstatat on PPC64
One more variation in the syscall table, hooray!
2020-11-20 08:38:10 +01:00
Tadeo Kondrak
25ec2dbc1e Add builtin.Signedness, use it instead of is_signed 2020-11-19 18:59:21 +02:00
Andrew Kelley
c9551652b0
Merge pull request #6978 from LemonBoy/statshit
Decouple kernel and libc stat definitions
2020-11-05 17:27:22 -05:00
Andrew Kelley
f85d719952
Merge pull request #6895 from jorangreef/fallocate
linux: add fallocate()
2020-11-05 17:23:00 -05:00
LemonBoy
0e95fa455c std: Split kernel&libc definitions of stat struct
There's no guarantee for the kernel definition to be ABI compatible with
the libc one (and vice versa).
There's also no guarantee of ABI compatibility between musl/glibc.

Fun, isn't it?
2020-11-05 09:38:50 +01:00
Joran Dirk Greef
8193f55820 Support 32-bit big-endian targets 2020-11-03 06:03:38 +02:00
LemonBoy
dc872a221d std: Fix syscall stubs passing 64bit offsets for BE targets 2020-11-02 12:11:07 +01:00
Andrew Kelley
909aae8153
Merge pull request #6792 from koachan/sparc64-linux
Initial sparc64-linux bringup
2020-11-01 22:14:56 -05:00
Joran Dirk Greef
c910f03a7b Swap endianness 2020-11-01 13:14:32 +02:00
Joran Dirk Greef
2dd8613adc "The Traveling Wilburys' - Handle With Care"
Both `offset` and `len` are `off_t`.

Like the rest of the std lib we assume that `_FILE_OFFSET_BITS == 64`
is always true, so that `off_t` is a `u64`.

When passing to 32-bit kernels, we split these into two `u32`
parameters.
2020-11-01 11:49:08 +02:00
Joran Dirk Greef
8fd88fdb31 linux: add fallocate() 2020-10-31 13:39:33 +02:00
Andrew Kelley
a41c0b63bb
Merge pull request #6356 from jorangreef/io_uring
std: add io_uring library
2020-10-29 18:20:38 -04:00
johnLate
23c28c72b7 std.os.linux.accept/accept4: allow null for addr and len
std.os.accept already wants to allow null, which matches `man 3p accept`:

>  address     Either a null pointer, or a pointer to a sockaddr structure
>              where the address of the connecting  socket  shall  be  re‐
>              turned.
>
>  address_len Either  a  null pointer, if address is a null pointer, or a
>              pointer to a socklen_t object which on input specifies  the
>              length  of  the  supplied sockaddr structure, and on output
>              specifies the length of the stored address.

Fixes ziglang#6832.
2020-10-27 21:52:47 +01:00
LemonBoy
8044ed4c66 std: Add basic smoke test for net functionality 2020-10-27 21:52:47 +01:00
Koakuma
3ce9428e3d Various formatting fixes 2020-10-25 21:53:16 +07:00
Koakuma
1d3abb761d "zig fmt" on lib/std/os/linux.zig 2020-10-25 13:38:08 +07:00