2543 Commits

Author SHA1 Message Date
LemonBoy
bd9003ed5b std: ArenaAllocator tries to resize before allocating
Closes #5116
2020-09-25 10:58:07 +02:00
Felix (xq) Queißner
7f68b14377 Implements std.meta.Tuple(), implements #4607 in userland. 2020-09-25 09:27:00 +02:00
Felix (xq) Queißner
93291cc472 Implements std.meta.ArgsTuple. 2020-09-25 09:16:43 +02:00
Andrew Kelley
495d18a205 std.log: better default for printing logs
* prefix with the message level
 * if the scope is not default, also prefix with the scope

This makes the stack trace test pass, with no changes to the
test case, because errors returned from main() now print
`error: Foo` just like they do in master branch.
2020-09-25 00:02:52 -07:00
Andrew Kelley
30dfdfdbd0 fix a round of regressions in this branch
* Don't try to generate C header files yet since it will only cause a
   crash saying the feature is unimplemented.
 * Rename the CLI options for release modes to use the `-O` prefix to
   match C compiler precedent. Options are now `-ODebug`,
   `-OReleaseFast`, `-OReleaseSafe`, `-OReleaseSmall`. The optimization
   mode matches the enum tags of std.builtin.Mode. It is planned to, at
   some point, rename std.builtin.Mode to std.builtin.OptimizationMode
   and modify the tags to be lower case to match the style convention.
   - Update build.zig code to support this new CLI.
 * update std.zig.binNameAlloc to support an optional Version and update
   the implementation to correctly deal with dynamic library version
   suffixes.
2020-09-24 23:50:15 -07:00
Andrew Kelley
f8b3543cab I think this test is still flakey
re-opens #4922
2020-09-24 22:57:03 -07:00
Josh Wolfe
1a8669eada build.zig: addBuildOptionArtifact 2020-09-25 01:53:38 -04:00
Andrew Kelley
7964341c76 zig build: update to use new --version flag instead of legacy flags 2020-09-24 22:18:53 -07:00
Loris Cro
c196c27af8 recvfrom
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
419aea54cb sendto
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
7fec5b3def pwritev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
7a07c62a07 pwrite
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:21 +02:00
Loris Cro
18f6629bd8 writev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:03 +02:00
Loris Cro
9075f8e5a1 write
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:05:41 +02:00
Loris Cro
59ecdaea12 preadv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:43 +02:00
Loris Cro
bd9f2369d5 pread
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:05 +02:00
Loris Cro
bc35435ca6 readv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:03:12 +02:00
Loris Cro
08364ac773 read
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:00:55 +02:00
Loris Cro
730428bfd6 connect
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 21:56:27 +02:00
Loris Cro
e85c89630e accept
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 21:56:27 +02:00
Frank Denis
bd89bd6fdb Revamp crypto/aes
* Reorganize crypto/aes in order to separate parameters, implementations and
modes.
* Add a zero-cost abstraction over the internal representation of a block,
so that blocks can be kept in vector registers in optimized implementations.
* Add architecture-independent aesenc/aesdec/aesenclast/aesdeclast operations,
so that any AES-based primitive can be implemented, including these that don't
use the original key schedule (AES-PRF, AEGIS, MeowHash...)
* Add support for parallelization/wide blocks to take advantage of hardware
implementations.
* Align T-tables to cache lines in the software implementations to slightly
reduce side channels.
* Add an optimized implementation for modern Intel CPUs with AES-NI.
* Add new tests (AES256 key expansion).
* Reimplement the counter mode to work with any block cipher, any endianness
and to take advantage of wide blocks.
* Add benchmarks for AES.
2020-09-24 13:16:00 -04:00
Frank Denis
c8cd6145ac Move PBKDF2 to a pwhash category, clarify what that category is
Password hashing functions are not general-purpose KDFs, and KDFs
don't have to satisfy the same properties as a PHF.

This will allow fast KDFs such as the HKDF construction to be in a
category of their own, while clarifying what functions are suitable
for using passwords as inputs.
2020-09-24 00:02:31 -04:00
Andrew Kelley
7bbd152dcc nobody likes my std.process.cleanExit idea
it's appropriate for the self-hosted compiler though, so this commit
moves it from std lib to stage2 src code.
2020-09-23 20:52:33 -07:00
Andrew Kelley
b08fd0e8fc stage2: building musl libc from source 2020-09-23 20:48:47 -07:00
Andrew Kelley
f4dde4d109 test_runner: fix missing newline in log 2020-09-23 11:15:10 -07:00
Andrew Kelley
c0b774fbc6 stage2: support passing extra C flags to C source files
closes #3508
2020-09-23 10:22:44 -07:00
Timon Kruiper
bbff6bd675 Eventloop: Enable basic event loop test, fixed by previous commit
Closes #4922
2020-09-23 18:38:28 +02:00
Timon Kruiper
0eed7ec9d5 Eventloop: Fix deadlock in linux event loop implementation
A simple empty main with evented-io would not quit, because some
threads were still waiting to be resumed (by the os). The os.write to
the eventfd only wakes up one thread and thus there are multiple writes
needed to wake up all the other threads.
2020-09-23 11:41:31 +02:00
Andrew Kelley
800a4a6ceb eliminate dependency of libzigcpp.a on libzigstage1.a
This allows us to create a build of self-hosted with LLVM extensions
enabled but without the stage1 backend.
2020-09-23 00:00:24 -07:00
Andrew Kelley
0638a020cf stage2: implement --pkg-begin and --pkg-end CLI args 2020-09-22 23:00:33 -07:00
Andrew Kelley
c2b1cd7c45 stage2: implement zig build
As part of this:

 * add std.process.cleanExit. closes #6395
   - use it in several places
 * adjust the alignment of text in `zig build --help` menu
 * Cache: support the concept of "unhit" so that we properly keep track
   of the cache when we find out using the secondary hash that the cache
   "hit" was actually a miss. Use this to fix false negatives of caching
   of stage1 build artifacts.
 * fix not deleting the symlink hash for stage1 build artifacts causing
   false positives.
 * implement support for Package arguments in stage1 build artifacts
 * update and add missing usage text
 * add --override-lib-dir and --enable-cache CLI options
   - `--enable-cache` takes the place of `--cache on`
 * CLI supports -femit-bin=foo combined with --enable-cache to do an
   "update file" operation. --enable-cache without that argument
   will build the output into a cache directory and then print the path
   to stdout (matching master branch behavior).
 * errors surfacing from main() now print "error: Foo" instead of
   "error: error.Foo".
2020-09-22 22:18:19 -07:00
Andrew Kelley
250664bea4 build runner: allow for a bit longer -D options
so they can display in the --help menu without getting squished.
2020-09-22 14:56:52 -07:00
Andrew Kelley
0c70bb4fce Merge remote-tracking branch 'origin/master' into stage2-zig-cc 2020-09-21 21:16:46 -07:00
LemonBoy
58ee5f4e61 std: Fix metadata corruption in HeapAllocator
HeapAllocator stores the pointer returned by HeapAlloc right after the
data block and, after the recent allocator refactoring, the space for
this pointer was not taken into account in the calculation of the final
block size.

Fixes #5830
2020-09-20 01:21:29 -04:00
zenith391
4fbf9f7f79 Add "emit_docs" field to LibExeObjStep. 2020-09-19 00:39:43 +03:00
Lachlan Easton
4496a6c9cc zig fmt: Special case un-indent comma after multiline string in param list 2020-09-18 20:34:00 +10:00
Lachlan Easton
1aacedf6e1 zig fmt: Fix regression in ArrayInitializers 2020-09-18 20:34:00 +10:00
Lachlan Easton
40b6e86a99 zig fmt: fix #6171 2020-09-18 20:34:00 +10:00
Lachlan Easton
c06674e701 zig fmt: Small cleanup 2020-09-18 20:34:00 +10:00
Lachlan Easton
206a8cf670 zig fmt: fix comments and multiline literals in function args 2020-09-18 20:34:00 +10:00
Lachlan Easton
291482a031 zig fmt: Don't consider width of expressions containing multiline string literals when calculating padding for array initializers. fixes #3739
Changes some of the special casing for multiline string literals.
2020-09-18 20:34:00 +10:00
Lachlan Easton
e1bd271192 zig fmt: Allow trailing comments to do manual array formatting. close #5948 2020-09-18 20:34:00 +10:00
Lachlan Easton
9f0821e688 zig fmt: Fix erroneously commented out code, add passing test case to close #5722 2020-09-18 20:34:00 +10:00
Lachlan Easton
ea6181aaf6 zig fmt: Add test for nesting if expressions 2020-09-18 20:34:00 +10:00
Andrew Kelley
333b12a8f9 std: start: use std.log instead of stderr
When main returns an error code.
2020-09-18 01:58:16 -07:00
Ryan Liptak
fbde15fdf4 Fix compile error in os.renameatW
Introduced in 5e3fa0e94f947c632aa584b9e13bfa2fe241fae1

Whoops!
2020-09-17 18:49:06 -04:00
Andrew Kelley
f125288c9b
Merge pull request #6336 from Rocknest/pbkdf2
Some changes to #6326 (pbkdf2)
2020-09-17 17:31:58 -04:00
Ryan Liptak
5e3fa0e94f Add rename to std.fs API
- Moves fs.rename functions to fs.renameAbsolute to match other functions outside of fs.Dir
- Adds fs.Dir.rename that takes two paths relative to the given Dir
- Adds fs.rename that takes two separate Dir's that the given paths are relative to (for renaming across directories without having to make the second path relative to a single directory)
- Fixes FileNotFound error return in std.os.windows.MoveFileExW
- Returns error.RenameAcrossMountPoints from renameatW
  + Matches the RenameAcrossMountPoints error return in renameatWasi/renameatZ
2020-09-17 17:22:26 -04:00
LemonBoy
27adb82fda std: Respect user-specified alignment when formatting ints
This implementation tries to do the right thing (TM) by treating the
sign as part of the number itself, therefore the alignment parameter
applies to both the sign and the digits.

In other words the format string `{:>4}` with -1 as input will not
output `-  1` but `  -1`.

And let's default to right alignment for everything as that's what users
want, especially when printing numbers. Many implementations use
different defaults for numeric vs non-numeric types, let's strive for a
consistent behaviour here.
2020-09-17 00:53:08 +02:00
LemonBoy
bb9a4ad6e9 std: Fix {*} printing of non-pointer types
Fixes a regression introduced in #6246.
Adds a test to make sure this won't happen again.
2020-09-16 13:45:54 +02:00