Commit Graph

15 Commits

Author SHA1 Message Date
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
leesongun
da2ca447c8
implement xoshiro256++ (#9298)
Implement xoshiro256++
2021-07-04 16:15:23 +02:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Matthew Borkowski
501b4aff99 Add tests for the fill functions of the Isaac64, Pcg, Sfc64, and Xoroshiro128 PRNGs 2021-03-29 09:22:06 +02:00
Matthew Borkowski
a5cc5f7854 Fix typo in Pcg.zig's fill function
When filling the last (len % 4) bytes of a buffer, the random number n was only being shifted right by 4 bits for each byte instead of 8. A random u16, for example, would always have its middle two nybbles be equal when generated this way. For comparison, Isaac64.zig, Sfc64.zig, and Xoroshiro128.zig all correctly shift right by 8 bits for each of the last bytes in their nearly identical fill functions.
2021-03-29 09:22:06 +02:00
Andrew Kelley
44c9bf559b std: disable a couple tests on windows
They are passing but we're hitting OOM on the Windows CI server. This is
to buy us more time until stage2 rescues us from the CI memory crisis.
2021-01-02 12:21:19 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Andrew Kelley
013efaf139 std: introduce a thread-local CSPRNG for general use
std.crypto.random

* cross platform, even freestanding
* can't fail. on initialization for some systems requires calling
  os.getrandom(), in which case there are rare but theoretically
  possible errors. The code panics in these cases, however the
  application may choose to override the default seed function and then
  handle the failure another way.
* thread-safe
* supports the full Random interface
* cryptographically secure
* no syscall required to initialize on Linux (AT_RANDOM)
* calls arc4random on systems that support it

`std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`.

I moved some of the Random implementations into their own files in the
interest of organization.

stage2 no longer requires passing a RNG; instead it uses this API.

Closes #6704
2020-12-18 12:22:46 -07:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
3817420d42 ziggurat uses @truncate instead of & 0xff
This makes it work on 32-bit targets.

closes #2939
2020-04-18 14:41:33 -04:00
Charles Shenton
e073c8a2b1 Update ziggurat.zig to use random.int(u64)
Ziggurat rng was using deprecated `random.scalar(u64)` which was causing compile errors on calls to public facing stdlib APIs (randExp) on 0.6+, this fixed those errors.
2020-04-18 14:39:36 -04:00
Andrew Kelley
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -05:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00