aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/bits
AgeCommit message (Collapse)Author
2021-09-01std.os.linux: remove the "bits" namespace altogetherAndrew Kelley
Now there is only 1 architecture-specific file for Linux kernel bits.
2021-09-01std: reorganize std.c to eliminate `usingnamespace`Andrew Kelley
Behavior tests pass on x86_64-linux with -lc
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-22std.os: (p)writev should perform partial writes if iov.len > IOV_MAXdaurnimator
Co-authored-by: Veikka Tuominen <git@vexu.eu>
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-09Merge remote-tracking branch 'origin' into libc-wasi-testTakeshi Yoneda
2021-08-09review: use defined flag for oflags.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
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-27WASI,libc: enable tests.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
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-16netbsd: add more std.os.bitsMichael Dusan
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-12Renamed @byteOffsetOf to @offsetOfExonorid
2021-06-10netlink ifi_change no longer reservedJens Goldberg
The documentation (e.g. `man 7 rtnetlink`) states that ifi_change "is reserved for future use and should be always set to 0xFFFFFFFF". This is no longer true, even though the text hasn't been updated.
2021-06-09os/bits/linux: add the fadvise advice valuesVincent Rischmann
2021-06-07Add Linux XDP bits (#9019)Jens Goldberg
2021-06-01os/bits: remove duplicate `sockaddr_storage` for dragonflyKenta Iwasaki
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-24housekeeping: builtin.arch → builtin.cpu.archMichael Dusan
2021-05-24dragonfly: pass `zig build test`Michael Dusan
2021-05-23overhaul elf csu (c-runtime startup) logicMichael Dusan
- more support for linux, android, freebsd, netbsd, openbsd, dragonfly - centralize musl utils; musl logic is no longer intertwined with csu - fix musl compilation to build crti/crtn for full archs list - fix openbsd to support `zig build-lib -dynamic` - initial dragonfly linking success (with a warning) ancillary: - fix emutls (openbsd) tests to use `try`
2021-05-22Merge pull request #8844 from ifreund/inlineAndrew Kelley
Support inline keyword as well as callconv(.Inline)
2021-05-22openbsd: complete kqueue(2) constant definitionsSébastien Marie
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-19openbsd: convert builtin.arch to builtin.target.cpu.archSébastien Marie
2021-05-18std: update freebsd bits to new builtinAndrew Kelley
2021-05-15Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * build.zig * src/Compilation.zig * src/codegen/spirv/spec.zig * src/link/SpirV.zig * test/stage2/darwin.zig - this one might be problematic; start.zig looks for `main` in the root source file, not `_main`. Not sure why there is an underscore there in master branch.
2021-05-14std: dragonfly: fix duplicate definition of sockaddr_storageAndrew Kelley
2021-05-14Merge pull request #8746 from koachan/sparc64-fixesAndrew Kelley
Various Linux/SPARCv9 fixes
2021-05-13std: dragonfly: fix duplicate definition of sockaddr_storageAndrew Kelley
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-12stage2: Add CPU feature detection for macosLemonBoy
This is mostly meant to detect the current and future AArch64 core types as the x86 part is already taken care of with OS-independent machinery.
2021-05-12Define ENOTSUP for SPARCKoakuma
2021-05-11bsd: detect os versionMichael Dusan
- netbsd, dragonly: use sysctlbyname - openbsd: use sysctl - updated default semver ranges
2021-05-10std/os: add missing sockaddr_storage defslithdew
2021-05-10std/os: fix sockaddr_storage padding sizelithdew
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/bits/windows: add `timeval` extern structlithdew