Commit Graph

1548 Commits

Author SHA1 Message Date
Andrew Kelley
57c4d38c55
rename std.event.tcp to std.event.net 2018-09-30 10:37:58 -04:00
emekoi
623f5085f1 merged windows dll apis 2018-09-30 01:05:13 -05:00
emekoi
d3bf267136 added dynamic library loading for windows 2018-09-30 01:05:13 -05:00
Jimmi Holst Christensen
1428ef3b07 Expose failing_allocator as *Allocator instead of const FailingAllocator 2018-09-30 01:23:05 +02:00
Josh Wolfe
e7d9d00ac8 overhaul api for getting random integers (#1578)
* rand api overhaul
* no retry limits. instead documented a recommendation
  to call int(T) % len directly.
2018-09-27 00:35:38 -04:00
Andrew Kelley
9485043b3c
fix implicit casting to *c_void
closes #1588

also some small std lib changes regarding posix sockets
and one doc typo fix
2018-09-26 11:06:09 -04:00
Wink Saville
0e6c18c820 Remove StrLitKind enum
I was looking at the tokenizer specifically fn testTokenize and the
this statement looked odd:

  if (@TagType(Token.Id)(token.id) != @TagType(Token.Id)(expected_token_id)) {

I then saw the TODO and thought I'd remove StrLitKind figuring that
would make testTokenize simpler. It did so I thought I'd prepare this PR.

The tests are still working and stage2 zig seems to work, it compiles and
I was able to use the fmt command.
2018-09-24 19:28:46 -04:00
Wink Saville
a170a64776 Fix typo in argsAlloc comment
Changed freeArgs to argsFree.
2018-09-23 13:12:57 -04:00
Andrew Kelley
7c5e3e1f8e
fixups 2018-09-21 14:15:58 -04:00
Andrew Kelley
073f7ebb0e
fix formatInt to handle upcasting to base int size 2018-09-20 13:46:20 -04:00
Andrew Kelley
15301504e2
Merge remote-tracking branch 'origin/llvm7' 2018-09-19 12:57:58 -04:00
Christian Wesselhoeft
5eeef1f5ed std/index.zig: Fix import
BufferOutStream is defined in io.zig
2018-09-18 19:01:35 -04:00
Andrew Kelley
6dd93ee5d9
fix regression from previous commit 2018-09-18 18:56:29 -04:00
Andrew Kelley
21328e0036
zig fmt: handle shebang lines
closes #1546
2018-09-18 18:36:39 -04:00
Andrew Kelley
275b4100c0
remove unnecessary setFloatMode calls
Now that Strict is the default, these calls only add noise.
2018-09-18 15:15:03 -04:00
Andrew Kelley
4b2719b51d
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-18 15:05:47 -04:00
Andrew Kelley
15e59eb142
remove deprecated, unused windows functions
* `CryptAcquireContextA`
 * `CryptReleaseContext`
 * `CryptGenRandom`

See https://github.com/ziglang/zig/issues/534#issuecomment-422208368
2018-09-17 20:07:48 -04:00
Andrew Kelley
4c6f1e614a
remove zig build --init. add zig init-lib and zig init-exe
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.

both now have test coverage with the new "cli tests" file.

closes #1035
2018-09-17 17:11:18 -04:00
Andrew Kelley
a2abdb185f
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-16 10:51:58 -04:00
Andrew Kelley
3f776af3fa
fix alignment of structs
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -04:00
Wink Saville
d9ed3d186d
Add test for Queue.dump
To make dump testable added dumpToSteam which takes a stream as input
and added the stream as a paraemter to dumpRecursive.

Added test "std.atomic.Queue dump"

And to make the test more robust SliceOutStream.pos is now public. This
allows the user of SliceOutStream to know the length of the data captured.
2018-09-14 14:14:58 -07:00
Wink Saville
82af31ce36 Fix additional regressions calling FileOutStream/FileInStream init()
This is caused by change 686663239a and not
fixed in 832caefc2a.
2018-09-14 12:07:21 -04:00
Andrew Kelley
c06a61e9bf
remove this. add @This().
closes #1283
2018-09-13 16:34:33 -04:00
Marc Tiehuis
e70c543bc4 math/complex: cexp test correction and ldexp usage fix 2018-09-13 20:33:05 +12:00
Andrew Kelley
a757533386 fix zig fmt on windows
closes #1069
2018-09-12 14:26:21 -04:00
Andrew Kelley
178d69191b windows: std.fs functions support concurrent ops
when reading and writing the same file descriptors
2018-09-12 13:55:35 -04:00
Andrew Kelley
0cfd019377
Merge pull request #1494 from ziglang/stage1-caching
stage1 caching
2018-09-12 12:40:16 -04:00
emekoi
54f7d58722 fixed WriteFile segfault 2018-09-12 07:01:48 -05:00
Andrew Kelley
04dc5cdaca
zig build: make the cache root dir before building 2018-09-11 18:15:08 -04:00
Andrew Kelley
9227315bf2
zig build: better placement of test exe artifact 2018-09-11 17:23:36 -04:00
Andrew Kelley
7dd3c3814d
fix incorrect error union const value generation
closes #1442

zig needed to insert explicit padding into this structure before
it got bitcasted.
2018-09-11 15:16:50 -04:00
Andrew Kelley
c9474faa4e
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-10 12:30:57 -04:00
Bas van den Berg
7c9f7b72c5 Add capacity and appendAssumeCapacity to ArrayList 2018-09-09 10:28:07 -04:00
Shawn Landden
17cb69cebc fix elf auxv handling
Auxillery vectors are not guaranteed to be in any order, this
just happens to work on x86_64.
2018-09-08 14:47:21 +00:00
Shawn Landden
7d6d1d1f60 NaNs do not have signedness.
From IEEE-754 standard:

Conversion of a quiet NaN in a supported format to an external character sequence
shall produce a language-defined one of “nan” or a sequence that is equivalent except
for case (e.g., “NaN”), with an optional preceding sign. (This standard does not interpret
the sign of a NaN.)
2018-09-08 03:52:28 +00:00
Shawn Landden
cba0d76fbc clone() on arm64 2018-09-08 03:52:28 +00:00
Shawn Landden
f8808edff4 simplify f64_min to equivilent value
arm64 complains about the old value (I added a test)
2018-09-08 03:52:28 +00:00
Shawn Landden
342cff28f5 initial arm64 support 2018-09-08 03:52:28 +00:00
Shawn Landden
4a8c992ef1 os: use less syscalls
these don't exist on new platforms (such as arm64)

also switch from the deprecated dirent to dirent64
2018-09-08 03:52:28 +00:00
Shawn Landden
d956d30167 this is not arch-specific 2018-09-08 03:52:28 +00:00
Andrew Kelley
a9a925e500
add C ABI tests 2018-09-06 16:29:35 -04:00
kristopher tate
15d30b967a std/crypto/x25519.zig: add test for createPublicKey; 2018-09-06 12:24:53 +09:00
kristopher tate
d1855a0e93 std/crypto/x25519.zig: fix signature for createPublicKey; 2018-09-06 12:24:12 +09:00
Andrew Kelley
b00007056d
update throughput test to new File API
closes #1468
2018-09-04 15:33:44 -04:00
Andrew Kelley
dbde8254d0
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-04 11:58:31 -04:00
Andrew Kelley
2bd2a8ea34
Merge pull request #1441 from ziglang/poly1305-x25519
Add poly1305 and x25519 crypto primitives
2018-09-04 10:34:46 -04:00
Marc Tiehuis
8b50d10a84 std/crypto: Clean up poly1305/x25519 2018-09-04 20:16:12 +12:00
Andrew Kelley
92f7474359 switch most windows calls to use W versions instead of A
See #534
2018-09-02 23:25:04 -04:00
Andrew Kelley
3eb89ee4db
fixups
* zig fmt
 * use canonical parameter order. memcpy has dest first and
   the base64 code follows the pattern.
 * pass correct radix to charToDigit
2018-09-02 19:23:30 -04:00
Andrew Kelley
0d8412d9f0
Merge branch 'std-fmt-hexToBytes' of https://github.com/kristate/zig into kristate-std-fmt-hexToBytes 2018-09-02 19:08:54 -04:00
Andrew Kelley
ab387bb4c7
Merge pull request #1460 from ziglang/Sahnvour-windows-coff-issue721
Stack traces for Windows
2018-09-02 18:47:48 -04:00
Andrew Kelley
832caefc2a fix regressions 2018-09-02 18:35:32 -04:00
Andrew Kelley
4cd50865bf fix source file lookup 2018-09-02 17:58:50 -04:00
Andrew Kelley
98dc943c07 rework code to avoid duplicate operations 2018-09-02 15:58:08 -04:00
kristopher tate
fbd9bac5e7 std/fmt/index.zig: add hexToBytes function under std.fmt;
Depends on #1454 being implemented;
2018-09-03 01:12:52 +09:00
Andrew Kelley
86e55567b4
Merge pull request #1454 from kristate/str-hexbytes-issue1453
std.fmt: print zeroed high-order bytes correctly in hex
2018-09-02 11:31:05 -04:00
Andrew Kelley
78a110cda5
Merge pull request #1452 from shawnl/patch-1
std/rb.zig: fix comment
2018-09-02 11:17:54 -04:00
Shawn Landden
528e3b43a6 these all use futex() (inaccurate comments) 2018-09-01 23:52:52 -07:00
kristopher tate
d1752fbdc0 std/fmt/index.zig: test for printing double width hex bytes with zeros;
Co-Authored-By: Shawn Landden <shawn@git.icu>
2018-09-02 15:04:57 +09:00
kristopher tate
48d3fbef5c std/fmt/index.zig: set width from 0 to 2;
\x00 was printed as 0 and \x0E was printed as E;
\x00 now correctly prints 00 and \x0E correctly prints 0E;
2018-09-02 15:04:20 +09:00
Shawn Landden
4bf54f3010
std/rb.zig: fix comment 2018-09-01 22:23:34 -07:00
kristopher tate
7a633f472d std/fmt/index.zig: #1358: test bytes printed-out as hex; 2018-09-01 19:53:11 +09:00
kristopher tate
454b2362ee std/fmt/index.zig: #1358 allow bytes to be printed-out as hex;
Supports {x} for lowercase and {X} for uppercase;
2018-09-01 19:40:05 +09:00
Andrew Kelley
6ddbd345aa figuring out where /names stream is 2018-08-31 19:50:03 -04:00
Andrew Kelley
b36b93fb3e awareness of debug subsections 2018-08-31 15:02:41 -04:00
Marc Tiehuis
763845f95c std/crypto: zig fmt 2018-08-31 18:45:45 +12:00
Marc Tiehuis
38399941d4 std/crypto: Update throughput_test.zig to include all hash functions
This avoids the need to recompile to test specific hash functions. This
also adds mac/key exchange performance tests as well.
2018-08-31 18:45:07 +12:00
Marc Tiehuis
a7527389cc Make poly1305 and x25519 more idiomatic zig
This also adjusts the current hash/hmac functions to have a consistent
interface allowing easier switching/testing.
2018-08-31 18:40:09 +12:00
Andrew Kelley
99170aa13d finding source file, line, and column info 2018-08-31 01:01:37 -04:00
Andrew Kelley
72185e7dd3 finding the function that an address is in 2018-08-30 16:57:55 -04:00
Andrew Kelley
44f908d2e6 figuring out which module an address belongs in 2018-08-30 15:33:50 -04:00
Andrew Kelley
96117e20cc reading the module information substream 2018-08-30 03:44:34 -04:00
Marc Tiehuis
65b89f598c Add poly1305 and x25519 crypto primitives
These are translated from [monocypher](https://monocypher.org/) which
has fairly competitive performance while remaining quite simple.

Initial performance comparision:

Zig:
 Poly1305: 1423 MiB/s
 X25519:   8671 exchanges per second

Monocypher:
 Poly1305: 1567 MiB/s
 X25519:   10539 exchanges per second

There is room for improvement and no real effort has been made at all in
optimization beyond a direct translation.
2018-08-30 18:02:19 +12:00
Andrew Kelley
686663239a printing info from the ModuleInfo substream of DebugInfo 2018-08-29 19:00:24 -04:00
Andrew Kelley
f1b71053de use RtlCaptureStackBackTrace on windows 2018-08-29 16:35:51 -04:00
Andrew Kelley
833477abf5 fix unresolved path preventing PDB loading 2018-08-28 18:55:51 -04:00
Andrew Kelley
41723f842c Merge branch 'windows-coff-issue721' of https://github.com/Sahnvour/zig into Sahnvour-windows-coff-issue721 2018-08-28 17:32:32 -04:00
Andrew Kelley
9de0f900e1
Merge pull request #1369 from shawnl/crypto
std/crypto: add chacha20
2018-08-28 16:07:58 -04:00
Marc Tiehuis
87eb95f816 speed up chacha20
The main changes are:

    Unrolling the inner rounds of salsa20_wordtobyte which doubles the speed.
    Passing the slice explicitly instead of returning the array saves a copy (can optimize out in future with copy elision) and gives ~10% improvement.
    Inlining the outer loop gives ~15-20% improvement but it costs an extra 4Kb of code space. I think the tradeoff is worthwhile here.
    The other inline loops are small and can be done by the compiler if it is worthwhile.
    The rotate function replacement doesn't alter the performance from the former.

The modified throughput test I've used to benchmark is as follows. Interestingly we need to allocate memory instead of using a fixed buffer else Zig optimizes the whole thing out.

https://github.com/ziglang/zig/pull/1369#issuecomment-416456628
2018-08-27 22:55:53 -07:00
Shawn Landden
444edd9aed std.crypto: add chaCha20
v3
2018-08-27 19:44:11 -07:00
Andrew Kelley
fb6d3859e8
zig fmt 2018-08-27 19:25:40 -04:00
Andrew Kelley
4f2d49fd13
std.zig.parse: fix parsing of doc comments after fields
closes #1404
2018-08-27 19:21:38 -04:00
tgschultz
ecc5464024 Handle unions differently in std.fmt (#1432)
* Handle unions differently in std.fmt

Print the active tag's value in tagged unions. Untagged unions considered unsafe to print and treated like a pointer or an array.
2018-08-27 17:25:33 -04:00
Andrew Kelley
7109035b78 Merge remote-tracking branch 'origin/master' into llvm7 2018-08-25 21:57:28 -04:00
Andrew Kelley
2cce171448 add test for previous commit 2018-08-25 17:28:30 -04:00
tgschultz
61c0c6d502
Fixed compile error when passing enum to fmt
Caused by struct printing behavior. Enums are different enough from structs and unions that the field iteration behavior doesn't do what we want even if @memberName didn't error on enums.
2018-08-25 10:51:49 -05:00
Andrew Kelley
815950996d Merge remote-tracking branch 'origin/master' into macos-stack-traces 2018-08-25 04:48:58 -04:00
Andrew Kelley
ac36f98e72 fix stack traces on linux 2018-08-25 03:07:37 -04:00
Andrew Kelley
32901926f0 compilation unit cwd dir appears to be unnecessary on macos 2018-08-24 15:43:48 -04:00
Andrew Kelley
4e7c255e4d macos stack traces have address-to-line translation 2018-08-24 14:55:55 -04:00
Andrew Kelley
bf1f91595d std.debug: remove workaround for fixed bug 2018-08-24 13:00:28 -04:00
Andrew Kelley
6b31b178a6 fix regression from 2f7f7d815d 2018-08-24 12:59:31 -04:00
Andrew Kelley
95e197667e macos stack traces have the compilation unit in them 2018-08-24 11:30:36 -04:00
Andrew Kelley
3173c90f14 macos stack traces: read debug info sections from .o files 2018-08-23 23:08:34 -04:00
Andrew Kelley
6c064cfd88
Merge pull request #1405 from shawnl/path-max
missing PATH_MAX change
2018-08-23 20:16:13 -04:00
Shawn Landden
2f7f7d815d missing PATH_MAX change 2018-08-23 17:00:50 -07:00
Andrew Kelley
5c1ec20c9a MacOS stack traces use the already mmapped executable
...rather than trying to find the executable on the file system.

Also use a more robust PIE offset calculation based on the
available metadata.

And for the last function, use the data that tells the end
rather than assuming 4K.

Also they print in a consistent way with Linux stack traces.
2018-08-23 16:23:33 -04:00
Andrew Kelley
327482c3a4
Merge pull request #1402 from ziglang/default-fp-ieee-strict
Default to strict IEEE floating point
2018-08-23 08:26:09 -04:00
Marc Tiehuis
353419f82d Default to strict IEEE floating point
Closes #1227.
2018-08-23 22:54:46 +12:00
Andrew Kelley
8f96553be8 rename std.debug.ElfStackTrace to std.debug.DebugInfo 2018-08-22 21:35:49 -04:00
kristopher tate
e95345b3dc std/mem.zig: test writing u64 integers; 2018-08-23 09:03:02 +09:00
Andrew Kelley
478db39866 fix selfExePath on macosx 2018-08-21 20:52:21 -04:00
Andrew Kelley
ea1b21dbdb fix linux
* error.BadFd is not a valid error code. it would always be a bug to
   get this error code.
 * merge error.Io with existing error.InputOutput
 * merge error.PathNotFound with existing error.FileNotFound.
   Not all OS's support both.
 * add os.File.openReadC
 * add error.BadPathName for windows file operations with invalid
   characters
 * add os.toPosixPath to help stack allocate a null terminating byte
 * add some TODOs for other functions to investigate removing the
   allocator requirement
 * optimize some implementations to use the alternate functions when
   a null byte is already available
 * add a missing error.SkipZigTest
 * os.selfExePath uses a non-allocating API
 * os.selfExeDirPath uses a non-allocating API
 * os.path.real uses a non-allocating API
 * add os.path.realAlloc and os.path.realC
 * convert many windows syscalls to use the W versions (See #534)
2018-08-21 20:31:50 -04:00
Andrew Kelley
51852d2587 fix windows 2018-08-21 16:07:28 -04:00
Andrew Kelley
bda5539e9d *WIP* std.os assumes comptime-known max path size
this allows us to remove the requirement of allocators for a lot
of functions

See #1392
2018-08-21 00:46:42 -04:00
Andrew Kelley
302936309a Merge branch 'path_max' of https://github.com/shawnl/zig into shawnl-path_max 2018-08-20 17:57:49 -04:00
Andrew Kelley
9e9dce76ff refactor std.os.makePath to use a switch instead of if 2018-08-20 17:57:03 -04:00
Andrew Kelley
820bf054ea std.fmt.format: handle non-pointer struct/union/enum
Also adds support for printing structs via reflection.
The case when structs have pointers to themselves is not
handled yet.

closes #1380
2018-08-20 16:04:03 -04:00
Shawn Landden
bb93886791 do not use an allocator when we don't need to because of the existance of PATH_MAX 2018-08-19 21:42:48 -07:00
Marc Tiehuis
53b18b0791 Add secureZero function
This is identical to `mem.set(u8, slice, 0)` except that it will never
be optimized out by the compiler. Intended usage is for clearing
secret data.

The resulting assembly has been manually verified in --release-* modes.

It would be valuable to test the 'never be optimized out' claim in tests
but this is harder than initially expected due to how much Zig appears
to know locally. May be doable with @intToPtr, @ptrToInt to get around
known data dependencies but I could not work it out right now.
2018-08-18 12:15:39 +12:00
tgschultz
fa955f0024
fixed handling of [*]u8 when no format specifier is set
If fmt was called on with a [*]u8 or [*]const u8 argument, but the fmt string did not specify 's' to treat it as a string, it produced a compile error due to accessing index 1 of a 0 length slice.
2018-08-14 12:56:41 -05:00
Shawn Landden
64a71be5c3 rb: some style fixes
avoid @import("std") as is the custom

compare function name
2018-08-10 21:46:30 -07:00
Andrew Kelley
c4b9466da7
Merge pull request #1294 from ziglang/async-fs
introduce std.event.fs for async file system functions
2018-08-10 15:51:17 -04:00
Andrew Kelley
598e80957e windows: call CancelIo when canceling an fs watch 2018-08-10 13:19:07 -04:00
Andrew Kelley
23af36c54f windows fs watching: fix not initializing table value 2018-08-09 21:48:25 -04:00
Andrew Kelley
26a842c264 windows: only create io completion port once 2018-08-09 20:12:46 -04:00
Andrew Kelley
b219feb3f1 initial windows implementation of std.event.fs.Watch 2018-08-09 16:48:44 -04:00
Andrew Kelley
c63ec9886a std.event.fs.preadv windows implementation 2018-08-08 16:55:19 -04:00
Andrew Kelley
8b456927be std.event.fs.pwritev windows implementation
also fix 2 bugs where the function didn't call allocator.shrink:
 * std.mem.join
 * std.os.path.resolve
2018-08-08 15:06:32 -04:00
Andrew Kelley
ac12f0df71 fix linux regressions 2018-08-07 22:23:26 -04:00
Andrew Kelley
60955feab8 std.event.fs.Watch distinguishes between Delete and CloseWrite on darwin
TODO: after 1 event emitted for a deleted file, the file is no longer
watched
2018-08-07 22:14:30 -04:00
Andrew Kelley
5cbfe392be implement std.event.fs.Watch for macos 2018-08-07 21:06:21 -04:00
Shawn Landden
a583beb76c mem: use pub on Compare (#1352)
fixes rb

/home/shawn/git/zig/std/rb.zig:133:37: error: 'Compare' is private
    compare_fn: fn(*Node, *Node) mem.Compare,
2018-08-07 19:15:11 -04:00
Andrew Kelley
034363a86c
Merge pull request #1338 from shawnl/master
std: add red-black tree implementation
2018-08-07 12:47:28 -04:00
Shawn Landden
bbbb26f4d3 mem: add mem.compare(), and use it for mem.lessThan() 2018-08-07 05:30:54 -07:00
Shawn Landden
86b512c5cd mem: move enum Compare from rb to mem 2018-08-07 04:57:41 -07:00
Shawn Landden
5d2abf4402 std: add red-black tree implementation
This is to be used with @fieldParentPtr();

Example:

const rb = @import("std").rb;

const Number = struct {
    node: rb.Node,
    value: i32,
};

fn number(node: *rb.Node) *Number {
    @fieldParentPtr(Number, "node", node);
}

fn compare(l: *rb.Node, r: *rb.Node) rb.Compare {
    var left = number(l);
    var right = number(r);

    if (left.value < right.value) {
        return rb.Compare.LessThan;
    } else if (left.value == right.value) {
        return rb.Compare.Equal;
    } else if (left.value > right.value) {
        return rb.Compare.GreaterThan;
    }
    unreachable;
}
--

A version that caches rb.Tree.first() could be added in the future.
2018-08-06 22:18:44 -07:00
Andrew Kelley
1a28f09684 fix hash map test 2018-08-07 00:54:19 -04:00
Andrew Kelley
fd50a6896b std.event.fs support for macos
The file I/O stuff is working, but the fs watching
stuff is not yet.
2018-08-07 00:49:09 -04:00
Andrew Kelley
2c9ed664dd merge @kristate's std lib changes to darwin 2018-08-06 19:36:31 -04:00
Andrew Kelley
97be8debab std.HashMap.autoHash: use xor instead of wrapping mult 2018-08-06 19:09:22 -04:00
Andrew Kelley
24d74cbf44 fix Thread impl on Linux and add docs 2018-08-06 17:31:52 -04:00
Andrew Kelley
d2dd29e80c separate os.Thread.Id and os.Thread.Handle because of windows 2018-08-06 17:25:24 -04:00
Andrew Kelley
0a3ae9dc6e fix std.os.Thread.getCurrentId for linux 2018-08-06 16:48:49 -04:00
Andrew Kelley
647fd0f4f1 Merge branch 'threadid' of https://github.com/mdsteele/zig into mdsteele-threadid 2018-08-06 16:12:37 -04:00
Andrea Orru
79d77faebf More type cast fixes 2018-08-06 02:42:12 -04:00
Andrea Orru
641066d82e Fix casts 2018-08-06 02:29:11 -04:00
Andrea Orru
d2f5e57b68 Merge branch 'master' into zen_stdlib 2018-08-06 01:43:19 -04:00
Matthew D. Steele
7a2401ef1e Don't compare ?Thread.Id == Thread.Id in the test
It doesn't work, because of issue #1332.
2018-08-04 21:47:13 -04:00
Andrew Kelley
b48948d6e8 Merge branch 'master' into llvm7 2018-08-04 15:19:03 -04:00
kristopher tate
a25824e033 zig/std/os/index.zig: clean-up thread id; (#1)
Ref #1316 #1330
2018-08-04 14:38:51 -04:00
Matthew D. Steele
86d1cc8e2f Add thread ID support to std.os.Thread (fixes #1316) 2018-08-03 21:36:04 -04:00
Andrew Kelley
2680f9ab48 Merge remote-tracking branch 'origin/master' into async-fs 2018-08-03 18:47:30 -04:00
Andrew Kelley
c5f1925bc8 when decls don't change, don't regenerate them 2018-08-03 17:59:11 -04:00
Andrew Kelley
5dfcd09e49 self-hosted: watch files and trigger a rebuild 2018-08-03 17:22:17 -04:00
Matthew D. Steele
dcaaa241df Fix a type error in std.os.linux.getpid() (#1326)
syscall0() returns usize, but we were trying to @bitCast to i32.
2018-08-03 11:45:23 -04:00
Matthew D. Steele
c2a08d7c51 Fix the start-less-than-end assertion in std.rand.Random.range (#1325)
The function returns a value in [start, end), but was asserting
start <= end instead of start < end.  With this fix, range(1, 1)
will now assertion error instead of dividing by zero.
2018-08-03 11:44:39 -04:00
Andrew Kelley
7f6e97cb26 fixups from the merge 2018-08-02 17:36:08 -04:00
Andrew Kelley
65140b2fba Merge remote-tracking branch 'origin/master' into async-fs 2018-08-02 17:29:31 -04:00
Andrew Kelley
821805aa92 WIP: Channel.getOrNull 2018-08-02 17:04:17 -04:00
Andrew Kelley
895f262a55 pull request fixups
* clean up parser code
 * fix stage2 parse and render code
 * remove redundant test
 * make stage1 compile tests leaner
2018-08-02 14:15:31 -04:00
Andrew Kelley
44fd3045ce Merge branch 'handle-builtin-issue1296' of https://github.com/kristate/zig into kristate-handle-builtin-issue1296 2018-08-02 13:37:24 -04:00
Andrew Kelley
729f2aceb0 fix API of RtlGenRandom 2018-08-02 13:34:31 -04:00
Andrew Kelley
cbca434cf0 Merge branch 'windows-RtlGenRandom-issue1318' of https://github.com/kristate/zig into pr-1319 2018-08-02 13:26:02 -04:00
kristopher tate
782043e2e6 std/os/windows/util.zig: SKIP instead of PASS on non-windows systems;
Tracking Issue #1318 ;
2018-08-03 02:16:49 +09:00
kristopher tate
dde7eb45c5 std/os/index.zig: call getRandomBytes() twice and compare;
Tracking Issue #1318 ;
2018-08-03 02:16:19 +09:00
kristopher tate
c44653f40f std/os/index.zig: swap CryptGetRandom() with RtlGenRandom();
Tracking Issue #1318 ;
2018-08-03 02:14:52 +09:00
kristopher tate
22fd359e2c std/os/windows/advapi32.zig: add SystemFunction036;
Tracking Issue #1318 ;
2018-08-03 02:14:06 +09:00
kristopher tate
432b7685bf std/os/index.zig: use "hw.logicalcpu" instead of "hw.ncpu" in macOS; (#1317)
Tracking Issue #1252 ;

hw.ncpu was deprecated in macOS. Among 4 new options available (hw.{physicalcpu, physicalcpu_max, logicalcpu, logicalcpu_max}), hw.logicalcpu was chosen because it actually reflects the number of logical cores the OS sees.
2018-08-02 12:59:59 -04:00
kristopher tate
96a94e7da9 std/event: directly return @handle();
Tracking Issue #1296 ;
2018-08-02 17:52:40 +09:00
kristopher tate
bc032a89cc std/zig/parser_test.zig: update test to reflect that the promise symbol is no in scope with suspend;
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
9fe140abad std/event/tcp.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
a3705b4251 std/event/loop.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
efec3a0e34 std/event/lock.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
b4ff464d39 std/event/group.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
244a7fdafb std/event/future.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
29057e5511 std/event/channel.zig: remove promise_symbol from suspend and use @handle();
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
Andrew Kelley
e3ae2cfb52 add std.event.RwLock and a few more std changes
* add std.event.RwLock and std.event.RwLocked
 * std.debug.warn does its printing locked
 * add std.Mutex, however it's currently implemented as a spinlock
 * rename std.event.Group.cancelAll to std.event.Group.deinit and change
   the docs and assumptions.
 * add std.HashMap.clone
2018-08-01 16:26:37 -04:00
Marc Tiehuis
e66f538972 Add integer binary output format (#1313) 2018-08-01 11:38:04 -04:00
Andrew Kelley
de949b72c7 simpler std.event.Lock implementation 2018-07-31 19:57:46 -04:00
Andrew Kelley
f804310d9f Merge remote-tracking branch 'origin/master' into llvm7 2018-07-31 14:36:27 -04:00
Andrew Kelley
058bfb254c std.fmt.format: add '*' for formatting things as pointers
closes #1285
2018-07-31 11:36:57 -04:00
Andrew Kelley
3c8d4e04ea std: file system watching for linux 2018-07-30 13:46:09 -04:00
Andrew Kelley
a870228ab4 self-hosted: use std.event.fs.readFile 2018-07-30 13:44:36 -04:00
Andrew Kelley
cc45527333 introduce std.event.fs for async file system functions
only works on linux so far
2018-07-30 13:44:36 -04:00
Andrew Kelley
5d4a02c350
Merge pull request #1307 from ziglang/cancel-semantics
improved coroutine cancel semantics
2018-07-30 13:42:26 -04:00
Andrew Kelley
09304aab77 fix cancel and await semantics 2018-07-29 23:25:40 -04:00
dbandstra
608ff52dc3 add SliceOutStream, rename SliceStream to SliceInStream (#1301) 2018-07-29 14:52:10 -04:00
dbandstra
f36faa32c4 add skipBytes function to InStream
this reads N bytes, discarding their values
2018-07-28 17:34:28 -07:00
dbandstra
3ce0ea884f add int writing functions to OutStream
added: writeInt, writeIntLe, and writeIntBe
2018-07-28 17:30:05 -07:00
Andrew Kelley
05456eb275 make some functions in std.event.Loop public 2018-07-28 12:53:33 -04:00
Andrew Kelley
02713e8d8a fix race conditions in self-hosted compiler; add test
* fix race condition in std.event.Channel deinit
 * add support to zig build for --no-rosegment
 * add passing self-hosted compare-output test for calling a function
 * put a global lock on LLD linking because it's not thread safe
2018-07-24 21:28:54 -04:00
Nathan Sharp
0046551852
std.io: PeekStream and SliceStream
SliceStream is a read-only stream wrapper around a slice of bytes. It
allows adapting algorithms which work on InStreams to in-memory data.

PeekStream is a stream wrapper which allows "putting back" bytes into
the stream so that they can be read again. This will help make
look-ahead parsers easier to write.
2018-07-23 23:30:40 -07:00
Andrew Kelley
dd9728c5a0 Merge remote-tracking branch 'origin/master' into llvm7 2018-07-24 00:43:12 -04:00
Andrew Kelley
72599d420b self-hosted: find all libc paths; windows linker code 2018-07-24 00:06:34 -04:00
Andrew Kelley
7dbbddf2a6 macho backtraces - use std.sort.sort instead of insertion sort
it's way faster
2018-07-23 15:36:45 -04:00
Andrew Kelley
5a919dd82d Merge remote-tracking branch 'origin/master' into self-hosted-libc-hello-world 2018-07-23 14:32:13 -04:00
Andrew Kelley
10d2f08d37 self-hosted: fix error messages not cleaning up correctly 2018-07-23 14:28:14 -04:00
Andrew Kelley
d767fae47e self-hosted: add first compare-output test 2018-07-23 00:35:53 -04:00
Andrew Kelley
93e78ee722 self-hosted can compile libc hello world 2018-07-22 23:28:53 -04:00
Andrew Kelley
99153ac0aa add std.math.big.Int.fitsInTwosComp
so that we can pass runtime-known values
2018-07-22 10:58:45 -04:00
Marc Tiehuis
d53fae3551 Add big int fits function (#1279)
Returns whether the current value in an Int fits in the requested type.
2018-07-22 10:11:27 -04:00
Marc Tiehuis
07b6a3d335 Tighten Int.to bounds and add twos-complement bitcount 2018-07-22 17:47:57 +12:00
Andrew Kelley
20f286f22a re-organize std lib darwin files 2018-07-22 00:04:24 -04:00
Andrew Kelley
f72f46e912 Merge branch 'posix-darwin-issue1271' of https://github.com/kristate/zig into kristate-posix-darwin-issue1271 2018-07-21 23:59:35 -04:00
Andrew Kelley
4d9964a457 rename error.skip to error.SkipZigTest
also print stats at the end of test runner
2018-07-21 23:43:43 -04:00
Sahnvour
2ec9a11646 Very much WIP base implementation for #721.
Currently does:
- read COFF executable file
- locate and load corresponding .pdb file
- expose .pdb content as streams (PDB format)
2018-07-21 20:30:11 +02:00
kristopher tate
c5c053b6fd std.event.tcp: add switch statement in preparation for building-out abstractions;
depends on issue #1274 ;
2018-07-22 03:11:55 +09:00
kristopher tate
bc411af4ff std.event.tcp: SKIP test instead of OKing test;
tracking issue #1274 ;
2018-07-22 02:21:52 +09:00
kristopher tate
df574ccf86 std.special.test_runner.zig: make tests skippable;
tracking issue #1274;

tests can be skipped by returnning `error.skip` :
2018-07-22 02:20:03 +09:00