Commit Graph

13492 Commits

Author SHA1 Message Date
LemonBoy
389d1177a5 stage1: Fix LLVM error in inline asm invocation
Pointer types need an extra indirection layer during the generation of
the function prototype for inline asm blocks.

Closes #3606
2021-05-04 18:43:31 +02:00
Frank Denis
97779442d0
Prepare std/crypto/pcurves for ecdsa and other curves (#8670)
Functions generated by Fiat-crypto are not prefixed by their description any more. This matches an upstream change.

We can now use a single type for different curves and implementations.

The field type is now generic, so we can properly handle the base field and scalars without code duplication.
2021-05-03 09:57:45 +02:00
Luna
c47028cd02 ci: freebsd: use py38-s3cmd 2021-05-02 17:24:17 -04:00
Andrew Kelley
4f9c928e56
Merge pull request #8665 from LemonBoy/misc
Miscellaneous patches
2021-05-01 18:07:58 -04:00
Andrew Kelley
d788181a3b
fix typo
Co-authored-by: Maciej Walczak <14938807+xackus@users.noreply.github.com>
2021-05-01 18:07:26 -04:00
LemonBoy
06b2fee05e std: Implement isFinite for f128 2021-05-01 16:28:13 +02:00
LemonBoy
236dba8ba9 std: Implement copysign for f128 2021-05-01 16:28:08 +02:00
LemonBoy
9f6edfd201 std: Implement signbit for f128 2021-05-01 16:28:03 +02:00
LemonBoy
718b43504e std: Fix pwrite/pread syscalls on SPARC targets 2021-05-01 15:46:28 +02:00
LemonBoy
69a9c1488d std: Add signal numbers for SPARC 2021-05-01 12:25:40 +02:00
LemonBoy
527053a4e4 std: Import correct errno defs for SPARC
Taken from Linux arch/sparc/include/uapi/asm/errno.h
2021-05-01 11:03:59 +02:00
LemonBoy
51f80deaf6 std: Fix stack overflow in SPARC clone() impl
Leave the minimum amount of stack space required by the ABI (16 * 8
bytes for the window contents plus 6 * 8 bytes for the input arguments)
on the new thread stack.
2021-05-01 11:02:04 +02:00
g-w1
e9e91b4ed0
std.build: if using a RunStep, show the command run on verbose (#8571) 2021-05-01 08:17:17 +02:00
Frank Denis
fe8781357a
std.crypto: add support for the NIST P-256 curve (#8627)
Uses verified code generated by fiat-crypto for field arithmetic, and complete formulas to avoid side channels.

There's still plenty of room for optimizations, especially with a fixed base. But this gives us a framework to easily add other similar curves.
2021-05-01 08:14:32 +02:00
Andrew Kelley
557eb414ee CLI: fix incorrect error message with -cflags 2021-04-30 21:55:28 -07:00
Devin Bayer
5fcc922ff2
add doc in Anonymous Struct Literal section for special @"0" syntax. (#8630) 2021-05-01 01:05:45 +02:00
Frank Denis
33cb660838
Doc: zig-cache/bin -> zig-out/bin (#8659) 2021-05-01 00:41:59 +02:00
Devin Bayer
d3f55782b0
rename doc refs to deprecated functions like openC (#8467) 2021-04-30 21:31:01 +02:00
LemonBoy
807bb7c03f std: Improve spinloop hint
* Add a yield pattern for PowerPC64
* Fix compile error on pre-v6 ARM targets
* Use isb instead of yield on AArch64 to give the CPU a chance to enter
  low-power states.
* Make the hint an inline function, the call overhead can be avoided.
2021-04-30 17:11:03 +02:00
Yorhel
f79b487337 Handle EPERM and ELOOP in os.fstatat() 2021-04-30 15:08:07 +02:00
Andrew Kelley
4e07755ce7
Merge pull request #8638 from ifreund/build-default-prefix
std/build: change default install prefix to zig-out
2021-04-30 00:10:44 -04:00
Isaac Freund
5079d11b21
std/build: change default install prefix to zig-out
Currently the default install prefix is $BUILD_ROOT/zig-cache,
but mixing cache and artifacts makes little sense. Instead make
$BUILD_ROOT/zig-out the default.
2021-04-29 23:58:45 +02:00
Matthew Borkowski
585479500e check for overflow when reading code lengths for a block with dynamic Huffman codes 2021-04-29 17:48:08 -04:00
Frank Denis
687ef42f98
x: comptime bool -> comptime x: bool (#8639) 2021-04-29 16:27:50 +02:00
Isaac Freund
2ed368fb92
std/build: add -p alias for --prefix 2021-04-29 14:25:58 +02:00
LemonBoy
55c58f226d std: Add a parser for hexadecimal floating point numbers
Should be good enough to unblock progress on the stage2 compiler.

Unifying this parser and the regular one (and perhaps rewrite it, #2207)
is left as an exercise for the reader.
2021-04-28 17:36:12 -04:00
Andrew Kelley
86e129eff6 std.Target: bump freebsd known maximum version 2021-04-28 10:26:47 -07:00
Andrew Kelley
2c9ed6daee
Merge pull request #8472 from sreehax/master
callconv: add SysV
2021-04-28 13:11:40 -04:00
joachimschmidt557
bc06e19828 stage2 riscv64: cleanup code and add tests 2021-04-28 07:20:45 +02:00
LemonBoy
da9da76e3f stage1: Implement CPU host detection for PowerPC targets
Untested but should work well on both 32 and 64 bit systems.
2021-04-27 13:11:39 -04:00
Andrew Kelley
1c0259f11e
Merge pull request #8609 from jedisct1/timingSafeCompare
Add std.crypto.utils.timingSafeCompare
2021-04-26 23:03:46 -04:00
Frank Denis
d3361c41db Change timingSafeCompare() to accept slices 2021-04-26 22:32:22 +02:00
Frank Denis
030fa5e7eb
25519: remove unused const, safeguard against unreduced scalars (#8624)
* 25519: remove unused const, safeguard against unreduced scalars

No behavior change, but it makes the existing code better match
the forthcoming code for other curves.

Rename nonAdjacentForm() to slide(), remove an unneeded and
confusing constant, and do a reduction in slide() if 257 bits would
be required.

Note that in all the high-level functions, the top bit is always
cleared, so the reduction is never necessary. But since the low-level
functions are public, the check is a safe thing to have.

* 25519: make identityElement public, deprecate neutralElement

Also fix a few comments by the way.
2021-04-26 22:25:48 +02:00
Andrew Kelley
95b42f9e6b
Merge pull request #8604 from hoanga/haiku-support-sysdefs
further haiku support system definitions
2021-04-26 16:12:23 -04:00
Andrew Kelley
0de962fdd9
Merge pull request #8622 from LemonBoy/cpuinfo
stage2: Add framework for host CPU detection on Linux
2021-04-26 16:02:07 -04:00
Andrew Kelley
528a83dd6b
Merge pull request #8618 from LemonBoy/mini-stuff
Two small patches
2021-04-26 14:32:45 -04:00
Andrew Kelley
ddf9ff79bd Revert "thread: simplify and remove useless return in spawn (#8621)"
This reverts commit 77cb45f59f.

Zig's error return traces will point to the return token if they
happen to occur, so having multiple return statements makes those
stack traces really helpful. This destroys debuggability.
2021-04-26 10:44:40 -07:00
LemonBoy
7e6cc4c505 stage2: Ensure the features set is populated 2021-04-26 18:28:17 +02:00
LemonBoy
896d93e1e6 stage2: Add framework for host CPU detection on Linux
Add a generic framework to parse /proc/cpuinfo and implement the model
detection for 64bit SPARC targets as proof of concept.
2021-04-26 18:11:28 +02:00
Vincent Rischmann
77cb45f59f
thread: simplify and remove useless return in spawn (#8621) 2021-04-26 18:03:32 +02:00
jumpnbrownweasel
bf67a3fdc9
#8454 Fix for std.mem.replacementSize adjacent matches bug. (#8455)
* #8454 Fix for std.mem.replacementSize adjacent matches bug.

When two 'needle' values are adjacent in the 'input' slice, the size is not
counted correctly. The 2nd 'needle' value is not matched because the index is
incremented by one after changing the index to account for the first value.

The impact is the the size returned is incorrect, and could cause UB when this
amount is used to size of the buffer passed to std.mem.replace.

* Apply changes from PR review:

- Add assert checking that the needle is non-empty and doc for this.
- Add minimal test that an empty input works.
- Use testing.expectEqualStrings.
2021-04-25 19:16:24 -04:00
Andrew Kelley
c420eb60ad
Merge pull request #8590 from lithdew/master
x,  x/os/Socket: initial work on new Socket abstraction
2021-04-25 19:15:15 -04:00
Andrew Kelley
2fc6b347ec
Merge pull request #8616 from LemonBoy/fn-align
Function pointer alignment
2021-04-25 19:12:06 -04:00
LemonBoy
82f1d592fa stage1: Use correct alignment for asyncCall frame 2021-04-25 20:41:49 +02:00
Andrew Kelley
6f61594692
Merge pull request #8496 from xackus/isError
std.meta: add isError
2021-04-25 13:27:44 -04:00
LemonBoy
5a94794b73 std: Fix thread creation with field-less context type
Closes #8524
2021-04-25 13:21:15 -04:00
joachimschmidt557
3a55cda14d stage2 register manager: Use an array instead of a hashmap for tracking
allocated registers
2021-04-25 13:20:53 -04:00
LemonBoy
dc29d86649 std: Fix wrong alignOf expression
Mostly harmless but conceptually wrong, luckily it hasn't tripped any
safety check.
2021-04-25 19:12:49 +02:00
LemonBoy
54db36cd88 std: Fix backtraces on sparcv9
Flush all the register windows to stack before starting the stack walk,
we may otherwise try to read garbage and crash and burn.

Add a few comptime annotations to debloat some functions.
2021-04-25 19:10:11 +02:00
Frank Denis
0747591c3d Add std.crypto.utils.timingSafeCompare
A little function to complement the existing crypto.utils.timingSafeEql
function with a way to compare large numbers serialized as arrays.

This is useful to compare nonces and to check that group elements are
in canonical form.

Absence of side channels remains a best effort, reusing the common
pattern we use elsewhere.
2021-04-25 17:07:11 +02:00