111 Commits

Author SHA1 Message Date
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
aebf28eba3 Make ifru fields sentinel-terminated 2020-06-02 14:56:06 -04:00
Luna
c60daa255f Replace C types in declarations 2020-06-02 14:56:06 -04:00
Luna
10ea2db5cb Replace C shorts by integer types 2020-06-02 14:56:06 -04:00
Luna
cb649b769c Fix ifreq definition 2020-06-02 14:56:06 -04:00
Luna
2c641c93da Only resolve scope id when needed 2020-06-02 14:56:06 -04:00
Luna
9c200035f3 Add some interface structs to linux bits 2020-06-02 14:56:06 -04:00
Andrew Kelley
c6764fd254
Merge pull request #5475 from marler8997/windowsDns
support name resolution on windows
2020-06-01 15:33:05 -04:00
Jonathan Marler
58fb5b29b6 more windows network fixes
* support posix SOCK_NONBLOCK and SOCK_CLOEXEC flags on windows
* fix bugs in os.socket and os.connect to return at the correct place
2020-05-31 10:07:51 -06:00
Vincent Rischmann
636d3ba780
linux: fix IOSQE_BIT decl and io_uring_sqe flags 2020-05-30 16:05:46 +02:00
Jonathan Marler
2eaab1e65e more windows network support, including dns 2020-05-29 22:38:48 -06:00
Andrew Kelley
53d011fa1a (breaking) std.time fixups and API changes
Remove the constants that assume a base unit in favor of explicit
x_per_y constants.

nanosecond calendar timestamps now use i128 for the type. This affects
fs.File.Stat, std.time.nanoTimestamp, and fs.File.updateTimes.

calendar timestamps are now signed, because the value can be less than
the epoch (the user can set their computer time to whatever they wish).

implement std.os.clock_gettime for Windows when clock id is
CLOCK_CALENDAR.
2020-05-24 21:40:08 -04:00
Jethro Nederhof
f83fd47b14 os/bits/freebsd audit 2020-05-24 10:08:43 +10:00
Jethro Nederhof
b504169fef FreeBSD: missing networking constants 2020-05-24 10:08:43 +10:00
Greg Anders
64955deb72 Add poll definitions for Darwin 2020-05-22 13:21:34 -04:00
Jakub Konka
fae4af9e1c Make mode_t a 0-byte type in WASI 2020-05-18 17:09:52 +02:00
Jakub Konka
d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
Vincent Rischmann
e5ffb94911 linux: remove duplicated fields 2020-05-17 02:42:59 -04:00
daurnimator
45f7c78bfc
std: fix RTLD_ constants on OSX 2020-05-08 22:34:18 +10:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Andrew Kelley
8a8beefa36 solve the problem with Darwin shims in std.os instead
* implement SOCK_NONBLOCK and SOCK_CLOEXEC Darwin shims in std.os
 * revert changes to std.net
 * remove os.accept and rename os.accept4 to os.accept
2020-05-02 17:36:28 -04:00
Cato Auestad
5418efa1e5 Added socket bits for Darwin 2020-05-01 14:28:33 -04:00
Jakub Konka
b23a87953a Fast-forward std.os.bits.wasi to match preview1 snapshot ABI
`wasi_snapshot_preview1` introduced a couple of ABI changes. This
commit fast-forwards the types and consts defined in `std.os.bits.wasi`
to match those changes.
2020-04-30 13:28:50 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
Vexu
b6fe839248
update std lib to decls being disallowed between fields 2020-04-18 23:56:05 +03:00
Andrew Kelley
a6e288d5fe
Merge pull request #4711 from leroycep/feature-file-locks
Add lock option to File.OpenFlags and File.CreateFlags
2020-04-10 15:00:45 -04:00
Michael Neumann
2b9cef1e04 Add missing constants for DragonFly 2020-04-07 17:23:20 +02:00
LeRoyce Pearson
4dd0822a36 Add LOCK_* constants to BSD os/bits 2020-04-02 23:50:12 -06: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
LeRoyce Pearson
35c462caf0 Merge branch 'master' into feature-file-locks 2020-04-02 21:46:48 -06:00
LemonBoy
5047cd3d78 Workaround for #4789 2020-04-01 12:46:16 +02:00
LemonBoy
070ace4b22 std: Fix more NetBSD bits
Fix some more libc definitions.
2020-04-01 12:11:19 +02:00
daurnimator
63409cf422 std: linux syscall numbers are now an extensible enum 2020-03-31 10:16:20 -04:00
daurnimator
9bc8a1e1d0 std: add some missing errnos on linux 2020-03-30 10:55:18 -04:00
daurnimator
356ef3840f std: update for linux 5.6 release 2020-03-30 10:55:18 -04:00
LeRoyce Pearson
c7f4e68464
Merge branch 'master' into feature-file-locks 2020-03-27 11:32:33 -06:00
LeRoyce Pearson
113b217593 Merge branch 'master' into feature-file-locks 2020-03-23 21:39:16 -06:00
LeRoyce Pearson
0b93932a21 Add O_SHLOCK and O_EXLOCK to freebsd and netbsd 2020-03-23 21:07:50 -06:00
LemonBoy
cda73c3c18 std: Add missing C bits and defines for NetBSD 2020-03-23 18:55:45 +01:00
LemonBoy
27344464ed std: Add missing C defines for NetBSD 2020-03-23 18:47:40 +01:00
LemonBoy
4843c3b4c3
std: Introduce fnctl wrapper 2020-03-18 13:45:52 -04:00
LeRoyce Pearson
32c5825030 Match netbsd's flock fields with others 2020-03-17 20:54:38 -06:00
LeRoyce Pearson
f66a607607 Define Flock for all posix systems 2020-03-14 10:12:46 -06:00
LeRoyce Pearson
e1868029e9 Implement blocking file locking API for windows 2020-03-14 10:12:46 -06:00
LeRoyce Pearson
9af0590a28 Add fnctlFlock system call, use it to lock files 2020-03-14 10:12:46 -06:00
LemonBoy
3e93dce0a1 std: Fix detection of Linux kernel version 2020-03-10 12:55:35 -04:00
daurnimator
648f94c027 std: add some definitions for netlink sockets 2020-03-09 13:02:38 -04:00
LeRoyce Pearson
25d9ab95dd Use os.ino_t for everything
Also, define ino_t for windows
2020-03-08 21:52:36 -06:00
LeRoyce Pearson
cb84875eed Define ino_t for systems not yet defining it
Also, use ino_t instead of u64 in fs.File.INode
2020-03-08 18:31:18 -06:00