aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c/linux.zig
AgeCommit message (Collapse)Author
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
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-11std: Harmonize use of off_t between libc and Zig implsLemonBoy
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-11std: Fix cast that's sometimes invalidLemonBoy
2021-05-11std: Prefer 64bit libc functions where possibleLemonBoy
While musl decided to hard-wire off_t to a 64bit quantity, glibc is much older and defaults to 32bit offsets and offers some -64 suffixed versions of I/O functions. There's a weird mix-up of types: sometimes off_t is used, sometimes not, sometimes it's defined as a signed quantity and sometimes as an unsigned one, but we'll sort this problem later.
2021-04-22std: fix compile errors caught by stage2 AstGenAndrew Kelley
Follow-up from 507a8096d2f9624bafaf963c3e189a477ef6b7bf
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-01-18std: define pipe2 only for os that support itLemonBoy
2021-01-14organize std lib concurrency primitives and add RwLockAndrew Kelley
* move concurrency primitives that always operate on kernel threads to the std.Thread namespace * remove std.SpinLock. Nobody should use this in a non-freestanding environment; the other primitives are always preferable. In freestanding, it will be necessary to put custom spin logic in there, so there are no use cases for a std lib version. * move some std lib files to the top level fields convention * add std.Thread.spinLoopHint * add std.Thread.Condition * add std.Thread.Semaphore * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux * add std.Thread.RwLock Implementations provided by @kprotty
2020-12-31Year++Frank Denis
2020-12-23std.ResetEvent: pthreads sem_t cannot be statically initializedAndrew Kelley
because it is allowed for the implementation to use a file descriptor, which would require making a syscall at runtime.
2020-12-23std.ResetEvent: use sem_t when linking against pthreadsAndrew Kelley
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-11-18Merge pull request #6385 from LemonBoy/callocatorAndrew Kelley
std: Make C allocator respect the required alignment
2020-11-05Implement a fallback mechanism for posix_memalignLemonBoy
Do the alignment dance by ourselves whenever posix_memalign is not available. Don't try to use malloc as it has too many edge cases, figuring out whether a block of memory is manually aligned by the mechanism above or is directly coming from malloc becomes too hard to be valuable.
2020-11-01Add libc signatureJoran Dirk Greef
2020-10-04implement {get, set}rlimit for linuxxackus
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-17std: signalfd: fix the types of things; add testAndrew Kelley
2020-08-17add signalfd to std.c.linuxLuna
2020-08-11copy_file_range linux syscall (#6010)Maciej Walczak
2020-05-05zig fmtTadeo Kondrak
2020-03-12std: Add setEndPos to fs.fileLemonBoy
Allow the user to shrink/grow the file size as needed.
2020-03-03breaking: std.os read/write functions + sendfileAndrew Kelley
* rework os.sendfile and add macosx support, and a fallback implementation for any OS. * fix sendto compile error * std.os write functions support partial writes. closes #3443. * std.os pread / pwrite functions can now return `error.Unseekable`. * std.fs.File read/write functions now have readAll/writeAll variants which loop to complete operations even when partial reads/writes happen. * Audit std.os read/write functions with respect to Linux returning EINVAL for lengths greater than 0x7fff0000. * std.os read/write shim functions do not unnecessarily loop. Since partial reads/writes are part of the API, the caller will be forced to loop anyway, and so that would just be code bloat. * Improve doc comments * Add a non-trivial test for std.os.sendfile * Fix std.os.pread on 32 bit Linux * Add missing SYS_sendfile bit on aarch64
2020-02-28introduce operating system version ranges as part of the targetAndrew Kelley
* re-introduce `std.build.Target` which is distinct from `std.Target`. `std.build.Target` wraps `std.Target` so that it can be annotated as "the native target" or an explicitly specified target. * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a struct which has the tag as well as version range information. * `std.elf` gains some more ELF header constants. * `std.Target.parse` gains the ability to parse operating system version ranges as well as glibc version. * Added `std.Target.isGnuLibC()`. * self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using `/usr/bin/env` rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: #2084 Note: this `/usr/bin/env` code is work-in-progress. * `-target-glibc` CLI option is removed in favor of the new `-target` syntax. Example: `-target x86_64-linux-gnu.2.27` closes #1907
2020-01-18std: turn EAI_ constants into a non-exhaustive enumdaurnimator
2019-12-31c.linux: add memfd_createLuna
2019-12-10improve dynamic library APIAndrew Kelley