Commit Graph

66 Commits

Author SHA1 Message Date
Isaac Freund
7b961a876b
std: add prctl definition for linux 2020-09-11 22:32:22 +02:00
Andrew Kelley
2315331d23
Merge pull request #5527 from shawnanastasio/ppc64le
Implement support for powerpc64{,le}
2020-09-10 15:56:27 -04:00
Veikka Tuominen
41bbadbb9a
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
2020-09-05 13:58:02 +03:00
Andrew Kelley
1034459170
Merge pull request #6243 from ifreund/uid-gid-cleanup
std: clean up usage of uid_t/gid_t, add seteuid/setegid to std.os
2020-09-03 18:05:59 -04:00
Vexu
1df0f3ac24
update uses of deprecated type field access 2020-09-03 18:10:40 +03:00
Isaac Freund
01a365f1b0
std: ensure seteuid/setegid do not change saved id 2020-09-03 15:16:26 +02:00
Isaac Freund
e8a2aecd2f
std: fix linux uid_t, use uid_t/gid_t in std.os
- correct uid_t from i32 to u32 on linux
- define uid_t and gid_t for OSes missing definitions
- use uid_t/gid_t instead of plain u32s throughout std.os
2020-09-03 15:08:37 +02:00
Aransentin
25f6663304 Add the sync functions 2020-09-02 22:16:40 +00:00
Matthew Knight
0fa3cfdb4a
Bpf: move under os/linux instead of bits (#6126)
* moved bpf syscall, added some bpf instructions and tests

* had to move bpf out of bits so that a freestanding target could import it

* removed line

* fixed imports
2020-08-22 15:08:01 -04:00
Matt Knight
80fabe1850 fixed bpf namespace 2020-08-21 11:40:35 -07:00
Matt Knight
7f1378909b moved bpf syscall, added some bpf instructions and tests 2020-08-21 11:40:35 -07:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
ae2c88754d std: signalfd: fix the types of things; add test 2020-08-17 16:19:57 -07:00
Luna
2deb07a001 rename signalfd4 to signalfd 2020-08-17 16:05:35 -07:00
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04:00
luna
a6626802f9
Add signalfd support (#5322)
* add signalfd_siginfo to linux bits

* Cast sigaddset's shift value to u5

* linux: add signalfd4

* os: add signalfd
2020-07-22 17:26:27 -04:00
Shawn Anastasio
ec0d775524 Implement std.os for powerpc64{,le} 2020-07-01 16:10:49 -05:00
Andrew Kelley
7fd937fef4 cleanups
* improve docs
 * add TODO comments for things that don't have open issues
 * remove redundant namespacing of struct fields
 * guard against ioctl returning EINTR
 * remove the general std.os.ioctl function in favor of the specific
   ioctl_SIOCGIFINDEX function. This allows us to have a more precise
   error set, and more type-safe API.
2020-06-02 15:28:46 -04:00
Luna
6623efd7d4 Change ioctl's request type to i32 2020-06-02 14:56:19 -04:00
Luna
7c71054286 Replace syscall3 to os.ioctl 2020-06-02 14:56:19 -04:00
Luna
c8468bed42 Add std.os.ioctl 2020-06-02 14:56:19 -04:00
Andrew Kelley
7c8d0cc678 fix pwrite on 32-bit linux 2020-05-25 19:59:39 -04:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Chris Heyes
8ebcca6734
Get evented io code paths to build on macOS (#5233)
* Get evented io code paths to build on macOS
* Use mode_t instead of usize where appropriate
2020-05-02 14:14:46 -04:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
LeRoyce Pearson
ea6525797d Use flock instead of fcntl to lock files
`flock` locks based on the file handle, instead of the process id.
This brings the file locking on unix based systems closer to file
locking on Windows.
2020-04-02 22:57:02 -06:00
daurnimator
63409cf422 std: linux syscall numbers are now an extensible enum 2020-03-31 10:16:20 -04:00
daurnimator
356ef3840f std: update for linux 5.6 release 2020-03-30 10:55:18 -04:00
LemonBoy
4843c3b4c3
std: Introduce fnctl wrapper 2020-03-18 13:45:52 -04:00
Andrew Kelley
66e76a0209
zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
LemonBoy
11df0d0cf8 std: Add setEndPos to fs.file
Allow the user to shrink/grow the file size as needed.
2020-03-12 09:43:45 +01:00
LemonBoy
89d7fc773d std: Fix pwrite invocation on 32bit architectures 2020-03-12 09:43:45 +01:00
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