Commit Graph

267 Commits (733f1c25bd34270b76c5fa43928dfffda1ecd5e3)

Author SHA1 Message Date
Andrew Kelley 03396b3caa
update docs to new fmt API 2019-12-08 23:46:50 -05:00
Andrew Kelley 8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley 525b1e8fb4
Merge pull request #3856 from ziglang/builtin-call
introduce `@call` and remove other builtin calls
2019-12-06 15:49:47 -05:00
Andrew Kelley 343987cd05
remove `@inlineCall` from zig 2019-12-06 14:12:01 -05:00
Vexu bfb15f1c9f fix casts 2019-12-05 15:47:06 -05:00
Andrew Kelley b7be57766b
Merge pull request #3715 from daurnimator/towards-afd
Misc windows additions+fixes
2019-12-02 16:12:55 -05:00
Andrew Kelley ad214c7aa0
bring your own OS layer in the std lib
closes #3784
2019-12-02 15:02:17 -05:00
Andrew Kelley b36c07a95a
Merge remote-tracking branch 'origin/master' into remove-array-type-coercion 2019-12-01 09:56:01 -05:00
Andrew Kelley 951dc451d6
Merge pull request #3808 from LemonBoy/i386-for-ya
linux-i386 support
2019-11-30 22:00:00 -05:00
Andrew Kelley 413f9a5cfc
move `std.fs.Dir.cwd` to `std.fs.cwd`
update to non-deprecated std.fs APIs throughout the codebase

Related: #3811
2019-11-30 15:35:27 -05:00
LemonBoy e1e06e6766 linux-i386 support 2019-11-30 16:13:33 +01:00
Andrew Kelley d87b13f2f7
fix windows std lib regressions 2019-11-29 21:55:27 -05:00
Andrew Kelley bf3ac66150
remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
daurnimator 8a71f77c4a
std: lie about windows socklen_t signed-ness 2019-11-27 13:01:34 +11:00
daurnimator edc84e7ef7
std: add more winsock functions 2019-11-27 13:01:33 +11:00
daurnimator 19f26578c0
std: windows sockaddr constants come from ws2_32 2019-11-27 13:01:32 +11:00
daurnimator 8aa3d6019c
std: add windows.USHORT definition 2019-11-27 13:01:30 +11:00
daurnimator 254c79125b
std: fix WSAIoctl definition
zig automatically passes functions as pointers
2019-11-27 13:01:28 +11:00
daurnimator d99f0a2b8f
std: IO_STATUS_BLOCK's status member is an NTSTATUS; add union 2019-11-27 13:01:10 +11:00
daurnimator 1537d4701e
std: fix definition of NtDeviceIoControlFile 2019-11-27 13:01:09 +11:00
daurnimator a453c99ba9
std: add comments for some nt status codes 2019-11-27 13:01:08 +11:00
daurnimator 2c6788d7de
std: add windows.closesocket 2019-11-27 13:01:07 +11:00
daurnimator 6b5b0e6cd6
std: fix windows.GetOverlappedResult 2019-11-27 13:01:05 +11:00
daurnimator ce9966a39b
std: improved windows.DeviceIoControl 2019-11-27 13:01:04 +11:00
daurnimator b05a5a3e52
std: add CreateEvent for windows 2019-11-27 13:01:03 +11:00
daurnimator 78c0d33eb7
std: add WaitForMultipleObjects for windows 2019-11-27 13:01:02 +11:00
daurnimator 21ca54f560
std: add alertable argument for windows.WaitForSingleObject 2019-11-27 13:00:59 +11:00
Jonathan S 4014a8e4b4 Avoid deprecated cwd-based functions for opening directories, preferring to open explicitly relative to `Dir.cwd()`. 2019-11-25 23:46:48 -05:00
Jonathan S 51c5740879 Use a specific access mask in `Dir.openDirListW` instead of a generic one. Untested.
The actual desired access mask in this case seems quite confusing and badly documented. The previous combination of `GENERIC_READ` and `SYNCHRONIZE` seems both illegal and redundant according to the [`ntifs.h` documentation](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile), which specifies that `GENERIC_READ` should not be used for directories and includes `SYNCHRONIZE`. `winnt.h` contains a number of relevant-sounding flags such as `FILE_ADD_FILE`, `FILE_ADD_SUBDIRECTORY`, and `FILE_DELETE_CHILD` that do not show up in documentation at all. These are equal in value to file-specific flags that are documented as flags you should not specify when opening a directory.
2019-11-25 23:46:47 -05:00
Andrew Kelley 4261fa3c49
move logic to the appropriate layers; add new compile error 2019-11-25 18:46:17 -05:00
Andrew Kelley 659c1bdeee
Merge branch 'wasi-run-tests' of https://github.com/fengb/zig into fengb-wasi-run-tests 2019-11-25 17:53:26 -05:00
Andrew Kelley cb38bd0a14
rename std.heap.direct_allocator to std.heap.page_allocator
std.heap.direct_allocator is still available for now but it is marked
deprecated.
2019-11-25 17:25:06 -05:00
Andrew Kelley bdf3680be1
zig fmt 2019-11-25 13:53:13 -05:00
Andrew Kelley 5a98dd42b3
Merge pull request #3728 from ziglang/null-terminated-pointers
sentinel-terminated pointers
2019-11-25 02:20:08 -05:00
daurnimator 69b780647a std: update for linux 5.4 2019-11-25 02:07:23 -05:00
Andrew Kelley d2cb740dd9 add missing null terminator in windows file path helper function 2019-11-25 01:10:30 -05:00
Andrew Kelley 29e438fd1f
more sentinel-terminated pointers std lib integration
See #3767
2019-11-25 00:43:36 -05:00
Andrew Kelley 15d415e10b
make std.mem.toSlice use null terminated pointers
and fix the fallout
2019-11-24 21:21:05 -05: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
Andrew Kelley cd5f4de2a6
std: remove O_LARGEFILE from OS bits when the OS does not define it 2019-11-21 20:34:55 -05:00
Benjamin Feng 0f0d01a037 Replace magic numbers with named constants 2019-11-21 18:41:02 -06:00
Andrew Kelley bf1cbebea1 improve std.fs.selfExePath and related functions on Windows 2019-11-21 18:51:12 -05:00
Andrew Kelley cd37c1a377
add std.fs.Dir.openRead
This is progress towards file system APIs that encourage avoiding
Time Of Check, Time Of Use bugs.
2019-11-21 17:07:29 -05:00
Benjamin Feng b88bb93af3 WASI isatty 2019-11-19 20:17:00 -06:00
Benjamin Feng 14e9c7d1f2 WASI clock functions 2019-11-19 19:44:19 -06:00
Benjamin Feng c3d93cd9f2 WASI time_t / timespec 2019-11-19 16:12:26 -06:00
daurnimator 431eeb5e20
std: add pieces for WSAIoctl on windows 2019-11-15 10:31:52 +11:00
daurnimator 3b8afe31a0
std: add NtDeviceIoControlFile definition for windows 2019-11-15 10:31:51 +11:00
daurnimator 6469900e79
std: add WSAStartup and WSACleanup for windows 2019-11-15 10:31:47 +11:00
daurnimator 4cf535a01b
std: add WSASocketW for windows 2019-11-14 17:09:22 +11:00
daurnimator d9d3268cc1
std: add DeviceIoControl and GetOverlappedResult for windows 2019-11-14 17:09:21 +11:00
daurnimator f4c6cc3270
std: add winsock some definitions 2019-11-14 17:09:19 +11:00
daurnimator a832b35c19
std: add windows socket constants
Taken from https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw
2019-11-14 17:09:17 +11:00
daurnimator be86e41d97
std: add CTL_CODE function for windows 2019-11-14 17:09:16 +11:00
daurnimator 4830415071
std: add FILE_ANY_ constants for windows 2019-11-14 17:00:09 +11:00
daurnimator 0270545edb
std: add windows ioctl transfer types 2019-11-14 17:00:07 +11:00
daurnimator ef6cec983c
std: add windows FILE_DEVICE_ defines 2019-11-14 17:00:05 +11:00
Vexu f0c94d95dd
use @atomicStore in std lib 2019-11-13 00:52:15 +02:00
Luna d1eabe81a9 add sockaddr_un to os/bits/windows 2019-11-10 14:38:33 -03:00
Andrew Kelley 3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley aa0daea541
update more of the std lib to use `@as` 2019-11-08 15:57:25 -05:00
Andrew Kelley e0db54e89d
update the codebase to use `@as` 2019-11-08 15:57:24 -05:00
Andrew Kelley 2723ffc2b2
fixups and zig fmt 2019-11-08 01:52:23 -05:00
Andrew Kelley fbbcf2f30d
Merge branch 'adaptive_lock' of https://github.com/kprotty/zig into kprotty-adaptive_lock 2019-11-08 01:21:22 -05:00
kprotty b5d84635f2 remove WaitOnAddress backend in std.ThreadParker 2019-11-07 15:46:57 -06:00
kprotty b535e86cc0 move SpinLock definitions around 2019-11-07 15:32:20 -06:00
Andrew Kelley c7fd414dab
Merge pull request #3618 from nrdmn/uefi
UEFI improvements
2019-11-06 23:19:46 -05:00
Nick Erdmann 78b54d9c96
std/os/uefi: protocol handling improvements 2019-11-07 03:06:06 +01:00
Nick Erdmann cef51eaffb
std/os/uefi: snp, mnp, ip6, and udp6 support 2019-11-07 02:53:53 +01:00
Nick Erdmann f4767186dd
std/os/uefi: loading images 2019-11-07 02:53:53 +01:00
kprotty 465ebf494d ThreadParker implementation 2019-11-05 15:58:58 -06:00
kprotty 0d4f4aad9e adaptive SpinLock 2019-11-05 08:16:08 -06:00
Andrew Kelley 081c62fc00
fix regression in std.os.dirent64 on linux 2019-10-31 13:56:15 -04:00
Tse 00382f6dae DragonFlyBSD tidyup 2019-10-31 13:53:32 -04:00
Andrew Kelley 61d5a0bf48
Merge branch 'std.net' 2019-10-30 21:30:16 -04:00
Andrew Kelley 6a15e8a7a7
add comments to disabled tests linking to the tracking issue 2019-10-30 21:29:45 -04:00
Tse 33cc204481 DragonFlyBSD support 2019-10-30 21:21:58 -04:00
Andrew Kelley 7b7ba51642
fix os.sockaddr being a union instead of a struct 2019-10-30 20:57:20 -04:00
Andrew Kelley c52ee6efca
canonicalize std.os IPPROTO constants 2019-10-30 20:41:28 -04:00
Andrew Kelley 0de862e8ba
make std.net more portable
* Delete `std.net.TmpWinAddr`. I don't think that was ever meant to
   be a real thing.
 * Delete `std.net.OsAddress`. This abstraction was not helpful.
 * Rename `std.net.Address` to `std.net.IpAddress`. It is now an extern
   union of IPv4 and IPv6 addresses.
 * Move `std.net.parseIp4` and `std.net.parseIp6` to the
   `std.net.IpAddress` namespace. They now return `IpAddress` instead of
   `u32` and `std.net.Ip6Addr`, which is deleted.
 * Add `std.net.IpAddress.parse` which accepts a port and parses either
   an IPv4 or IPv6 address.
 * Add `std.net.IpAddress.parseExpectingFamily` which additionally
   accepts a `family` parameter.
 * `std.net.IpAddress.initIp4` and `std.net.IpAddress.initIp6` are
   improved to directly take the address fields instead of a weird
   in-between type.
 * `std.net.IpAddress.port` is renamed to `std.net.IpAddress.getPort`.
 * Added `std.net.IpAddress.setPort`.
 * `os.sockaddr` struct on all targets is improved to match the
   corresponding system struct. Previously I had made it a union of
   sockaddr_in, sockaddr_in6, and sockaddr_un. The new abstraction for
   this is now `std.net.IpAddress`.
 * `os.sockaddr` and related bits are added for Windows.
 * `os.sockaddr` and related bits now have the `zero` fields default
   to zero initialization, and `len` fields default to the correct size.
   This is enough to abstract the differences across targets, and so
   no more switch on the target OS is needed in `std.net.IpAddress`.
 * Add the missing `os.sockaddr_un` on FreeBSD and NetBSD.
 * `std.net.IpAddress.initPosix` now takes a pointer to `os.sockaddr`.
2019-10-30 20:22:05 -04:00
Andrew Kelley 618ee5b63a fixes for macos and 32 bit arches 2019-10-30 14:43:55 -04: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 d5865f5319
move libc/linux bits around 2019-10-28 15:29:50 -04:00
Andrew Kelley f4c244b3d0
partial no-libc implementation of std.net.getAddressList 2019-10-28 15:29:50 -04:00
Andrew Kelley 4b80e376e3
std.net.getAddressList 2019-10-28 15:29:50 -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
Andrew Kelley 17eb24a7e4
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
  `@import("std").builtin`. The target-related types are moved
  to `std.Target`. This allows the data types to have methods, such as
  `std.Target.current.isDarwin()`.
 * `std.os.windows.subsystem` is moved to
   `std.Target.current.subsystem`.
 * Remove the concept of the panic package from the compiler
   implementation. Instead, `std.builtin.panic` is always the panic
   function. It checks for `@hasDecl(@import("root"), "panic")`,
   or else provides a default implementation.

This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 19:09:49 -04:00
Andrew Kelley e839250c51
Merge branch 'stratact-no-dir-allocators'
closes #2885
closes #2886
closes #2888
closes #3249
2019-10-21 23:54:29 -04:00
Andrew Kelley fc6f84f3f0 fix os.unlinkatW implementation 2019-10-21 20:58:53 -04:00
Andrew Kelley 9a82f00a4f
add freebsd AT_* bits 2019-10-21 20:50:47 -04:00
Andrew Kelley 98c4365b66 darwin: add AT_* bits 2019-10-21 19:39:30 -04:00
Andrew Kelley 87f632b08a fs.Dir.openDir: use empty object name for "." on Windows 2019-10-21 19:19:49 -04:00
Andrew Kelley ef67c49785
[wip] use NtDll APIs on Windows to implement std.fs.Dir 2019-10-21 14:18:01 -04:00
stratact e78d3750c5
Use 8192 sized buffers and remove allocator parameters 2019-10-19 14:04:51 -04:00
Nick Erdmann 8774b1d947
std/os/windows: remove subsystem detection for uefi 2019-10-18 19:49:02 +02:00
Andrew Kelley 2aec35525d
mipsel: fix padding on stat struct 2019-10-17 13:20:30 -04:00
Andrew Kelley 45e5841281
Merge pull request #3464 from nrdmn/uefi
UEFI improvements
2019-10-16 18:14:32 -04:00
Andrew Kelley 5181970807
improve docs and field names of Statx struct 2019-10-16 17:24:42 -04:00
Nick Erdmann e6eae25053
std/os/uefi: add documentation 2019-10-16 21:46:41 +02:00
Nick Erdmann 77104da43e
std/os/uefi: add Guid format() 2019-10-16 19:49:51 +02:00
LemonBoy ead9630c13 Fix signedness for some fields in ARM stat definition 2019-10-12 20:52:10 +02:00
LemonBoy 40fc7a1fda Add support for the statx syscall 2019-10-12 20:51:51 +02:00
Andrew Kelley 01b2c291d5
miscellaneous improvements to generated docs
* introduce std.json.WriteStream API for writing json
   data to a stream
 * add WIP tools/merge_anal_dumps.zig for merging multiple semantic
   analysis dumps into one. See #3028
 * add std.json.Array, improves generated docs
 * add test for `std.process.argsAlloc`, improves test coverage and
   generated docs
2019-10-10 23:25:40 -04: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
Nick Erdmann ff9c3c6e5b std/os/uefi: fix Guid alignment in rng protocol 2019-09-29 12:28:14 -04:00
Andrew Kelley ce0e794092
fix glibc builds on aarch64-linux-gnu
There was a missing include path in the compilation line, leading to
incorrect fstat ABI.

closes #3291
2019-09-27 18:19:21 -04:00
LemonBoy 5aaa7d0fbb Avoid truncating mmap2 offsets if not multiple of page size 2019-09-27 18:18:38 +02:00
Nick Erdmann 4527110e02
std/os/uefi: add some hii support 2019-09-27 07:56:14 +02:00
Nick Erdmann a4f324e9ea
std/os/uefi: add exitBootServices and allocatePool 2019-09-27 07:56:02 +02:00
Andrew Kelley 23a82b5ffd
fix mipsel regression in previous commit
I think that should actually be a compile error, it's a usingnamespace
that depends on itself. This workaround is fine for now.
2019-09-26 21:38:04 -04:00
Andrew Kelley ebe79329a2
fix some linux declarations not getting exposed 2019-09-26 18:49:37 -04:00
LemonBoy a94372231c Errno changes for MIPS 2019-09-26 18:07:39 +02:00
LemonBoy a9be62f085 Fix wrong IOCTL value 2019-09-26 11:49:49 +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