Commit Graph

1888 Commits (68cc068a3aa5df8bd1995d10a9133af1fa1ea1d3)

Author SHA1 Message Date
LeRoyce Pearson 86fe88bbcb Use std.fs.base64_encoder in std.cache_hash 2020-05-25 13:48:43 -04:00
LeRoyce Pearson 8c8813a5cf Add filesystem base64 decoder 2020-05-25 13:48:43 -04:00
LeRoyce Pearson ce5b2286f1 Support caching bools; make caching values infallible 2020-05-25 13:48:43 -04:00
LeRoyce Pearson de341b8fb8 Fix memory leak in cache_hash 2020-05-25 13:48:43 -04:00
LeRoyce Pearson 8a77c1c637 Add `cache` method; add support for caching integers 2020-05-25 13:48:43 -04:00
LeRoyce Pearson 3158dc424e Partially implement cache hash API in zig 2020-05-25 13:48:43 -04:00
data-man 0ecdbdb3cb Support comptime floats in std.fmt 2020-05-25 12:48:59 -04:00
Alexandros Naskos 65d827183b Added custom build step id, made tests.zig steps use it 2020-05-25 11:36:12 +03:00
Alexandros Naskos d268e0cf2e Added and id and a cast function to build steps 2020-05-25 11:20:31 +03:00
Andrew Kelley 3052fd84c8 fix regression in std.os.windows.fromSysTime 2020-05-25 00:37:47 -04: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
LeRoyce Pearson c6e7d0fcfd Use better names for darwin timestart 2020-05-24 21:40:08 -04:00
LeRoyce Pearson b85a191398 Fix compile errors for MacOS 2020-05-24 21:40:08 -04:00
LeRoyce Pearson 2dfe798217 Use `once` to init _timestart in thread safe way 2020-05-24 21:40:08 -04:00
LeRoyce Pearson 7586ce0023 Implement a faster way to get nanoseconds on darwin 2020-05-24 21:40:08 -04:00
LeRoyce Pearson bb46894115 Add `std.time.nanoTimestamp` function 2020-05-24 21:40:08 -04:00
Jethro Nederhof 4b1a846471
target: Implement running OS version detection for FreeBSD (#5416)
* target: Implement OS version detection for FreeBSD

Fixes #4582

* freebsd version: handle errors explicitly
2020-05-24 20:52:13 -04:00
data-man db0c30446a Supports vectors in mem.zeroes 2020-05-24 20:48:29 -04:00
data-man b13dd3cf61 Treat vectors as indexable 2020-05-24 20:44:17 -04:00
Andrew Kelley dd05f2be80 run zig fmt on std lib 2020-05-24 10:04:09 -04:00
Andrew Kelley 1c0b7ddda8 fix regression in AST node iteration
the new iteration code caused an integer underflow for function
prototypes with no parameters. now fixed.
2020-05-24 10:03:26 -04:00
Andrew Kelley 2ff3995a70
Merge pull request #5378 from ziglang/speed-up-stage2-parsing
improve std.zig.parse performance using flat arrays for AST nodes and tokens
2020-05-24 09:44:08 -04:00
Andrew Kelley f771545a7e revert std.zig.ast iterator changes back to master branch API 2020-05-23 20:14:38 -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
Andrew Kelley 8f6d7b3208 std: update singly linked list tests to new API 2020-05-23 16:38:43 -04:00
Greg Anders 64955deb72 Add poll definitions for Darwin 2020-05-22 13:21:34 -04:00
Andrew Kelley 8df0841d6a stage2 parser: token ids in their own array
To prevent cache misses, token ids go in their own array, and the
start/end offsets go in a different one.

perf measurement before:
         2,667,914      cache-misses:u
     2,139,139,935      instructions:u
       894,167,331      cycles:u

perf measurement after:
         1,757,723      cache-misses:u
     2,069,932,298      instructions:u
       858,105,570      cycles:u
2020-05-22 12:34:12 -04:00
Andrew Kelley 295bca9b5f stage2 parser: don't append doc comments to the list
The DocComment AST node now only points to the first doc comment token.
API users are expected to iterate over the following tokens directly.

After this commit there are no more linked lists in use in the
self-hosted AST API.

Performance impact is negligible. Memory usage slightly reduced.
2020-05-22 00:28:59 -04:00
Andrew Kelley 1dac9e71b5 std.testing: fix a crash when printing diffs 2020-05-22 00:27:51 -04:00
Andrew Kelley 8252c8b9d6 stage2 parser: different multiline string literal parsing strategy
and using flat memory rather than singly linked list

roughly equivalent performance, slightly reduced memory usage, better
API.
2020-05-21 23:25:15 -04:00
Andrew Kelley 19de259936 stage2 parser: arrays and structs directly in memory after the node
Slightly reduced memory usage. Roughly the same API and perf.
2020-05-21 22:52:45 -04:00
Andrew Kelley 9377af934f stage2 parser: SwitchCase uses intrusive array instead of linkedlist
no perf impact, but the API is better
2020-05-21 22:28:30 -04:00
Andrew Kelley d37b81d43b stage2 parser performance/API improvements
* Extract Call ast node tag out of SuffixOp; parameters go in memory
   after Call.
 * Demote AsmInput and AsmOutput from AST nodes to structs inside the
   Asm node.
 * The following ast nodes get their sub-node lists directly following
   them in memory:
   - ErrorSetDecl
   - Switch
   - BuiltinCall
 * ast.Node.Asm gets slices for inputs, outputs, clobbers instead of
   singly linked lists

Performance changes:

throughput: 72.7 MiB/s => 74.0 MiB/s
maxrss: 72 KB => 69 KB (nice)
2020-05-21 22:01:16 -04:00
Andrew Kelley 32ecb416f3 fix compile errors when setting NodeIndex/TokenIndex to u32 2020-05-21 00:30:08 -04:00
Andrew Kelley d57d9448aa stage2 parsing: rework block statements AST memory layout
block statements are now directly following the Block AST node rather
than a singly linked list. This had negligible impact on performance:

throughput: 72.3 MiB/s => 72.7 MiB/s

however it greatly improves the API since the statements are laid out in
a flat array in memory.
2020-05-20 23:47:04 -04:00
Andrew Kelley 688aa114e4 Revert "stage2 parser: elide memcpy of large initialization lists"
This reverts commit 84df1d4f3d.

Not worth the complexity! Always memcpy initialization lists into the
arena.
2020-05-20 22:42:43 -04:00
Andrew Kelley 84df1d4f3d stage2 parser: elide memcpy of large initialization lists
throughput: 71.4 MiB/s => 72.9 MiB/s
2020-05-20 22:41:18 -04:00
Andrew Kelley 44aeb38328 make rand function public, fixes crypto benchmark 2020-05-20 21:27:08 -04:00
Andrew Kelley 897f23f20f stage2 parser: split off some SuffixOp AST nodes into separate tags
These SuffixOp nodes have their own ast.Node tags now:
 * ArrayInitializer
 * ArrayInitializerDot
 * StructInitializer
 * StructInitializerDot

Their sub-expression lists are general-purpose-allocator allocated
and then copied into the arena after completion of parsing.

throughput: 72.9 MiB/s => 74.4 MiB/s
maxrss: 68 KB => 72 KB

The API is also nicer since the sub expression lists are now flat arrays
instead of singly linked lists.
2020-05-20 19:18:14 -04:00
Andrew Kelley 7c2c0e36f8 stage2 parser: different memory layout of ParamDecl
Instead of being its own node, it's a struct inside FnProto.
Instead of FnProto having a SinglyLinkedList of ParamDecl nodes,
ParamDecls are appended directly in memory after the FnProto.

throughput: 72.2 MiB/s => 72.9 MiB/s
maxrss: 70 KB => 68 KB

Importantly, the API is improved as well since the data is arranged
linearly in memory.
2020-05-20 17:39:54 -04:00
Andrew Kelley ad4b591db1 small bump to ArenaAllocator minimum alloc size
self-hosted parser benchmark:
throughput: 69.4 MiB/s => 72.2 MiB/s
2020-05-20 16:30:28 -04:00
Andrew Kelley 64c149ca19 fields and decls: ArrayList appending, memcpy to ast arena
This makes fields and decl ast nodes part of the Root and ContainerDecl
AST nodes.

Surprisingly, it's a performance regression from using a singly-linked
list for these nodes:

throughput: 76.5 MiB/s => 69.4 MiB/s

However it has much better memory usage:

maxrss: 392 KB => 77 KB

It's also better API for consumers of the parser, since it is a flat
list in memory.
2020-05-20 16:13:02 -04:00
Andrew Kelley b1bcdc96ca arena allocator: smaller minimum allocation size 2020-05-20 16:11:55 -04:00
Andrew Kelley 8c10178a1e golly jeepers it's taking a long time to update translate-c 2020-05-20 13:53:53 -04:00
Andrew Kelley 4617c5907a fix zig fmt test regressions 2020-05-20 00:19:00 -04:00
Andrew Kelley 82225f6568 zig fmt parser tests are compiling again 2020-05-19 23:08:48 -04:00
Andrew Kelley 93384f7428 use singly linked lists for std.zig.parse
std.ast uses a singly linked list for lists of things. This is a
breaking change to the self-hosted parser API.

std.ast.Tree has been separated into a private "Parser" type which
represents in-progress parsing, and std.ast.Tree which has only
"output" data. This means cleaner, but breaking, API for parse results.
Specifically, `tokens` and `errors` are no longer SegmentedList but a
slice.

The way to iterate over AST nodes has necessarily changed since lists of
nodes are now singly linked lists rather than SegmentedList.

From these changes, I observe the following on the
self-hosted-parser benchmark from ziglang/gotta-go-fast:

throughput: 45.6 MiB/s => 55.6 MiB/s
maxrss: 359 KB => 342 KB

This commit breaks the build; more updates are necessary to fix API
usage of the self-hosted parser.
2020-05-19 21:22:52 -04:00
Andrew Kelley 1cde0edff4 json: properly stringify error sets
I did this wrong originally in
feade9ef00
2020-05-18 19:23:40 -04:00
Jakub Konka cd8daa533a Undo accidentally checked-in changes to fs/test.zig 2020-05-18 22:22:27 +02:00
Jakub Konka 57719006bb Always return false for ANSI escape codes compat in WASI 2020-05-18 21:17:49 +02:00
Jakub Konka 3d267bab71 Re-enable refAllDecls gen and check in std.zig 2020-05-18 21:05:29 +02:00
Jakub Konka 2a59ecd7ec Integrate getTestDir with tmpDir logic 2020-05-18 17:10:49 +02:00
Jakub Konka f26ab568aa Remove obsolete runtime panics from sleep impl 2020-05-18 17:10:17 +02:00
Jakub Konka 5186711a96 Change to Self from *const Self/*Self where possible 2020-05-18 17:10:06 +02: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
Andrew Kelley feade9ef00 std.json: support stringify for anyerror 2020-05-17 17:07:27 -04:00
Veikka Tuominen 2a5c0ef7f0
Merge pull request #5164 from daurnimator/in_stream-helpers
A couple of helpers for streams that I've found helpful
2020-05-17 22:02:10 +03:00
Andrew Kelley 16f100b82e
Merge pull request #5307 from ziglang/self-hosted-incremental-compilation
rework self-hosted compiler for incremental builds
2020-05-17 13:53:27 -04:00
Vexu 28d449b38d
fix zig fmt regression 2020-05-17 15:13:19 +03:00
Vincent Rischmann e5ffb94911 linux: remove duplicated fields 2020-05-17 02:42:59 -04:00
Andrew Kelley f2ceb023f4
Merge pull request #5217 from wozeparrot/master
build.zig recursive dep support
2020-05-16 14:24:51 -04:00
Vexu eda03354dc
Merge pull request #5358 from Vexu/parser
Fix infinite loop with invalid comptime
2020-05-16 20:49:37 +03:00
Andrew Kelley cf34480f2a
Merge pull request #5231 from kubkon/wasi-preopens
Add mechanism for extracting preopens from the runtime
2020-05-16 12:49:08 -04:00
Felix (xq) Queißner 7dc29fdee1 Creates `std.ascii.control_code` that contains the C0 control codes as named constants. 2020-05-16 12:46:44 -04:00
data-man 6647c3f054 Fixes fmt padding for some types 2020-05-16 12:45:43 -04:00
Michael Dusan e05923f34b macos: use realpath$DARWIN_EXTSN
macOS 10.15 Catalina causes an ancient variant of `realpath` to fail,
likely due to 10.15's evolving security model.

closes #5325
2020-05-16 12:41:53 -04:00
Andrew Kelley 79462bb591
Merge pull request #5354 from DrDeano/master
Add enum to addBuildOption
2020-05-16 12:40:06 -04:00
Vexu 081ffe24cf
fix infinite loop with invalid comptime 2020-05-16 19:23:59 +03:00
Vexu 74f7d710bb
Merge pull request #5032 from LakeByTheWoods/redo_translate_c
Translate C: Redo Add comment containing c source location for failed decls.
2020-05-16 17:37:19 +03:00
DrDeano 72b72faa0b
Add Enum Option 2020-05-16 15:36:18 +01:00
DrDeano b2cb8beed9
Add enum to addBuildOptions 2020-05-16 15:35:42 +01:00
Vexu d061e5854a
Merge pull request #5020 from jinroh/docs/search-perf
docs: search perf
2020-05-16 16:43:41 +03:00
Vexu 758de71d97
Merge pull request #5353 from Vexu/parser
Self-hosted parser fixes
2020-05-16 15:56:03 +03:00
Vexu 092f726eec
Merge pull request #5175 from daurnimator/multi-out-stream
std: add io.MultiOutStream
2020-05-16 13:43:50 +03:00
Vexu e2a0f5741d
Merge pull request #5189 from zigazeljko/patch-1
Split AES struct into AESEncrypt and AESDecrypt
2020-05-16 13:20:14 +03:00
Vexu a05011d403
move ParamType to Node.ParamDecl 2020-05-16 12:54:51 +03:00
Vexu ed62081d38
recover from missing semicolon after if stmt 2020-05-16 12:29:01 +03:00
Vexu 6ca0def499
recover from invalid global error set access 2020-05-16 12:09:34 +03:00
Andrew Kelley 69a5f0d797 Merge remote-tracking branch 'origin/master' into self-hosted-incremental-compilation 2020-05-16 01:26:18 -04:00
Vexu b2f16d4484
fix infinite loop with mismatced bracket 2020-05-15 23:50:47 +03:00
Vexu a00fd6e254
properly handle extra closing braces at top level 2020-05-15 14:30:49 +03:00
Vexu f8b99331a2
Merge pull request #5336 from Vexu/parser
Make self-hosted parser more error tolerant
2020-05-15 14:15:30 +03:00
Vexu 440189a04a
cleanup* remove unecessary error* properly handle ReturnTypeInvalid in ast.zig functions* assert that the tree is clean in render.zig* simplify parser recovery with top level decls 2020-05-15 11:35:37 +03:00
Andrew Kelley 81a01bd481 fix codegen of sentinel-terminated arrays and .got alignment
we now have an exit(0) program working
2020-05-14 16:34:04 -04:00
Andrew Kelley 0986dcf1cf self-hosted: fix codegen and resolve some analysis bugs 2020-05-14 13:20:27 -04:00
Vexu c77fee0344
fix infinite loop
findToken wasn't as generic as I thought it was
2020-05-14 19:56:55 +03:00
Vexu c4552ee8ed
store rparen in ReturnType.Invalid
This is useful for getting a partial function signature
2020-05-14 17:18:14 +03:00
Vexu a32e240540
improve recovery from invalid container members
Instead of trying to find the end of the block or the next comma/semicolon
we no try to find the next token that can start a container member.
2020-05-14 12:09:40 +03:00
Vexu 89f2923a8a
recover from missing semicolon 2020-05-14 11:19:50 +03:00
Vexu ac319b2734
remove useless nosuspend parsing
nosuspend cannot be used in a type expression and
all other use casesare covered by PrimaryExpr
2020-05-14 11:19:14 +03:00
Andrew Kelley 6a2425c38c self-hosted: fix the rest of the compile errors 2020-05-13 22:12:38 -04:00
Andrew Kelley 080022f6c6 self-hosted: fix compile errors, except for codegen.zig 2020-05-13 20:06:01 -04:00
Vexu c3b76d0913
recover from invalid builtin/async call 2020-05-14 00:16:56 +03:00
Vexu 1f81887a78
recover after invalid inline/extern 2020-05-13 23:35:58 +03:00
Vexu ad71d959d7
correctly recover from invalid top level declarations 2020-05-13 23:28:04 +03:00
Vexu 2296906e2a
modernize std.zig.tokenizer 2020-05-13 23:08:42 +03:00
Vexu 23c5ff94e9
improve recovery on top level declarations 2020-05-13 20:42:18 +03:00
Vexu 118db892be
Merge pull request #5321 from gpanders/ascii-case-sensitive
Add helper functions and docstrings to ascii.zig
2020-05-13 19:04:53 +03:00
Vexu 76681e6b96
Make PriorityQueue.Iterator public
The `iterator` function was already public but these seem to have been forgotten.
2020-05-13 18:38:03 +03:00
DrDeano 2589f7207b
Make StackIterator next public 2020-05-13 16:21:15 +01:00
Vexu cefc04348e
continue parsing on invalid and token 2020-05-13 17:36:06 +03:00
Vexu be392777b7
continue parsing after missing commas and invalid statements 2020-05-13 17:21:27 +03:00
Vexu 91358f3092
continue parsing on extra qualifier errors 2020-05-13 16:51:23 +03:00
Jason Merrill 706311cad9
Fix comment typo RFC8529 -> RFC8259
Ref: https://tools.ietf.org/html/rfc8259
2020-05-12 19:11:05 -07:00
Vexu df22c7dfef
std.zig attempt to continue parsing on error 2020-05-12 22:37:39 +03:00
Vexu fa57463bb9
make parser testError take a list of expected errors 2020-05-12 21:44:08 +03:00
Vexu 80d0c2f166
Merge pull request #5118 from xackus/fix-json-writestream
fix json.WriteStream.emitJson
2020-05-12 17:44:06 +03:00
Greg Anders c6420820b0 Remove redundant ASCII functions
The `matchCase` variants are simply duplicates of the `eql` and
`indexOf` functions found in std.mem.
2020-05-12 08:38:15 -06:00
Vexu 08e2e690d7
Merge pull request #5275 from strangebug/docs-markdown-links
Add support for external links and URL to markdown parser.
2020-05-12 15:35:50 +03:00
Vexu b1ebaba408
std.json properly handle comptime int/float 2020-05-12 15:15:21 +03:00
Andrew Kelley 619159cf48 self-hosted: rework the memory layout of ir.Module and related types
* add TypedValue.Managed which represents a Type, a Value, and some
   kind of memory management strategy.
 * introduce an analysis queue
 * flesh out how incremental compilation works with respect to exports
 * ir.text.Module is only capable of one error message during parsing
 * link.zig no longer has a decl table map and instead has structs that
   exist directly on ir.Module.Decl and ir.Module.Export
 * implement primitive .text block allocation
 * implement linker code for updating Decls and Exports
 * implement null Type

Some supporting std lib changes:
 * add std.ArrayList.appendSliceAssumeCapacity
 * add std.fs.File.copyRange and copyRangeAll
 * fix std.HashMap having modification safety on in ReleaseSmall builds
 * add std.HashMap.putAssumeCapacityNoClobber
2020-05-12 01:02:48 -04:00
Greg Anders 9f496c0777 Add helper functions and docstrings to ascii.zig
* Add an upper case variant of `allocLowerString`
  * Add case-sensitive variants of `eqlIgnoreCase`, `indexOfIgnoreCase`,
    and `indexOfIgnoreCasePos`
  * Add and update docstrings on functions
2020-05-11 19:36:41 -06:00
Jonathan Marler 832f6c1228 make Address.getOsSockLen pub 2020-05-11 09:11:05 -06:00
Andrew Kelley a32d3a85d2 rework self-hosted compiler for incremental builds
* introduce std.ArrayListUnmanaged for when you have the allocator
   stored elsewhere
 * move std.heap.ArenaAllocator implementation to its own file. extract
   the main state into std.heap.ArenaAllocator.State, which can be
   stored as an alternative to storing the entire ArenaAllocator, saving
   24 bytes per ArenaAllocator on 64 bit targets.
 * std.LinkedList.Node pointer field now defaults to being null
   initialized.
 * Rework self-hosted compiler Package API
 * Delete almost all the bitrotted self-hosted compiler code. The only bit
   rotted code left is in main.zig and compilation.zig
 * Add call instruction to ZIR
 * self-hosted compiler ir API and link API are reworked to support
   a long-running compiler that incrementally updates declarations
 * Introduce the concept of scopes to ZIR semantic analysis
 * ZIR text format supports referencing named decls that are declared
   later in the file
 * Figure out how memory management works for the long-running compiler
   and incremental compilation. The main roots are top level
   declarations. There is a table of decls. The key is a cryptographic
   hash of the fully qualified decl name. Each decl has an arena
   allocator where all of the memory related to that decl is stored.
   Each code block has its own arena allocator for the lifetime of
   the block. Values that want to survive when going out of scope in
   a block must get copied into the outer block. Finally, values must
   get copied into the Decl arena to be long-lived.
 * Delete the unused MemoryCell struct. Instead, comptime pointers are
   based on references to Decl structs.
 * Figure out how caching works. Each Decl will store a set of other
   Decls which must be recompiled when it changes.

This branch is still work-in-progress; this commit breaks the build.
2020-05-10 02:05:54 -04:00
Haze Booth e79d7e0ded Remove fs.File artifact from connectUnixSocket 2020-05-09 12:29:27 -04:00
Vexu d4d509090b
make std.build.getInstallPath public
Closes  #5299
2020-05-09 00:31:11 +03:00
Vexu 453df1cc1e
Merge pull request #4892 from Sobeston/patch-4
mem.zeroes - add sentinel terminated array support
2020-05-08 22:37:27 +03:00
Vexu 336ddb5b76
std: add test for mem.zeroes on sentinel terminated arrays 2020-05-08 19:03:27 +03:00
Vexu f2d3266075
Merge pull request #4932 from Qix-/fix-private-access
Fix private access
2020-05-08 18:21:15 +03:00
daurnimator 45f7c78bfc
std: fix RTLD_ constants on OSX 2020-05-08 22:34:18 +10:00
Vexu 10abffcd98
fix more private member access 2020-05-08 15:10:38 +03:00
Josh Junon b6dc7fc9ff
publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
Loris Cro 35a59b5b0f remove readable check when opening a socket connection 2020-05-07 13:41:17 -04:00
Loris Cro 7e8b859095 fix oneshot flag erroneusly set as filter_flag 2020-05-07 13:41:17 -04:00
Loris Cro a78ac96134 fix crash in single-threaded builds 2020-05-07 13:41:02 -04:00
Andrew Kelley ba43492c0e
Merge pull request #5268 from tadeokondrak/remove-callconv-redundant-syntax
Remove syntax redundant with callconv
2020-05-07 12:42:26 -04:00
Jens Goldberg 20c1696865 Removed GetModuleHandleA from user32
GetModuleHandleA is an kernel32 function and already defined there, it doesn't belong in user32.
2020-05-07 12:38:46 -04:00
Jens Goldberg 25810bc1e6 Removed duplicate WM_ACTIVATE 2020-05-07 12:38:46 -04:00
Jonathan Marler 0a76e11617 add failAllocator to enable some regression tests 2020-05-06 23:56:48 -06:00
Jonathan Marler 0c7397b49f fix copy/paste error in AllocWithOptionaPayload 2020-05-06 23:08:08 -06:00
Timon Kruiper b336dda076 Standard library: Fix a regression in loop.waitUntilFdWritableOrReadable
This broke async io on linux.
Regressed in 8ebcca6734
2020-05-06 13:14:06 -04:00
data-man 3c4abacba6 Optimization of vectors hashing 2020-05-06 17:08:49 +05:00
Vexu 0e30edd8d0
std: handle ConnectionTimedOut in switch
regression from #5266
closes #5270
2020-05-06 12:52:26 +03:00
Andrew Kelley 6f3d76f61e simplify test-evented-io build setting 2020-05-05 15:18:04 -04:00
Haze Booth a39cb034ea Add setUseTestEventedIO for test steps in build.zig 2020-05-05 15:16:54 -04:00
Andrew Kelley b13a02ed1a avoid unnecessary fcntl syscalls when setting socket flags 2020-05-05 12:50:50 -04:00
Andrew Kelley 0a2104689b fix incorrect flags being set in os.setSockFlags
fixes networking stuff on darwin
2020-05-05 12:45:39 -04:00
Tadeo Kondrak 84a0a9688c
update docs/tests for async/extern fn removal 2020-05-05 10:31:32 -06:00
StrangeBug 54088fe6e1 Add support for external links and URL to markdown parser. 2020-05-05 18:09:32 +02:00
Tadeo Kondrak 6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Tadeo Kondrak d0e996405b
add zig fmt fix for async/extern fn 2020-05-05 09:37:59 -06:00
Tadeo Kondrak 7ada59f873
remove nakedcc/stdcallcc/async fn/extern fn fnproto 2020-05-05 09:37:28 -06:00
Jakub Konka 81d824bf80 Clear PreopenList on every populate call 2020-05-05 17:23:49 +02:00
Andrew Kelley e6955688ac
Merge pull request #5272 from tadeokondrak/noasync-to-nosuspend
Noasync to nosuspend
2020-05-05 11:21:02 -04:00
Jakub Konka 07a968b344 Add docs 2020-05-05 17:05:30 +02:00
Jakub Konka 558bb24601 Move preopen and path wasi helpers to std.fs.wasi module
Previously, the path and preopens helpers were prototyped in `std.os.wasi`
module, but since they are higher-level abstraction over wasi, they belong in
`std.fs.wasi` module.
2020-05-05 15:08:52 +02:00
Jakub Konka d4c33129cf Shuffle things around; add PreopenList.findByPath method
This commit removes `std.os.openatWasi` function, and renames it to
`std.os.wasi.openat`. Additionally, the added `PreopenList.findByPath`
method allows querying the list for a matching preopen by path.
2020-05-05 15:08:52 +02:00
Jakub Konka dd238352a4 Encapsulate getPreopens inside PreopenList 2020-05-05 15:08:52 +02:00
Jakub Konka fc77e393fd Remove obsolete PATH_MAX const 2020-05-05 15:08:52 +02:00
Jakub Konka b8112b3d17 Simplify File constructors 2020-05-05 15:08:52 +02:00
Jakub Konka 8bce1b6981 Refactor resolve_preopen into getPreopens function
This commit refactors `std.os.wasi.resolve_preopen` into a (higher-level)
`std.os.wasi.getPreopens` funtion which returns a slice with _all_
preopens at any given time. This fn allows the WASI module to
inquire at any given time for all preopens provided by the runtime.

This commit also makes `cwd()` a compile error on WASI.
2020-05-05 15:08:52 +02:00
Jakub Konka 05fb3e79fe Make std.fs.cwd() return preopen for "." if exists
This commit adds WASI specific impl of `std.fs.cwd()` in which we
emulate the `cwd` behaviour by inquiring the runtime for a "."
preopen if available. This is OK for simple relative ops, but will
not work for any ops which require absolute paths.
2020-05-05 15:08:52 +02:00
Jakub Konka 8e1cd69717 Implement std.fs.Dir.openFileWasi
It seems that `std.os.openZ` is too POSIX-specific, so I think it
should not be a point of entry for WASI `open` call. I figure
WASI should be treated as a separate "os" that's _not_ POSIX
especially given the incoming changes in the ephemeral snapshot.
2020-05-05 15:08:52 +02:00
Jakub Konka d7ca220121 Start drafting out openZ 2020-05-05 15:08:52 +02:00
Tadeo Kondrak fdfdac4939
update comments for nosuspend 2020-05-05 05:55:27 -06:00
Tadeo Kondrak af00afed98
zig fmt 2020-05-05 05:55:25 -06:00
Tadeo Kondrak 8d5636ebe4
Rename noasync to nosuspend in self-hosted, add rewriter 2020-05-05 05:17:33 -06:00
Haze Booth 4cb4097b08
Update ErrorUnion thread spawn result to return null instead of 0 2020-05-05 04:15:43 -04:00
Vexu f127dee474
Merge pull request #5267 from Vexu/const-call
Fix missing compile error on call assigned to const
2020-05-04 21:45:15 +03:00
Jonathan Marler 75b699b2c6 os.zig: add ETIMEDOUT error case to read function
According to documentation ETIMEDOUT (110) is a valid error code for the read function.  I just had my long-running  (been running for about 7 weeks) network program crash because it did not handle the ETIMEDOUT error code from "read".
2020-05-04 13:48:34 -04:00
Vexu 85fd484f07
std: fix blake3 assignment to constant 2020-05-04 14:45:36 +03:00
Cato 9b788b765c Pass filtered_sock_type to system.socket. Cover PermissionDenied error 2020-05-03 15:35:36 -04:00
daurnimator 277d088558
std: use async for MultiOutStream 2020-05-03 18:33:04 +10: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 07bee9da42 Fixed Darwin-incompatible socket flags and unavailable system calls 2020-05-02 16:37:39 -04:00
Andrew Kelley 03a7124543
Merge pull request #5249 from ziglang/FireFox317-windows-evented-io
fix behavior test with --test-evented-io on windows
2020-05-02 16:29:58 -04:00
Andrew Kelley b7914d901c add test coverage for top level fields
closes #2022
2020-05-02 14:53:20 -04:00
Andrew Kelley 7998e2b0f4 Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-io 2020-05-02 14:16:59 -04: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
Andrew Kelley 5656f5090d fs.File: improve handling async I/O on Windows
Before it was possible for .intended_io_mode = .blocking,
.capable_io_mode = .evented, and then the implementation would put a
request on the fs thread, which is the wrong behavior. Now it always
calls the appropriate WriteFile/ReadFile function, passing the intended
io mode directly as a parameter.

This makes the behavior tests pass on Windows with --test-evented-io.
2020-05-02 14:09:17 -04:00
Andrew Kelley 9dac8a5be9 update windows impl of child process to new File API 2020-05-02 04:31:26 -04:00
nycex 77376a54bf
correct usages of std.fs.dir.DeleteFileError (#5058)
* correct usages of std.fs.dir.DeleteFileError

* test std.fs.createFileAbsolute() and std.fs.deleteFileAbsolute()
2020-05-02 04:19:07 -04:00
Andrew Kelley 428065da30
Merge pull request #5243 from niacat/kern-arand
Avoid reading from /dev/urandom on NetBSD
2020-05-02 04:16:24 -04:00
Andrew Kelley 6546c74825 child process: no need to remove O_CLOEXEC before execve 2020-05-02 03:38:05 -04:00
Andrew Kelley beebcbb677 Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-io 2020-05-02 01:53:24 -04:00
Andrew Kelley 43f7856bac fix regressions in windows std lib tests 2020-05-02 01:25:22 -04:00
Andrew Kelley 2272a07ca0 std.event.Loop: promote the fs thread to be available for all OS's 2020-05-02 00:41:19 -04:00
Andrew Kelley 45bce27b8f cleanup and fixes. behavior tests passing with evented I/O 2020-05-01 23:17:28 -04:00
Andrew Kelley 988031c07c Merge branch 'windows-evented-io' of https://github.com/FireFox317/zig into FireFox317-windows-evented-io 2020-05-01 19:02:16 -04:00
Andrew Kelley 3386bb896d
Merge pull request #5192 from ziglang/stage2-tests
add ZIR compare output test case to test suite
2020-05-01 17:35:52 -04:00
Andrew Kelley 94b0d0e802 std.progress: handle error from FillConsoleOutputAttribute
I observed this returning an error. Fall back to not doing
terminal stuff if an error occurs here.

See #5244
2020-05-01 15:14:44 -04:00
Cato Auestad 5418efa1e5 Added socket bits for Darwin 2020-05-01 14:28:33 -04:00
Andrew Kelley ec6ef86219 fix off-by-one error in sizeInBaseUpperBound 2020-05-01 13:33:46 -04:00
nia 14a954f350 Add arc4random_buf() in NetBSD libc, use it to implement getrandom() 2020-05-01 17:22:27 +01:00
Andrew Kelley 4044a77621 update std.meta.IntType => std.meta.Int 2020-05-01 06:49:30 -04:00
Andrew Kelley 8766821157 rework std.math.big.Int
Now there are 3 types:
 * std.math.big.int.Const
   - the memory is immutable, only stores limbs and is_positive
   - all methods operating on constant data go here
 * std.math.big.int.Mutable
   - the memory is mutable, stores capacity in addition to limbs and
     is_positive
   - methods here have some Mutable parameters and some Const
     parameters. These methods expect callers to pre-calculate the
     amount of resources required, and asserts that the resources are
     available.
 * std.math.big.int.Managed
   - the memory is mutable and additionally stores an allocator.
   - methods here perform the resource calculations for the programmer.
   - this is the high level abstraction from before

Each of these 3 types can be converted to the other ones.

You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.

This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
2020-05-01 06:47:56 -04:00
Andrew Kelley f89dbe6c4e link: introduce the concept of output mode and link mode 2020-05-01 06:47:20 -04:00
Andrew Kelley 28729efe29 ZIR: implement return instruction 2020-05-01 06:47:20 -04:00
Andrew Kelley 6b0f7de247 ZIR: add cmp and condbr instructions 2020-05-01 06:47:20 -04:00
Andrew Kelley 2bae942800 add ZIR compare output test case to test suite 2020-05-01 06:47:20 -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
wozeparrot 9d79f39844 switch anyerror to OutOfMemory 2020-04-30 12:14:17 -04:00
Vexu 7192ca14b7
Merge pull request #5216 from alexnask/windows_ansi_codes
Progress will now use ANSI escape codes on windows for terminals that support them
2020-04-30 18:35:55 +03:00
Vexu e72f45475d
Merge pull request #4683 from LakeByTheWoods/parser_test
Add visible newlines to parser_test output when there's a failure.
2020-04-30 12:04:23 +03:00
Vexu 611bd8e9f4
Merge pull request #5213 from tadeokondrak/evented-readv-fix
Fix std.event.Loop.readv
2020-04-30 11:00:27 +03:00
Vexu 87c9696121
move printWithVisibleNewlines to testing.expectEqualStrings 2020-04-30 10:34:18 +03:00
Vexu 2d06e731ec
rename diffIndex to indexOfDiff 2020-04-30 10:33:50 +03:00
Jakub Konka 611a1436f0 Update WASI snapshot to preview1
This commit updates the WASI imports to use `wasi_snapshot_preview1`
instead of the old `wasi_unstable`. There are some minor ABI
differences between the two, however, the main motivator for using
the latest "stable" snapshot (aka preview1) is that, at least in
Wasmtime, there has been a lot of improvement work put into preview1
and unfortunately I might add, the improvements were not (in full)
backported to `wasi_unstable` snapshot.

Also, this commit removes the optional bound on the pointer to
`environ_get` syscall.
2020-04-30 01:52:12 -04:00