aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c/linux.zig
AgeCommit message (Collapse)Author
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-06-18std.posix: remove unchecked std.os.linux usageIsaac Freund
Using std.os.linux directly in e.g. std.posix.timerfd_create() causes the function to compile but silently fail at runtime when targeting any OS other than Linux. To catch errors like this at compile time, std.os.linux must only be directly accessed within std.posix where there has been a comptime check that the target os is in fact Linux.
2024-06-17std: fix pthread_{get,set}name_np return type ABIIsaac Freund
I believe this was accidentally broken when the E enum for errno values was introduces. These functions are quite the special case in that they return the error value directly rather than returning -1 and passing the error value through the errno variable. In any case, using a u16 as the return type at the ABI boundary where a c_int is expected is asking for trouble.
2024-06-17std: make all dirent structs externIsaac Freund
Using structs with unspecified layout on the ABI boundry can't end well.
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-02-14std.os: export T struct and winsize structTim Culverhouse
Export the T struct and winsize struct for targets which have it defined in std.c. This struct defines libc constants for ioctl syscalls.
2024-02-12std.os.termios: consolidate and correctAndrew Kelley
2024-02-11some API work on std.c, std.os, std.os.wasiAndrew Kelley
* std.c: consolidate some definitions, making them share code. For example, freebsd, dragonfly, and openbsd can all share the same `pthread_mutex_t` definition. * add type safety to std.c.O - this caught a bug where mode flags were incorrectly passed as the open flags. * 3 fewer uses of usingnamespace keyword * as per convention, remove purposeless field prefixes from struct field names even if they have those prefixes in the corresponding C code. * fix incorrect wasi libc Stat definition * remove C definitions from incorrectly being in std.os.wasi * make std.os.wasi definitions type safe * go through wasi native APIs even when linking libc because the libc APIs are problematic and wasteful * don't expose WASI definitions in std.posix * remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all future rights too? or only all current rights known? both are the wrong answer.
2024-02-06std.c.MAP: use a packed structAndrew Kelley
Same as previous commit, but for the libc interface.
2023-09-08std.c.linux: Add getpw{nam,uid}()Linus Groh
2023-07-31Revert "linux adding some NUMA support"Andrew Kelley
This reverts commit 6f418c11e1ad1150fbdb002cfe1be92bda4e93cb.
2023-07-31Revert "std.os: adding linux's sched_setaffinity and its wrapper"Andrew Kelley
This reverts commit c7bf8bab38f8b89c1371eedb9229e00a29b5ca5b.
2023-07-31Revert "std.Thread: refining stack size from platform minimum, changes more ↵Andrew Kelley
targetted towards platform like Linux/musl (#15791)" This reverts commit 41502c6aa53a3da31b276c23c4db74db7d04796b.
2023-07-31Revert "std.c: exposing timer api"Andrew Kelley
This reverts commit 54ea0bbcdddc9e13ed98415d8883f03d59392509.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-18std.c: exposing timer apiDavid CARLIER
2023-05-25std.Thread: refining stack size from platform minimum, changes more ↵David CARLIER
targetted towards platform like Linux/musl (#15791)
2023-05-13std.os: adding linux's sched_setaffinity and its wrapperDavid CARLIER
2023-05-13linux adding some NUMA supportDavid CARLIER
2023-04-06std.os: add mincore syscalljim price
The mincore syscall is available on some UNIX like operating systems and allows a user to determine if a page is resident in memory.
2022-12-21Fix missing pthread_key_t definition on linuxGanesan Rajagopal
* pthread_key_t should also be available for non-android platforms * Also change the type to c_uint because Linux pthreadtypes.h typedefs it as "unsigned int" Partially addresses #13950
2022-12-14std.c.fstatat64: add noalias attributesAndrew Kelley
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
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-10-21Support compiling for the android NDK (#13245)Louis Pearson
2022-09-29std: Replace use of stage1 function pointersominitay
2022-09-16fix android definition of pthread_rwlock_t (#12830)billzez
2022-05-26Merge pull request #11598 from aiotter/masterAndrew Kelley
Add functions from `dirent.h` to std.c
2022-05-17std.c: Implement dirent on std/c/linux.zigaiotter
2022-05-13target: Rename sparcv9 -> sparc64Koakuma
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-03-20stage2: disable default panic handler when linking -lcAndrew Kelley
It's failing to compile std.os.dl_iterate_phdr correctly.
2022-03-13c/linux: Fix `stat` struct definition for SPARCv9Koakuma
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-02-11std: validate frame-pointer address in stack walkingm
2022-01-23std: Add some missing termios types to c/linux.zig and os.zigjoachimschmidt557
2022-01-17Fix os.rusage when linking with c library on LinuxjohnLate
Fixes ziglang#10543 on Linux.
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-11-18Fixes invalid errno definition for ***-linux-androidFelix "xq" Queißner
2021-10-30std: add missing termios def to std/c/linux.zigpfg
Fixes #9707
2021-09-12os: usingnamespace fixes for std.x.os.Socket and std.os.TCPKenta Iwasaki
Extract existing constants to do with TCP socket options into a 'TCP' namespace. Export 'MSG' and 'TCP' from std.os.{linux, windows} into std.c. Fix compile errors to do with std.x.os.Socket methods related to setting TCP socket options. Handle errors in the case that an interface could not be resolved in an IPv6 address on Windows. Tested using Wine with the loopback interface disabled. Have all instantiations of std.x.os.Socket on Windows instantiate an overlapped socket descriptor. Fixes the '1ms read timeout' test in std.x.net.tcp.Client. The test would previously deadlock, as read timeouts only apply to overlapped sockets. Windows documentation by default recommends that most instantiations of sockets on Windows be overlapped sockets (s.t. they may operate in both blocking or nonblocking mode when operated with WSA* syscalls). Refer to the documentation for WSASocketA for more info.
2021-09-01std.os fixes to get the test suite passing againAndrew Kelley
2021-09-01std: fix regressions from this branchAndrew Kelley
Also move some usingnamespace test cases from compare_output to behavior.
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-09-01std.os: fix FILENO constants mapped to wrong valuesAndrew Kelley
yikes!
2021-09-01std.os: more reorganization effortsAndrew Kelley
* std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace`
2021-09-01std: reorganize std.c to eliminate `usingnamespace`Andrew Kelley
Behavior tests pass on x86_64-linux with -lc
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-07-29std/c: add pthread_setname_np and pthread_getname_npVincent Rischmann
2021-07-15Add inotify_rm_watch definition to c/linux.zigRyan Liptak
Also make inotify_add_watch's pathname marked as nul-terminated
2021-05-18std: add android __SIZEOF_PTHREAD_MUTEX_TAndrew Kelley
closes #8384