2432 Commits

Author SHA1 Message Date
Tadeo Kondrak
e4b61aa527
std.meta.TrailerFlags fixes 2020-08-27 16:02:00 -06:00
Tadeo Kondrak
ce8a3ef2de
std.zig: Update to new std.meta.TrailerFlags API 2020-08-27 15:21:18 -06:00
Tadeo Kondrak
f94583076e
std.meta.TrailerFlags: use @Type to improve API
- Use an enum of all field names instead of string literals
- Create a struct type with all fields optional instead of relying on
anonymous struct literals

This should provide better type inference, compile errors, and a
(subjectively) cleaner API.
2020-08-27 15:11:33 -06:00
Asherah Connor
dc7608da97 ensure main return type is not i8
Avoids a compile error from start.zig:

	/home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: error:
	expected type 'u8', found 'i8'
			    return result;
				   ^
	/home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: note:
	unsigned 8-bit int cannot represent all possible signed 8-bit
	values
			    return result;
2020-08-27 15:03:56 +03:00
Cléo Rebert
fc001110b4 Added edge case test to mem.count
Some implementations break on this edge case. Thought relevant to add it.
2020-08-27 04:12:28 -04:00
Sobeston
7d0bb0774e std.mem.count 2020-08-26 17:37:05 -04:00
Frank Denis
ad18078d53 forceEval() -> doNotOptimizeAway() 2020-08-26 10:50:34 +02:00
Frank Denis
0bd53dd203 Rename blackBox, move it to std.mem.forceEval() 2020-08-26 10:50:34 +02:00
Frank Denis
ff2e82f382 Rename at to tag in AEADs 2020-08-26 10:50:34 +02:00
Frank Denis
b8729ca1a0 Improve crypto benchmarks
- 1MiB objects on the stack doesn't play well with wasmtime.
Reduce these to 512KiB so that the webassembly benchmarks can run.
- Pass expected results to a blackBox() function. Without this, in
release-fast mode, the compiler could detected unused return values,
and would produce results that didn't make sense for siphash.
- Add AEAD constructions to the benchmarks.
- Inline chacha20Core() makes it 4 times faster.
- benchmarkSignatures() -> benchmarkSignature() for consistency.
2020-08-26 10:50:34 +02:00
Jakub Konka
982ab7df6c
Merge pull request #6161 from kubkon/macho-text
Add (empty) __TEXT segment load command
2020-08-26 07:03:58 +02:00
Andrew Kelley
3e24e95892 std.rand: promote normal comments to doc comments 2020-08-25 19:51:40 -07:00
Andrew Kelley
b498eebfd4 std.math.big: fix use-after-free
When there is parameter aliasing, the ensureCapacity calls can cause the
Const parameters to become dangling pointers.

See #6167
2020-08-25 19:49:40 -07:00
Andrew Kelley
973e6c978c std: clean up GeneralPurposeAllocator memset code
The freeSlot function was only called once so I inlined the logic and
utilized some of the other locals that were in scope.
2020-08-25 19:48:39 -07:00
Andrew Kelley
6fb105fdd7 std: GeneralPurposeAllocator: set freed bytes to undefined
Helps catch use-after-free. Caught a couple issues in the self-hosted
compiler.
2020-08-25 13:36:40 -07:00
Rocknest
140c599559
Fix & update windows version stuff (#6157)
* Update windows version constants
* Add docs
2020-08-24 16:47:44 -04:00
Jakub Konka
43b6d0e4b1
Add (empty) __TEXT segment load command
Also, link against `libSystem` by default when targeting macOS.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 21:18:27 +02:00
Jakub Konka
9745e7b512 Clean up draft for merging into upstream
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Jakub Konka
1698e6d7a7 Link against libSystem when generating Mach-O exe
This is required when generating an exe on macOS.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Jakub Konka
2516db9645 Specify path to dyld in Mach-O
This is required since an exec on macOS always has to link against
libSystem.dylib.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Andrew Kelley
4d7013f7d3
Merge pull request #6146 from daurnimator/no_ctty
Use O_NOCTTY open flag
2020-08-23 23:26:58 -04:00
LiterallyVoid
4bbea3422a Fix unused argument error when formatting std.Target 2020-08-23 22:47:57 -04:00
Luna
7015d84e0c remove licensing comments from init-exe/init-lib 2020-08-23 22:45:18 -04:00
daurnimator
129d3e274d
std: use O_NOCTTY flag 2020-08-24 02:28:31 +10:00
daurnimator
23a81b4396
std: refactor fs.openFileZ flag handling 2020-08-24 02:27:26 +10:00
Andrew Kelley
54f3b0a560 stage2: clean up SPU Mk II code
* move SPU code from std to self hosted compiler
 * change std lib comments to be descriptive rather than prescriptive
 * avoid usingnamespace
 * fix case style of error codes
 * remove duplication of producer_string
 * generalize handling of less than 64 bit arch pointers
 * clean up SPU II related test harness code
2020-08-22 13:36:08 -07:00
Noam Preil
f448b518f8 SPU-II: use undefined1 as breakpoint 2020-08-22 12:45:29 -07:00
Noam Preil
f2796239ba SPU-II: Fix logging in interp, remove JIT-compat code 2020-08-22 12:45:29 -07:00
Noam Preil
f2fef240a1 SPU-II: Test harness skeleton 2020-08-22 12:45:29 -07:00
Noam Preil
f18636fa58 SPU-II: Add common definitions 2020-08-22 12:45:29 -07:00
Noam Preil
803a1025bb Targets: add SPU Mark II architecture 2020-08-22 12:45:29 -07:00
Frank Denis
2d402157d9 Improve documentation on siphash recommended parameters 2020-08-22 15:12:54 -04:00
Frank Denis
f540dc1b7e cache_hash: hash function change
This makes the `cache_hash` hash function easier to replace.

BLAKE3 would be a natural fit for hashing large files, but:
- second preimage resistance is not necessary for the cache_hash use cases
- our BLAKE3 implementation is currently very slow

Switch to SipHash128, which gives us an immediate speed boost.
2020-08-22 15:10:33 -04:00
Matthew Knight
0fa3cfdb4a
Bpf: move under os/linux instead of bits (#6126)
* moved bpf syscall, added some bpf instructions and tests

* had to move bpf out of bits so that a freestanding target could import it

* removed line

* fixed imports
2020-08-22 15:08:01 -04:00
Jakub Konka
69de1a51cd Add entry_point_command struct to Mach-O definitions
The `entry_point_command` is a replacement for `thread_command`, and
is used for main executables to specify the location of `main()`
entry point.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-22 04:14:27 -04:00
Tadeo Kondrak
a049c31f21 Remove TypeInfo.Error.value 2020-08-22 03:20:12 -04:00
Frank Denis
e919744c7a Promote hash/siphash to crypto/siphash
SipHash *is* a cryptographic function, with a 128-bit security level.

However, it is not a regular hash function: a secret key is required,
and knowledge of that key allows collisions to be quickly computed offline.

SipHash is therefore more suitable to be used as a MAC.

The same API as other MACs was implemented in addition to functions directly
returning an integer.

The benchmarks have been updated accordingly.

No changes to the SipHash implementation itself.
2020-08-22 02:47:50 -04:00
Isaac Freund
9ab4281856 std: remove init functions from linked list nodes
These functions are rather useless and redundant as initializing the
struct directly is just as easy:

var node = TailQueue(u32).Node{ .data = 42 };
2020-08-22 02:47:39 -04:00
Andrew Kelley
dad7af0b37
Merge pull request #6116 from jedisct1/polyfast
Make poly1305 faster
2020-08-21 16:52:33 -04:00
Isaac Freund
37ad9f38dc std: sync TailQueue with new SinglyLinkedList API
The API of SinglyLinkedList was changed in 93384f7, removing the init
function as well as the redundant allocation helper functions.

This commit makes parallel changes to the API of TailQueue in order to
keep the standard library consistent.
2020-08-21 15:59:50 -04:00
Matt Knight
80fabe1850 fixed bpf namespace 2020-08-21 11:40:35 -07:00
Matt Knight
bc1536f4bf decided to split up loading of 64-bit immediates 2020-08-21 11:40:35 -07:00
Matt Knight
7f1378909b moved bpf syscall, added some bpf instructions and tests 2020-08-21 11:40:35 -07:00
Frank Denis
0fe6677736 No need to keep a 128-bit carry around 2020-08-21 20:33:16 +02:00
Frank Denis
2fc2ebd920 Force myself to use unusual integer sizes a little bit more :) 2020-08-21 19:43:06 +02:00
Frank Denis
c9218f1719 Make poly1305 faster 2020-08-21 16:30:52 +02:00
Frank Denis
eef111fe78 Fix missing init() update in std/build/write_file.zig 2020-08-20 19:21:10 -04:00
Andrew Kelley
21106b9c9f
Merge pull request #6095 from jedisct1/crypto-reorg
Breaking: sort std/crypto functions into categories
2020-08-20 19:01:22 -04:00
Frank Denis
fc55cd458a Hash functions now accept an option set
- This avoids having multiple `init()` functions for every combination
of optional parameters
- The API is consistent across all hash functions
- New options can be added later without breaking existing applications.
  For example, this is going to come in handy if we implement parallelization
  for BLAKE2 and BLAKE3.
- We don't have a mix of snake_case and camelCase functions any more, at
least in the public crypto API

Support for BLAKE2 salt and personalization (more commonly called context)
parameters have been implemented by the way to illustrate this.
2020-08-21 00:51:14 +02:00
Andrew Kelley
9cfcd0c296
Merge pull request #6103 from Vexu/extern
Disallow extern variables with initializers.
2020-08-20 18:35:31 -04:00