Commit Graph

3688 Commits

Author SHA1 Message Date
Sébastien Marie
89e522b935 make std.c.getErrno() return same type as _errno() aka c_int
adjust std.os.unexpectedErrno() to be correct for all std.os.system.errno (c_int, u12, usize, ...)
2021-03-12 15:04:36 +01:00
Andrew Kelley
e9a038c33b
Merge pull request #7934 from Vexu/stage2-cbe
Stage2 cbe: optionals and errors
2021-03-11 22:02:35 -05:00
Isaac Freund
a5cb4ab95e parser: disallow ptr modifiers on array types 2021-03-12 00:18:30 +01:00
LemonBoy
482424e2b1 std: Handle empty MultiArrayList in items()
Closes #8211
2021-03-12 00:17:35 +01:00
Andrew Kelley
4fc6f631e0
Merge pull request #8126 from xackus/translate_c_int_literal_promotion
translate-c: promote int literals to bigger types
2021-03-11 14:32:37 -05:00
Asherah Connor
24e5959840 elf: make EM non-exhaustive 2021-03-11 10:09:51 +11:00
Asherah Connor
c5eb15526d expose machine field in ELF header 2021-03-10 16:26:41 +11:00
Loris Cro
a033735c8d update to latest fetch-them-macos-headers 2021-03-09 22:43:16 +01:00
Loris Cro
767eb2d469 update to latest fetch-them-macos-headers 2021-03-09 22:15:01 +01:00
Isaac Freund
b988815bf0 parser: fix parsing/rendering of a[b.. :c] slicing
The modification to the grammar in the comment is in line with the
grammar in the zig-spec repo.

Note: checking if the previous token is a colon is insufficent to tell
if a block has a label, the identifier must be checked for as well. This
can be seen in sentinel terminated slicing: `foo[0..1:{}]`
2021-03-08 01:37:28 +01:00
Veikka Tuominen
0a7be71bc2
stage2 cbe: non pointer optionals 2021-03-08 00:33:56 +02:00
jacob gw
5d215cc76b stage2 Elf linker: fill in bswapAllFields
I moved it to std.elf since it could be used there and added test
2021-03-07 23:18:26 +02:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter (#8137)
* Implement fmtDuration using Formatter

Deprecate Duration, duration

* fmtDuration: Fixed ns remainder

* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491 std: Deprecate the B and Bi format specifiers
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
e47b754b28 std: Prevent null pointer deref in mem.len{,Z}
Closes #8140
2021-03-07 14:58:45 +02:00
Vincent Rischmann
272ae0ca0d fix parsing of assignment with 'inline for' and 'inline while' 2021-03-06 17:39:54 -08:00
Meghan
9f722f43ac
std/special: init-exe,lib make import(std) its own decl (#8160)
std/special: init-exe,lib make import(std) its own decl
2021-03-05 19:13:05 -08:00
Isaac Freund
ef3adbdb36 zig fmt: fix lastToken() for container_decl_arg 2021-03-05 21:33:27 +01:00
xackus
eee43a65ae add tests 2021-03-05 21:21:23 +01:00
Maciej Walczak
5f53b77c2b remove redundant cast
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-03-05 21:04:27 +01:00
xackus
679910ecec translate-c: promote int literals to bigger types 2021-03-05 21:04:27 +01:00
Veikka Tuominen
9cd038d73a std: fix memory leak in MultiArrayList 2021-03-05 10:52:40 -08:00
cryptocode
02737d535a Reject bare +/- input when parsing floats 2021-03-05 13:11:20 +01:00
Andrew Kelley
434fce2146 zig fmt: recovery: missing while rbrace
Previously, this test case resulted in zig fmt entering an endless loop.
2021-03-04 20:54:09 -07:00
Andrew Kelley
ffb2568a9f
Merge pull request #7763 from kivikakk/zig-elf-parse
std.elf: expose parsing decoupled from std.fs.File
2021-03-04 11:56:31 -08:00
daurnimator
34ca6b7b44 std: add io.Writer.writeStruct
We have readStruct, add writeStruct for symmetry
2021-03-03 22:45:45 +01:00
Veikka Tuominen
904f774563 translate-c: fix c tokenizer giving invalid tokens 2021-03-03 11:33:14 -08:00
Isaac Freund
3ad9cb8b47 zig fmt: allow and trim whitespace around zig fmt: (off|on)
Currently `//  zig fmt: off` does not work as there are two spaces
after the `//` instead of one. This can cause confusion, so allow
arbitrary whitespace before the `zig fmt: (off|on)` in the comment but
trim this whitespace to the canonical single space in the output.
2021-03-03 01:06:09 +01:00
Vincent Rischmann
3dd8396a55 os/linux: fix IO_Uring.timeout
According to the io_uring PDF (https://kernel.dk/io_uring.pdf) the
timeout struct must be 64 bits on both 32 and 64 bit architectures.
2021-03-02 14:13:11 +02:00
Andrew Kelley
f9c9b92175
Merge pull request #7946 from koachan/sparc64-framefixes
SPARCv9: Handle various stack frame related quirks.
2021-03-01 19:10:36 -08:00
Andrew Kelley
a20169a610 zig fmt the std lib 2021-03-01 20:04:28 -07:00
Martin Wickham
7613e51a57 Add some bit set variants 2021-03-01 18:52:15 -08:00
Isaac Freund
7b5b7bda87 parser: fix infinite loop on missing comma in param list 2021-03-01 16:09:57 -08:00
LemonBoy
cd7c870bd8 std: Deprecate 'x'/'X'/'e'/'E' special cases for u8 slices
Let's follow the road paved by the removal of 'z'/'Z', the Formatter
pattern is nice enough to let us remove the remaining four special cases
and declare u8 slices free from any special casing!
2021-03-01 15:33:10 -08:00
LemonBoy
bee7db77fe std: Replace lastIndexOf with lastIndexOfScalar
This may work around the miscompilation in LLVM 12.
2021-03-01 11:08:16 -08:00
fancl20
baab1b2f31
std: Add std.fs.path.joinZ (#7974)
* std: Add std.fs.path.joinZ

* Merge std.fs.path.join and std.fs.path.joinZZ tests
2021-03-01 10:38:56 +02:00
Evan Haas
45d220cac6 translate-c: add <assert.h> support
Implement __builtin_expect so C code that uses assert() can be translated.
2021-03-01 10:34:23 +02:00
Andrew Kelley
9550db33cb
Merge pull request #8097 from LemonBoy/thread-spawn-order
std: Swap arguments in Thread.spawn
2021-02-28 20:42:34 -08:00
Frank Denis
a5a3ad4f95 std/crypto: add AES-OCB
OCB has been around for a long time.

It's simpler, faster and more secure than AES-GCM.

RFC 7253 was published in 2014. OCB also won the CAESAR competition
along with AEGIS.

It's been implemented in OpenSSL and other libraries for years.

So, why isn't everybody using it instead of GCM? And why don't we
have it in Zig already?

The sad reason for this was patents. GCM was invented only to work
around these patents, and for all this time, OCB was that nice
thing that everybody knew existed but that couldn't be freely used.

That just changed. The OCB patents are now abandoned, and OCB's
author just announced that OCB was officially public domain.
2021-02-28 20:40:49 -08:00
daurnimator
1f17221bc4 std: add sendmsg 2021-02-28 21:57:43 +02:00
Frank Denis
0423f0f7d8 std/crypto/aes: fix AES {encrypt,decrypt}Wide
These functions are  not used by anything yet, but run the last
round only once.
2021-02-28 21:55:58 +02:00
Frank Denis
b959029f88 std/crypto/benchmark: update format strings
Use the s formatter to format strings.
2021-02-28 21:55:24 +02:00
LemonBoy
566adc2510 std: Swap arguments in Thread.spawn
Beside the new order being consistent with the ThreadPool API and making
more sense, this shuffling allows to write the context argument type in
terms of the startFn arguments, reducing the use of anytype (eg. less
explicit casts when using comptime_int parameters, yay).

Sorry for the breakage.

Closes #8082
2021-02-28 14:03:19 +01:00
daurnimator
d4af35b3fe HashMap.put returns !void, not a !bool 2021-02-27 13:11:47 +02:00
Andrew Kelley
490654c332 std.ascii: add lessThanIgnoreCase and orderIgnoreCase
For sorting ascii strings, case insensitively.
2021-02-27 01:21:01 -07:00
Andrew Kelley
3f844cba0b std.zig.fmt escaped string formatting recognizes single quote style
This introduces {'} to indicate escape for a single-quoted string,
and {} to indicate escape for a double quoted string.

Without this, there would be unnecessary \' inside double quoted
strings, and unnecessary \" inside single quoted strings.

Motivated by the llvm12 branch, in the new tool I am writing for
updating target CPU features.
2021-02-27 00:27:53 -07:00
Andrew Kelley
4360f45d7f std.os: remove special case for haiku
This is an accident from a merge conflict introduced in
7edb204edf.

The new pipe2 code I believe is supposed to work for all posix-like
systems. If haiku needs special handling here, it should be
re-introduced.
2021-02-25 17:42:14 -07:00
Andrew Kelley
37a1d08de2 haiku: minor fixups
* no isHaiku() function since there is not more than one os tag that
   this applies to.
 * clean up some control flow into a switch
 * add some TODO comments to investigate panics that suspiciously look
   like they should be compile errors (see #363)
2021-02-25 16:54:32 -07:00
Al Hoang
96a08c1698 initial support for haiku defer debug 2021-02-25 16:41:42 -07:00
Al Hoang
c17396691c initial support for haiku sync update
* add cpu count
* use haiku find_directory
* add definitions and exports for building in haiku
2021-02-25 16:41:42 -07:00