Commit Graph

34 Commits

Author SHA1 Message Date
daurnimator
627618a38d
std: add Dir.changeDir as wrapper around fchdir 2020-03-03 13:25:43 -05:00
Andrew Kelley
582db68a15
remove superfluous comptime keyword 2020-03-03 12:01:17 -05:00
LemonBoy
a6fb6dcfc9 linux: Correct pread64 syscall for ARM/MIPS
Closes #4615
2020-03-03 11:59:16 -05:00
Andrew Kelley
c81345c8ae
breaking: std.os read/write functions + sendfile
* 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-03-03 02:25:26 -05:00
Terin Stock
bd287dd194
std: implement sendfile on linux
This changset adds a `sendfile(2)` syscall bindings to the linux bits
component. Where available, the `sendfile64(2)` syscall will be
transparently called.

A wrapping function has also been added to the std.os to transform
errno returns to Zig errors.

Change-Id: I86769fc4382c0771e3656e7b21137bafd99a4411
2020-03-02 12:54:50 -05:00
Andrew Kelley
4616af0ca4
introduce operating system version ranges as part of the target
* 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-02-28 14:51:53 -05:00
nofmal
a697de3eac Add basic linux termios implementation 2020-02-04 14:09:57 -05:00
LemonBoy
1ba4554855 Correct dl_iterate_phdr address
The base should be zero so that p_vaddr + dlpi_addr = p_vaddr
2020-01-29 12:05:36 -05:00
LemonBoy
c85afff5a8 Correct l_name field type 2020-01-14 23:11:10 +01:00
Andrew Kelley
53913acaf7
zig fmt and update extern fn to callconv(.C) 2020-01-06 15:34:50 -05:00
data-man
2f6b045fb1
Add std.os.getrusage 2020-01-05 16:52:36 -05:00
Luna
f0cbf63e1a
os: use system for memfd_create
- os: update flags type for memfd_create
2019-12-31 15:58:03 -05:00
Luna
997812e8fb
os: add memfd_create
currently only linux is supported
2019-12-31 15:58:03 -05:00
daurnimator
95c83388e4
std: use pid_t where appropriate 2019-12-22 20:20:58 +11:00
daurnimator
6de4bd850c
std: add tkill and tgkill for linux 2019-12-22 20:20:58 +11:00
daurnimator
c31afc3736
std: remove high level linux sigprocmask wrappers 2019-12-22 20:20:58 +11:00
daurnimator
96c9c38b35
std: sigprocmask set is optional 2019-12-22 12:03:03 +11:00
Raul Leal
62c817420d [#3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types (#3900)
* #3844 update std.c functions to use null-terminated pointer types

* check linux functions

* fix callsites

* fix io test

* Add allocPrintCstr function to remove other cast
2019-12-17 15:43:49 -05:00
Robin Voetter
4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley
343987cd05
remove @inlineCall from zig 2019-12-06 14:12:01 -05:00
LemonBoy
e1e06e6766 linux-i386 support 2019-11-30 16:13:33 +01:00
Andrew Kelley
47f06be369
string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
Vexu
f0c94d95dd
use @atomicStore in std lib 2019-11-13 00:52:15 +02:00
Andrew Kelley
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -05:00
kprotty
b535e86cc0 move SpinLock definitions around 2019-11-07 15:32:20 -06:00
Andrew Kelley
24b3da871d
fix regressions 2019-10-30 12:49:37 -04:00
Andrew Kelley
67058b9b70
basic DNS address resolution for linux without libc 2019-10-29 02:19:22 -04:00
Andrew Kelley
60cd11bd4b
get rid of std.os.foo.is_the_target
It had the downside of running all the comptime blocks and resolving
all the usingnamespaces of each system, when just trying to discover if
the current system is a particular one.

For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this
demonstrates the utility that #425 would provide.
2019-10-24 01:14:52 -04:00
LemonBoy
40fc7a1fda Add support for the statx syscall 2019-10-12 20:51:51 +02:00
LemonBoy
7640bec8e0 Fix pipe syscall for MIPS 2019-10-03 17:07:53 -04:00
LemonBoy
17f2af10b5 Correct signal bits for MIPS
Also enable the segfault handler for all the supported architectures
beside MIPS.
2019-10-01 13:58:58 -04:00
LemonBoy
5aaa7d0fbb Avoid truncating mmap2 offsets if not multiple of page size 2019-09-27 18:18:38 +02:00
LemonBoy
4ebcf64864 Initial support for mipsel architecture¬ 2019-09-26 09:31:55 +02:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00