Commit Graph

534 Commits (26e08d57016352c469ae34b3fbd61e7f2a85a76c)

Author SHA1 Message Date
Vexu 89310dad56
Merge branch 'master' into modernize-stage2 2019-11-23 23:01:28 +02:00
Vexu b9ef36094c
re-enable stage2 tests 2019-11-23 22:57:34 +02:00
Vexu 6c64f079fa
add workaround to child_process.zig 2019-11-23 22:06:51 +02:00
Vexu 7fa59565d3 fix small regressions in std.event 2019-11-23 14:01:00 -05:00
Andrew Kelley 7597735bad
update the stage1 implementation to the new proposal
See #3731
2019-11-23 04:45:35 -05:00
Vexu 4e6c1b676b
add cast to not hit #2561 2019-11-21 23:21:51 -05:00
Vexu 0e8a53514e
add missing error set to ChildProsess.SpawnError 2019-11-21 23:21:14 -05:00
Andrew Kelley fd6020c4e2
update tests, better error messages, update self-hosted tokenizer 2019-11-21 20:43:41 -05:00
Andrew Kelley cf2fe2536e
better error message when null termination does not match 2019-11-21 20:43:41 -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 21f344b3b9
add null terminated pointers and arrays to self-hosted
as well as `@typeInfo` and `@Type`
2019-11-21 20:43:41 -05:00
Andrew Kelley 1aa978f32e
implement null terminated pointers 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
Andrew Kelley 874b34a30f
self-hosted tokenizer handles \r in string literals 2019-11-20 21:03:17 -05:00
Andrew Kelley ed619245e9
remove dead code shebang support from self-hosted tokenizer 2019-11-20 20:18:19 -05:00
Benjamin Feng d27721f58c Add .enable_wasmtime build flag 2019-11-20 12:06:21 -06:00
Benjamin Feng 218f9ff34e Work around WASI's nonexistent @returnAddress() 2019-11-19 20:55:55 -06: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
Benjamin Feng 747529e96b Use wasm_allocator 2019-11-19 00:31:40 -06:00
Johan Bolmsjö ad77e93415 std.testing.expectEqual: show differing pointer values
Show differing pointer values when comparing pointers instead of the
content they point to.

It's confusing for a test to say "expected S{.x = 1}, found S{.x = 1}"
as illustrated below when it was the pointers that differed.

There seems to be different rules for when a pointer is dereferenced by
the printing routine depending on its type. I don't fully grok this but
it's also illustrated below.

    const std = @import("std");

    const S = struct { x: u32 };

    // before: ...expected S{ .x = 1 }, found S{ .x = 1 }
    // after:  ...expected S@7ffcd20b7798, found S@7ffcd20b7790
    test "compare_ptr_to_struct" {
        var a = S{.x = 1};
        var b = S{.x = 1};
        std.testing.expectEqual(&a, &b);
    }

    // before: ...expected u32@7fff316ba31c, found u32@7fff316ba318
    // after:  ...expected u32@7ffecec622dc, found u32@7ffecec622d8
    test "compare_ptr_to_scalar" {
        var a: u32 = 1;
        var b: u32 = 1;
        std.testing.expectEqual(&a, &b);
    }
2019-11-19 06:22:34 +00:00
dbandstra b3539b40a6 add `std.math.tau` constant (equivalent to 2 * pi) 2019-11-19 06:20:20 +00:00
frmdstryr aa4e92f3b3 Make StreamServer return address of accecpted client 2019-11-19 01:06:04 +00:00
Andrew Kelley 4dd3f42972
Merge pull request #3695 from daurnimator/towards-afd
Windows definitions
2019-11-17 23:17:48 +00:00
Andrew Kelley 57b8614a5a
Merge pull request #3697 from Vexu/container-docs
Implement container level doc comments
2019-11-17 22:31:12 +00:00
Andrew Kelley 8e3370367b
Merge pull request #3705 from daurnimator/fix-std.valgrind
std: fix outdated valgrind module
2019-11-17 22:29:17 +00:00
Vexu 6cddf9d723 properly parse anon literal in array 2019-11-17 22:24:21 +00:00
daurnimator d870a68e68
std: add a couple of tests to valgrind module 2019-11-17 14:16:09 +11:00
daurnimator 7d582d0a00
std: fix missing @ptrToInt in valgrind.memcheck 2019-11-17 14:14:57 +11:00
daurnimator 41c72bb54c
std: fix use of old syntax in std.valgrind.memcheck 2019-11-17 14:14:57 +11:00
daurnimator cc76494c42
std: use enum literals in valgrind module 2019-11-17 14:14:57 +11:00
daurnimator 4a3bb557f1
std: fix outdated valgrind module 2019-11-17 14:14:57 +11:00
Vexu 977b613881
add container doc comments to generated docs 2019-11-15 15:17:59 +02: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
Vexu b92f42d1f4
implemented container doc comments in stage 2 2019-11-14 16:25:06 +02: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
Andrew Kelley 0237e7a701 std.io.getStdOut and related fns no longer can error
Thanks to the Windows Process Environment Block, it is possible to
obtain handles to the standard input, output, and error streams without
possibility of failure.
2019-11-13 04:01:40 +00:00
Andrew Kelley 8bae70454d
Merge pull request #3675 from Vexu/atomic-store
Add @atomicStore builtin
2019-11-13 03:06:55 +00:00
Andrew Kelley 37318bf151
fn parameters participate in result location semantics
See #3665
2019-11-12 18:55:17 -05:00
Vexu f0c94d95dd
use @atomicStore in std lib 2019-11-13 00:52:15 +02:00
Sahnvour 956ba8b0e7
Merge pull request #3447 from Sahnvour/vcpkg
build: initial support for using vcpkg libraries
2019-11-12 20:16:01 +01:00
Vexu 5194fc57d1
use enum with atomics in std lib 2019-11-12 17:55:54 +02:00
Andrew Kelley d4e6a6d5e2
zig fmt: support anon struct and anon list init syntax 2019-11-11 13:12:45 -05:00
Andrew Kelley 5b27943498
implement anon struct literal syntax
This implements stage1 parser support for anonymous struct literal
syntax (see #685), as well as semantic analysis support for anonymous
struct literals and anonymous list literals (see #208). The semantic
analysis works when there is a type coercion in the result location;
inferring the struct type based on the values in the literal is not
implemented yet. Also remaining to do is zig fmt support for this new
syntax and documentation updates.
2019-11-11 13:11:58 -05:00
Andrew Kelley ae0a219d1f
stop accepting deprecated `use` keyword
closes #2591
2019-11-11 13:02:39 -05:00
Felix Queißner cd5c9c8998 Fix missing @as cast in std.fmt.formatInt (#3650) 2019-11-10 23:08:24 +00:00
Andrew Kelley d44a69689e
std.ChildProcess.spawn has a consistent error set
across targets. Also fix detection of pkg-config not
installed on Windows when using zig build.
2019-11-10 15:40:27 -05:00
Andrew Kelley 891e2149b0
Merge pull request #3635 from lun-4/unify-unix-sockets
std.net: add unix socket support to Address and StreamServer
2019-11-10 20:40:19 +00:00
Luna c8a8da2804 remove builtin.os check in Address.initUnix 2019-11-10 16:44:18 -03:00
Luna d1eabe81a9 add sockaddr_un to os/bits/windows 2019-11-10 14:38:33 -03:00
Luna d99ecef943 replace panic to unreachable
- remove error.UnsupportedOS from StreamServer.listen
2019-11-10 14:17:39 -03:00
Luna 2d02920a90 use hasDecl instead of switch on builtin.os 2019-11-10 14:04:52 -03:00
dimenus 98e37537d1 minor fix due to recent directory handling API changes 2019-11-10 16:34:31 +00:00
Luna 25423eb453 add errors/panics for unsupported OSes 2019-11-10 10:50:22 -03:00
Luna e4704f68f8 use at-as 2019-11-09 15:10:39 -03:00
Luna fc2e8f92b2 Merge remote-tracking branch 'upstream/master' into unify-unix-sockets 2019-11-09 15:07:09 -03:00
Luna 348c0232a5 miscellaneous fixes
- make connextUnixSocket use std.net.Address
 - fix StreamServer.listen giving wrong protocol for unix sockets
2019-11-09 14:53:48 -03:00
Luna 05ae21b78e make StreamServer.listen family-agnostic
- rename Address.parseUnix to Address.initUnix
2019-11-09 12:51:33 -03:00
Luna f4d8dc278b rename TcpServer -> StreamServer
- add AF_UNIX support to getOsSockLen
2019-11-09 12:40:56 -03:00
Sahnvour def5462d05 build: initial support for using vcpkg libraries 2019-11-09 12:37:38 +01:00
Luna c2325053a8 add Address.parseUnix and Address.format support for AF_UNIX 2019-11-08 21:44:17 -03:00
dimenus 8c8078513e missed cast in std/target.zig 2019-11-08 19:19:08 -05:00
Luna 9458620e18 replace Address.parse Address.parseIp 2019-11-08 19:59:30 -03:00
Luna 5d05cfcfe6 rename IpAddress to Address, add Address.unix 2019-11-08 19:35:04 -03:00
Andrew Kelley f7b1e02158 fix type cast in windows child process code 2019-11-08 17:05:20 -05: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 e2189b6e5d cleanup getEventHandle 2019-11-07 19:37:53 -06:00
kprotty 43900011f7 handle NtCreateKeyedEvent failure by spinning to ensure correctness 2019-11-07 18:56:43 -06:00
kprotty fe8c1cf804 missing `os` declaration 2019-11-07 17:14:08 -06:00
kprotty bb4abfdc78 Use `system` instead of `builtin.link_libc` 2019-11-07 16:36:33 -06:00
kprotty 12e68cbeb6 pthread_sched_yield -> sched_yield 2019-11-07 16:33:25 -06:00
kprotty f41e58d015 fix SpinLock.yield for pull/3626 2019-11-07 15:51:20 -06: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
Vexu 459a364a33 allow Group to optionally manage function frames' memory 2019-11-07 13:26:49 -05:00
Vexu 3858a526e3 make callMainAsync async 2019-11-07 13:18:47 -05:00
kprotty 92dac89d01 lock the mutex on pthread_cond_signal() 2019-11-07 09:23:02 -06:00
LemonBoy cf6fb89ced
Add small tokenizer test case for #3468 2019-11-07 02:46:10 -05: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
Andrew Kelley 6ee3cabe5c
allow type coercion from *[0]T to E![]const T
This is an unambiguous, safe cast.
2019-11-06 20:44:15 -05:00
kprotty 7045f1e875 skip std.ThreadParker test on single-threaded 2019-11-06 17:23:44 -06:00
shiimizu 7277670843 Add error when too few arguments are provided to std.fmt 2019-11-06 18:22:33 -05:00
Sebastian Keller f81f36e2ff std.json.Value: added dumpStream(), utilize WriteStream for dump() 2019-11-06 18:21:52 -05:00
Vexu 4530adbd33 use global event loop in std.event types 2019-11-06 15:17:40 -05:00
Andrew Kelley 913f7d0450
improve the start code for evented I/O
When evented I/O is being used, prevent event loop from terminating
at least until main() has returned.
2019-11-06 15:08:29 -05:00
Brendan Hansknecht c1e8fdf812 add token for parsing pointer dereference 2019-11-06 14:03:21 -05:00
Sebastian Keller dd4e9fb16b Fixed a leak in the json parser.
parseString() created a copy of the string using the wrong allocator.
Instead of using the ArenaAllocator, it was using the allocator passed
into Parser.init(). This lead to a leak as the copied string was not
freed when the ArenaAllocator was deinited.
2019-11-06 14:00:36 -05:00
kprotty 4dbfc48ab3 Disable asm("yield") for arm in SpinLock.yieldCpu() because of CI 2019-11-05 16:16:03 -06:00
kprotty c9db420a09 Adaptive Mutex:
- uses std.ThreadParker
- supports static initialization (deprecates StaticallyInitializedMutex)
2019-11-05 16:14:43 -06:00
kprotty 465ebf494d ThreadParker implementation 2019-11-05 15:58:58 -06:00
kprotty 14209cf615 make SpinLock.Backoff pub 2019-11-05 13:43:17 -06:00
Andrew Kelley 9bc4f8ea77
zig build: addIncludeDir does -I instead of -isystem 2019-11-05 14:32:17 -05:00
Vexu a26e9fa723 add special formatting for ipv4-mapped ipv6 addresses 2019-11-05 12:05:34 -05:00
Andrew Kelley 4e9ab0306a
Merge pull request #3587 from LemonBoy/fix-things
Bunch'o'fixes
2019-11-05 11:44:07 -05:00
Shawn Landden 1c22cb5e51 fix noreturn function that may return.
we do not want undefined behavior here in --release-fast
and --release-small modes
2019-11-05 11:38:32 -05:00
Shawn Landden 55685ae780 remove duplicate isNan implementation 2019-11-05 11:34:33 -05:00
lukechampine 3d907b2943 crypto: Add support for AES-CTR 2019-11-05 11:33:11 -05:00
kprotty 84e370d0b2 Move hybrid yielding into its own struct 2019-11-05 09:31:29 -06:00
kprotty 0d4f4aad9e adaptive SpinLock 2019-11-05 08:16:08 -06:00
daurnimator 1657bead46 std: Add fifo useful for buffers 2019-11-04 17:44:01 -05:00
data-man 42ccdc2765 Replace AES variables to constants 2019-11-04 17:43:14 -05:00
Andrew Kelley ce70a9be24
Merge pull request #3589 from Vexu/ipv6-improvements
Ipv6 improvements
2019-11-04 15:22:14 -05:00
Andrew Kelley 6c17282062
std.os.read can fail with ConnectionResetByPeer 2019-11-04 14:40:30 -05:00
Andrew Kelley aaf50970a8
Merge pull request #3574 from lukechampine/aes
crypto: Add AES implementation
2019-11-04 14:39:40 -05:00
LemonBoy c8b6e55299 Make the `leb` module available to non-std code 2019-11-04 20:33:40 +01:00
Luke Champine eb95afbc66
remove speculative AES TODOs 2019-11-04 13:59:26 -05:00
Andrew Kelley 5db77e3c66
Merge pull request #3588 from daurnimator/tiny-std-fixes
Tiny std fixes
2019-11-04 13:25:37 -05:00
Brendan Hansknecht 52207f22de Add karatsuba to big ints 2019-11-04 13:20:03 -05:00
Vexu 6e786b60d4
support ipv4-mapped ipv6 addresses 2019-11-04 19:54:36 +02:00
Vexu 32ac1b5927
improve ipv6 parsing and formatting 2019-11-04 19:00:58 +02:00
daurnimator c8463ce9b0
std: Add definitions for (deprecated) futimes and utimes C functions 2019-11-05 02:19:25 +11:00
daurnimator 6e635c6406
std: close is OSX specific 2019-11-05 02:16:30 +11:00
kprotty bb6ad1a6c2 Remove StaticallyInitializedMutex 2019-11-03 21:09:51 -06:00
Luna 2e0dd5733f add FileNotFound to os.ConnectError error set 2019-11-02 15:49:15 -04:00
Luna d535bf2c7d add FileNotFound error to os.connect 2019-11-02 15:49:15 -04:00
Andrew Kelley f749bf0942
std.os: fix sendto, poll, recvfrom when linking libc
Thank you to Brendan Hansknecht for this patch.
2019-11-02 15:15:56 -04:00
lukechampine f403aa6cee crypto: Add AES implementation 2019-11-01 22:42:25 -04:00
Andrew Kelley d6dec80261
startup code respects root source file's event_loop if present 2019-10-31 14:21:04 -04: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 d3d3e4e374
startup code sets up event loop if I/O mode is declared evented 2019-10-31 11:41:39 -04:00
Andrew Kelley 788848e123
std.net: fix reference to incorrect constant name 2019-10-30 23:03:49 -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
Henry Wu 7c73503451 generated docs: move color to box-shadow CSS prop 2019-10-30 21:20:02 -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 d7f15aa2cb
Merge remote-tracking branch 'origin/master' into std.net 2019-10-30 20:43:56 -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 f5ff36271b
Merge branch 'testAddresses' of https://github.com/marler8997/zig into std.net 2019-10-30 12:33:47 -04:00
Andrew Kelley 0fb1388031
std.net: enable test for resolving DNS 2019-10-30 12:16:47 -04:00
Nathan Michaels 1f0bcefe4a Document PriorityQueue. 2019-10-30 01:05:00 -04:00
Andrew Kelley 16397241f6
fix std.net tests and std.net.TcpServer docs 2019-10-30 00:50:30 -04:00
Andrew Kelley d5e438b36e
rename std.net.Server to TcpServer and simplify it 2019-10-30 00:34:30 -04:00
Andrew Kelley c3d816a98e
std lib networking improvements, especially non-blocking I/O
* delete the std/event/net directory
 * `std.event.Loop.waitUntilFdReadable` and related functions
   no longer have possibility of failure. On Linux, they fall
   back to poll() and then fall back to sleep().
 * add some missing `noasync` decorations in `std.event.Loop`
 * redo the `std.net.Server` API. it's quite nice now, but
   shutdown does not work cleanly. There is a race condition with
   close() that I am actively working on.
 * move `std.io.OutStream` to its own file to match `std.io.InStream`.
   I started working on making `write` integrated with evented I/O,
   but it got tricky so I backed off and filed #3557. However
   I did integrate `std.os.writev` and `std.os.pwritev` with evented I/O.
 * add `std.Target.stack_align`
 * move networking tests to `lib/std/net/test.zig`
 * add `std.net.tcpConnectToHost` and `std.net.tcpConnectToAddress`.
 * rename `error.UnknownName` to `error.UnknownHostName` within the
   context of DNS resolution.
 * add `std.os.readv`, which is integrated with evented I/O.
 * `std.os.preadv`, is now integrated with evented I/O.
 * `std.os.accept4` now asserts that ENOTSOCK and EOPNOTSUPP never
    occur (misuse of API), instead of returning errors.
 * `std.os.connect` is now integrated with evented I/O.
   `std.os.connect_async` is gone. Just use `std.os.connect`.
 * fix false positive dependency loop regarding async function frames
 * add more compile notes to help when dependency loops occur
   in determining whether a function is async.
 * ir: change an assert to ir_assert to make it easier to find
   workarounds for when such an assert is triggered. In this case
   it was trying to parse an IPv4 address at comptime.
2019-10-29 22:59:30 -04:00
lukechampine 48b5dc0516 inline path separator loop 2019-10-29 21:32:02 -04:00
Andrew Kelley 8d3b7689ad
std.net: port the RFC 3484/6724 destination...
...address selection from musl libc
2019-10-29 16:10:14 -04:00
Andrew Kelley 9ade31faaf
implement CNAME expansion 2019-10-29 14:03:39 -04:00
Jonathan Marler 4e0c2ed443 Add tests for ip address formatting 2019-10-29 00:27:45 -06: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 a3222b5ff1
remove dead tls code 2019-10-28 15:10:12 -04:00
Andrew Kelley b37c009683
Merge pull request #3541 from xackus/language_server
* fix json parser crashing on empty input

* make implicit cast of tagged unions to enums easier to find in docs
2019-10-28 15:08:33 -04:00
Timon Kruiper 03603ea353 Std docs: Fix a js error that would cause some function to be not rendered 2019-10-28 15:06:55 -04:00
Nathan Michaels 6fdeaac338 Add some documentation for standard library things. (#3540)
* Add some documentation for standard library things.

Added a bunch of descriptions for array_list.
Added some usage notes for failing_allocator.
Documented some of mem.Allocator.
2019-10-28 03:57:23 -04:00
xackus 36fa5fabc6 rename error and specify it in function 2019-10-27 21:52:28 +01:00
xackus eeb6536c85
better test name for empty string
Co-Authored-By: Andrew Kelley <andrew@ziglang.org>
2019-10-27 21:41:52 +01:00
Andrew Kelley 8af6c7e34c
Merge pull request #3522 from SebastianKeller/WriteJson
Added 'writeJson' to write_stream.zig:
2019-10-27 15:53:24 -04:00
Sebastian Keller 78b00c0b51 Added test for 'emitJson' 2019-10-27 20:49:42 +01:00
Sebastian Keller ac705a7bb6 Unified public api 2019-10-27 20:15:48 +01:00
Henry Wu f756d875b1 generated docs: vertically align fns with comments 2019-10-27 15:11:36 -04:00
Andrew Kelley 4a57913ca0
std.target: use mem instead of std.mem 2019-10-27 14:27:20 -04:00
Benoit Giannangeli 73c4a5f186 lib/std/target.zig: Added missing 'mem' constant 2019-10-27 14:26:25 -04:00
xackus a0abd3be85 fix json parser crashing on empty input
remove unreachable code
2019-10-27 10:45:54 +01:00
Luna d4e41c5bc6 std: make addr_size parameter be a pointer to socklen_t
removes ptrCast
2019-10-26 22:05:17 -03:00
Luna bf16fc210b fix std.os.accept4
- add WouldBlock to list of errors in AcceptError
 - ptrCast addr_size to the system's socklen_t, instead of assuming it's
    usize
2019-10-26 22:00:50 -03:00
Andrew Kelley 55c282ed51
os.dup2: handle EBAF 2019-10-24 21:13:05 -04:00
Sebastian Keller 6257b4c596 Shortened switch statement 2019-10-24 22:44:12 +02:00
Sebastian Keller b82b6a7093 Added 'writeJson' to write_stream.zig:
Small addition to make writing a json value easier
2019-10-24 14:23:36 +02: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 8591731f2b
refAllDecls in a test block to limit when it gets run 2019-10-24 00:32:18 -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
Jonathan Marler ef62452363 Handle TERM=dumb for stdout/stderr 2019-10-23 11:44:39 -04:00
Andrew Kelley 0dbdb6329f
Merge pull request #3503 from MasterQ32/markdown-renderer
Starts to implement markdown parser.
2019-10-22 15:26:42 -04:00
Felix Queißner c71857703f Adds documentation for std.fmt.format grammar and customization. (#3474) 2019-10-22 14:58:27 -04:00
Felix Queißner 03f1ad5007 Merge branch 'master' of https://github.com/ziglang/zig into markdown-renderer 2019-10-22 20:29:25 +02: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 a5cc758036
std.os.accept4: improve docs and integrate with evented I/O 2019-10-21 23:23:11 -04:00
Jonathan Marler 87b11617b5 Fix accept function API
The sockaddr pointer and size of the accept function points to a data structure that can only be determined at runtime.  The only requirement is that it must be large enough to hold 2 bytes for the address family value.  Typeical usage of the socket API is for UDP/TCP IPv4 and IPv6 sockets, which use sockaddr_in and sockaddr_in6.  And some sockets can actually support both simultaneously in which case the app may want to have access to the size of the returned sockaddr.  Operating systems can even support custom protocols where they use custom sockaddr data structures.  In this case the standard library would have no knowledge of the actual size of the sockaddr being passed into the accept function.  In this case the standard library should defer to the app to pass in the size of their structure.
2019-10-21 23:12:35 -04:00
Vexu 2550cb4638 remove pub syntax for container fields 2019-10-21 23:04:19 -04:00
Andrew Kelley 064377be9a
test runner: restore previous behavior of printing all tests passed 2019-10-21 22:21:18 -04:00
Andrew Kelley fc6f84f3f0 fix os.unlinkatW implementation 2019-10-21 20:58:53 -04:00
Andrew Kelley 65165554d0
test runner: restore previous behavior when...
...stderr does not support ansi escape codes
2019-10-21 20:50:47 -04:00
Andrew Kelley 9a82f00a4f
add freebsd AT_* bits 2019-10-21 20:50:47 -04:00
Andrew Kelley 5917572e59
cleanup 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 859cbef8a4
test runner: refresh display before running test
This makes it so that when a test fails quickly, and writes output, it
will do so after the test name is printed.
2019-10-21 19:01:08 -04:00
Andrew Kelley 16a91e6a45
adjust test runner to print the test name when error occurs 2019-10-21 18:36:37 -04:00
Andrew Kelley ef67c49785
[wip] use NtDll APIs on Windows to implement std.fs.Dir 2019-10-21 14:18:01 -04:00
Andrew Kelley 5b1a492012
breaking: improve std.fs directory handling API
* Added `std.c.unlinkat` and `std.os.unlinkat`.
 * Removed `std.fs.MAX_BUF_BYTES` (this declaration never made it to
   master branch)
 * Added `std.fs.Dir.deleteTree` to be used on an open directory handle.
 * `std.fs.deleteTree` has better behavior for both relative and
   absolute paths. For absolute paths, it opens the base directory
   and uses that handle for subsequent operations. For relative paths,
   it does a similar strategy, using the cwd handle.
 * The error set of `std.fs.deleteTree` is improved to no longer have
   these possible errors:
   - OutOfMemory
   - FileTooBig
   - IsDir
   - DirNotEmpty
   - PathAlreadyExists
   - NoSpaceLeft
 * Added `std.fs.Dir.posix_cwd` which is a statically initialized
   directory representing the current working directory.
 * The error set of `std.Dir.open` is improved to no longer have these
   possible errors:
   - FileTooBig
   - IsDir
   - NoSpaceLeft
   - PathAlreadyExists
   - OutOfMemory
 * Added more alternative functions to `std.fs` for when the path
   parameter is a null terminated string. This can sometimes be more
   effecient on systems which have an ABI based on  null terminated
   strings.
 * Added `std.fs.Dir.openDir`, `std.fs.Dir.deleteFile`, and
   `std.fs.Dir.deleteDir` which all operate on an open directory handle.
 * `std.fs.Walker.Entry` now has a `dir` field, which can be used to do
   operations directly on `std.fs.Walker.Entry.basename`, avoiding
   `error.NameTooLong` for deeply nested paths.
 * Added more docs to `std.os.OpenError`

This commit does the POSIX components for these changes. I plan to
follow up shortly with a commit for Windows.
2019-10-20 21:48:23 -04:00
Felix Queißner 5456eb1107 Starts to implement markdown parser. Implemented: strong, emphasis, strikethrough, underline, code blocks, ulist, olist, paragraphs, headings. Planned: Links, Images, internal references. 2019-10-20 11:49:28 +02:00
Andrew Kelley 6948d7fce7
Merge pull request #3429 from Rocknest/docs-local
Design suggestion for generated docs
2019-10-19 16:43:39 -04:00
stratact e78d3750c5
Use 8192 sized buffers and remove allocator parameters 2019-10-19 14:04:51 -04:00
Nick Erdmann c8dec5729c
std/build: make subsystem configurable 2019-10-18 20:11:28 +02:00
Nick Erdmann 8774b1d947
std/os/windows: remove subsystem detection for uefi 2019-10-18 19:49:02 +02:00
Andrew Kelley 2d5b2bf1c9
improve progress reporting
* use erase rest of line escape code.
 * use `stderr.supportsAnsiEscapeCodes` rather than `isTty`.
 * respect `--color off`
 * avoid unnecessary recursion
 * add `Progress.log`
 * disable the progress std lib test since it's noisy and uses
   `time.sleep()`.
 * enable/integrate progress printing with the default test runner
2019-10-17 21:55:49 -04:00
Andrew Kelley 299991019d
rework the progress module and integrate with stage1 2019-10-17 20:20:22 -04:00
Luna a73c7bcaf9
add lib/std/progress.zig 2019-10-17 13:32:45 -04:00
Andrew Kelley 2aec35525d
mipsel: fix padding on stat struct 2019-10-17 13:20:30 -04:00
Andrew Kelley f80c01f9d8
ref more math decls for better docs 2019-10-16 19:16:57 -04:00
Rocknest 40d53a7bc5
Merge branch 'master' into docs-local 2019-10-17 01:57:29 +03:00
Rocknest c95a9e9785 Cleanup 2019-10-17 01:54:39 +03:00
Rocknest 1c5dfaaca9 Changes from master 2019-10-17 01:35:10 +03:00
Andrew Kelley 7598a579ff
turn comments into doc comments 2019-10-16 18:33:12 -04:00
Sebsatian Keller 1b07ff7be0
Add 'missing' consts to math.zig
The C library defines constants for log2e and sqrt2 etc. Those should also be available in zig.
2019-10-16 18:31:22 -04:00
Emeka Nkurumeh 700bb19a90 fix std.mem.AsBytesReturnType (#3442)
closes #3334
2019-10-16 18:15:52 -04:00
Andrew Kelley 45e5841281
Merge pull request #3464 from nrdmn/uefi
UEFI improvements
2019-10-16 18:14:32 -04:00
Andrew Kelley 09abd09ab8
add docs for std.fs.File.updateTimes 2019-10-16 18:13:40 -04:00
LemonBoy 6a549a7f0c Fix compilation of updateTimes on 32bit platforms
Add a test to avoid regressions.

Fixes #3412
2019-10-16 18:10:32 -04:00
Andrew Kelley 5181970807
improve docs and field names of Statx struct 2019-10-16 17:24:42 -04:00
Andrew Kelley 312880f102
Merge pull request #3439 from LemonBoy/statx
Add support for the statx syscall
2019-10-16 17:11:22 -04:00
Nick Erdmann e6eae25053
std/os/uefi: add documentation 2019-10-16 21:46:41 +02:00
Andrew Kelley 8cf3a4d586
[breaking] standardize std.os execve functions
* `std.os.execve` had the wrong name; it should have been
   `std.os.execvpe`. This is now corrected.
 * introduce `std.os.execveC` which does not look at PATH, and uses
   null terminated parameters, matching POSIX ABIs. It does not
   require an allocator.
 * fix typo nonsense doc comment in `std.fs.MAX_PATH_BYTES`.
 * introduce `std.os.execvpeC`, which is like `execvpe` except it
   uses null terminated parameters, matching POSIX ABIs, and thus
   does not require an allocator.
 * `std.os.execvpe` implementation is reworked to only convert
   parameters and then delegate to `std.os.execvpeC`.
 * `std.os.execvpeC` improved to handle `ENOTDIR`. See #3415
2019-10-16 15:24:48 -04:00
Nick Erdmann 77104da43e
std/os/uefi: add Guid format() 2019-10-16 19:49:51 +02:00
Andrew Kelley 1014cfdf3b
generated docs: progress towards generic types being useful
See #3406
2019-10-16 01:49:02 -04:00
Andrew Kelley e6ca61bdd1
generated docs: further clean up keyboard shortcut handling
now it's harder to introduce a bug when modifying keyboard shortcut
code.
2019-10-15 18:37:24 -04:00
dtw-waleee 725c873e81
fix small misstake, 'escape' v. 'Escape' 2019-10-15 18:19:13 -04:00
dtw-waleee 3e891c9c0b
Fix keyboard layout issue with help-modal
Some keyboard layouts produces a different ev.which value in firefox
for ? than 191, eg. the Swedish QWERTY one produces 171. Chrome/chromium
doesn't have this issue.
2019-10-15 18:19:13 -04:00
tgschultz 6a629d3a9f Replaced setTag hack in Deserialize with @unionInit 2019-10-15 18:14:13 -04:00
Vexu 7495fd8cb9 fix struct align fmt 2019-10-15 17:58:02 -04:00
LemonBoy b164e0ae55 Fix stack iteration stop condition 2019-10-13 17:49:47 -04:00
LemonBoy b1f3f59d66 Fix fp-based backtracing on RISC-V
The fp points to the top of the frame instead of pointing to the old fp,
compensate this difference with an offset.
2019-10-13 12:13:41 +02:00
LemonBoy ba711f1115 Add ELF architecture constant for RISC-V 2019-10-13 12:12:33 +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
Rocknest b175468159 Consistent margins 2019-10-12 19:17:35 +03:00
Andrew Kelley 8b45921664
merge targets of generated docs 2019-10-11 18:14:06 -04:00
Andrew Kelley 30a555eed4
merge dumps tool: merging ast nodes
-fgenerate-docs is replaced ith -femit-docs
-fno-emit-bin is added to prevent outputting binary
2019-10-11 18:13:24 -04: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
Andrew Kelley 0e0976828a
Merge pull request #3421 from LemonBoy/win32-mingw
Win32 mingw
2019-10-10 21:23:28 -04:00
Rocknest b0cd64c019
Merge branch 'master' into docs-local 2019-10-11 04:09:01 +03:00
Rocknest 2bb2a2fcea Changes from master 2019-10-11 03:54:03 +03:00
Andrew Kelley 6082c14753
generated docs: add optional type support 2019-10-10 20:32:17 -04:00
Andrew Kelley bc393eefa1
generated docs: better rendering of unknown decls 2019-10-10 19:21:56 -04:00