aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/bits/linux.zig
AgeCommit message (Collapse)Author
2021-09-01std.os reorganization, avoiding `usingnamespace`Andrew Kelley
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-08-31std: Use truncating cast in WIFSTOPPED for Linux, FreeBSD and DragonFlyPhilip Ã…kesson
The intermediate value can be larger than an u16, so @truncate is needed to match the behavior of musl.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
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-24std: [breaking] move errno to become an nonexhaustive enumAndrew Kelley
The primary purpose of this change is to eliminate one usage of `usingnamespace` in the standard library - specifically the usage for errno values in `std.os.linux`. This is accomplished by truncating the `E` prefix from error values, and making errno a proper enum. A similar strategy can be used to eliminate some other `usingnamespace` sites in the std lib.
2021-08-21linux: Add recent clone/clone3 and missing signalfd flags.Aydin Mercan
The following flags have been introduced: - CLONE_PIDFD (>=5.2) - CLONE_INTO_CGROUP (>=5.7) - SFD_CLOEXEC and SFD_NONBLOCK (>=2.6.27)
2021-08-07linux: add missing FUTEX definitionsKlecko
2021-08-02Move iovec and log levels to bits/posix.zigN00byEdge
This lets only the OSes that uses them to import them, and removes dependencies on bits.zig for the os/<os>/<arch>.zig files
2021-07-22linux stdlib: fix definition of RW flags (#9428)Biolunar
2021-07-10Add waitid syscall on linux (#9335)Malcolm Still
2021-06-21fix code broken from previous commitJacob G-W
2021-06-12Make std.ChildProcess exit code u8 to match std.process.exitGarrett Squire
This patch adjusts the exit code for a child process to be a u8. Since the WEXITSTATUS macro returns the lower eight bits, it's safe to assume that we can truncate the returned u32.
2021-06-09os/bits/linux: add the fadvise advice valuesVincent Rischmann
2021-06-07Add Linux XDP bits (#9019)Jens Goldberg
2021-06-01os: make msghdr, msghdr_const, and sockaddr_storage backwards-compatibleKenta Iwasaki
`msghdr` and `msghdr_const` definitions have been added back the way they were in std.os. std.os.sendmsg has also been modified to accept a msghdr_const again to ensure backwards-compatibility with this PR. Underneath the hood, std.os.sendmsg will @ptrCast the provided msghdr_const into a std.x.os.Socket.Message. `sockaddr_storage` definitions have been added back the way they were in std.os, except that it now simply aliases std.x.os.Socket.Address.Native.Storage as all of std.x.os.Socket.Address.Native.Storage's fields are equivalent to the fields that were previously defined for std.x.os.bits.sockaddr_storage. std.x.os.Socket.sendMessage now no longer is a stub that aliases std.os.sendmsg, but instead calls and handles errors from std.os.system.sendmsg directly. Addresses feedback to urge backwards compatibility from @andrewrk.
2021-06-01os: `sockaddr_storage` -> `std.x.os.Socket.Address.Native.Storage`Kenta Iwasaki
2021-06-01x/io, x/os: async i/o reactor, cross-platform socket syscalls and bitslithdew
Cross-platform versions of msghdr, sendmsg, recvmsg, linger, and iovec were provided based on findings from glibc, musl, and Microsoft's documentation. Implemented initial Reactor interface for epoll (linux) which wraps around I/O reactor subsystems such as epoll, kqueue, select, etc. across different platforms. The Reactor interface allows for driving async I/O in Zig applications. A test was added for the Reactor interface to drive a TCP client/listener socket pair. A greatest-common-subset of possible socket initialization flags (close socket on exec syscalls, initialize socket to be non-blocking) were implemented. A test was added for using sendmsg/recvmsg syscalls across different platforms for a TCP client/listener socket pair.
2021-05-12Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
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-10std/os, x/os/socket: windows support, socket helpers, getpeername()lithdew
Socket I/O methods such as read, readv, write, writev, send, recv, sendmsg, recvmsg have been generalized to read(buf, flags), write(buf, flags), readVectorized(vectors, flags), and writeVectorized(vectors, flags). There is still some work left to be done abstracting both readVectorized and writeVectorized properly across platforms, which is work to be done in a future PR. Support for setting the linger timeout of a socket, querying the remote address of a socket, setting whether or not keep-alive messages are to be sent through a connection-oriented socket periodically depending on host operating system settings has been added. `std.io.Reader` and `std.io.Writer` wrappers around `Socket` has been implemented, which wrap around Socket.read(buf, flags) and Socket.write(buf, flags). Both wrappers may be provided flags which are passed to Socket.read / Socket.write accordingly. Cross-platform support for `getpeername()` has been implemented. Windows support for the new `std.x.os.Socket` has been implemented. To accomplish this, a full refactor of `std.os.windows.ws2_32` has been done to supply any missing definitions and constants based on auto-generated Windows syscall bindings by @marler8997. `std.x.net.TCP.Listener.setQuickACK` has been moved to `std.x.net.TCP.Client.setQuickACK`. Windows support for resolving the scope ID of an interface name specified in an IPv6 address has been provided. `sockaddr_storage` definitions have been provided for Windows, Linux, and Darwin. `sockaddr_storage` is used to allocate space before any socket addresses are queried via. calls such as accept(), getsockname(), and getpeername(). Zig-friendly wrappers for GetQueuedCompletionStatusEx(), getpeername(), SetConsoleCtrlHandler(), SetFileCompletionNotificationModes() syscalls on Windows have been provided. Socket.setOption() was provided to set the value of a socket option in place of os.setsockopt. Socket.getOption() will be provided in a future PR. There is still further work to be done regarding querying socket option values on Windows, which is to be done in a subsequent PR.
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux/tls.zig * test/behavior/align.zig * test/behavior/atomics.zig * test/behavior/vector.zig
2021-05-06Merge pull request #8683 from LemonBoy/thumblinuxAndrew Kelley
Initial bringup for Linux/Thumb2
2021-05-05Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
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-04std: Initial bringup for Linux on Thumb2LemonBoy
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-03std/os/linux/bits: correct socket option codes for ppc/ppc64lithdew
2021-05-01std: Add signal numbers for SPARCLemonBoy
2021-05-01std: Import correct errno defs for SPARCLemonBoy
Taken from Linux arch/sparc/include/uapi/asm/errno.h
2021-04-22std: fix compile errors caught by stage2 AstGenAndrew Kelley
* `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-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-04-10Add ppc Linux bitsBenjamin Feng
2021-04-04os/bits/linux: add IPv6 socket optionsVincent Rischmann
2021-03-02os/linux: fix IO_Uring.timeoutVincent Rischmann
According to the io_uring PDF (https://kernel.dk/io_uring.pdf) the timeout struct must be 64 bits on both 32 and 64 bit architectures.
2021-01-11os/bits/linux: add the termios cc bitsVincent Rischmann
2021-01-08Add IP_ constantsRobin Voetter
2021-01-03Improve uring definitionsdaurnimator
2020-12-31Year++Frank Denis
2020-12-18std.crypto.random: introduce fork safetyAndrew Kelley
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-17Add baudrate constantsTau
This adds the missing baudrate constants for linux where I've used them directly.
2020-12-12std: Further siginfo refinementsLemonBoy
* Define siginfo and sigaction for Darwin * Define sigaction/handler union for maximum libc compatibility * Minor correction to some type definitions
2020-12-12std: Improve sigaction interfaceLemonBoy
Add a smoke test to prevent regressions.
2020-11-05Merge pull request #6978 from LemonBoy/statshitAndrew Kelley
Decouple kernel and libc stat definitions
2020-11-05Merge pull request #6895 from jorangreef/fallocateAndrew Kelley
linux: add fallocate()
2020-11-04std: Correct stack_t definition for mipsLemonBoy
2020-11-01Merge pull request #6792 from koachan/sparc64-linuxAndrew Kelley
Initial sparc64-linux bringup
2020-11-01Add definitions for FALLOC_FL_ mode flagsJoran Dirk Greef
2020-10-29Merge pull request #6356 from jorangreef/io_uringAndrew Kelley
std: add io_uring library
2020-10-25Fix SA_* constants for sparc64Koakuma
2020-10-24Add sparc64-specific values for the various SA_ and SIG_ constantsKoakuma
2020-10-24Add sparc64 linux bitsKoakuma
2020-10-19std: Minor changes to startup codeLemonBoy
* Smaller startup sequence for ppc64 * Terminate the frame-pointer chain when executing _start * Make the stack traces work on ppc64 * Make the stack traces coloured on ppc64, some ioctls numbers are different and the whole set of constants should be audited.
2020-10-17Make std.meta.Int accept a signedness parameterJan Prudil
2020-10-08Rename ix_rss -> ixrssBenjamin Feng