Commit Graph

12880 Commits

Author SHA1 Message Date
joachimschmidt557
345ac53836
stage2 ARM: Implement basic integer multiplication 2021-03-02 00:14:56 +01: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
jacob gw
58b14d01ae stage2: remove value field from error
This saves memory and from what I have heard allows threading
to be easier.
2021-02-28 22:01:13 +02:00
daurnimator
1f17221bc4 std: add sendmsg 2021-02-28 21:57:43 +02:00
Evan Haas
294ee1bbc9 translate-c: add limited OffsetOfExpr support
Add support for OffsetOfExpr that contain exactly 1 component, when that component
is a field.

For example, given:

```c
struct S {
  float f;
  double d;
};
struct T {
  long l;
  int i;
  struct S s[10];
};
```

Then:
```c
offsetof(struct T, i)       // supported
offsetof(struct T, s[2].d)  // not supported currently
```
2021-02-28 21:56:57 +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
d3d3e55fae langref: Update usage of Thread.spawn() 2021-02-28 17:01:30 +01: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
Michael Dusan
e65b6d99ac std.zig.fmtEscapes: update impacted test 2021-02-27 12:53:49 -07: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
4a548002af translate-c: upgrade to new std.zig.fmtEscapes API
fixes regressions from previous commit
2021-02-27 01:20:19 -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
Evan Haas
0816981561 translate-c: add typeof support 2021-02-25 22:33:42 -08:00
Andrew Kelley
fd208d9d59 stage2: implement the error_value AST tag 2021-02-25 18:21:22 -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
g-w1
153c97ac9e improve stage2 to allow catch at comptime:
* add error_union value tag.
* add analyzeIsErr
* add Value.isError
* add TZIR wrap_errunion_payload and wrap_errunion_err for
  wrapping from T -> E!T and E -> E!T
* add anlyzeInstUnwrapErrCode and analyzeInstUnwrapErr
* add analyzeInstEnsureErrPayloadVoid:
* add wrapErrorUnion
* add comptime error comparison for tests
* tests!
2021-02-25 16:41:16 -08:00
Andrew Kelley
7edb204edf
Merge pull request #7546 from hoanga/haiku-support
initial support for haiku
2021-02-25 16:00:00 -08: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
Al Hoang
6b0372229d initial support for haiku continue clean up
* remove unused definitions
* setup os specific blocks
2021-02-25 16:41:42 -07:00
Al Hoang
025635c3f8 initial support for haiku past stage0 2021-02-25 16:41:42 -07:00
joachimschmidt557
297eabd4ac stage2 ARM: Save callee-saved registers
Add a new allocated_registers bitmap to keep track of all callee-saved
registers allocated during generation of this function.

Function(.arm).gen uses this data to generate instructions in the
function prologue and epilogue to push and pop these registers
respectively.
2021-02-25 22:27:19 +02:00
Hubert Jasudowicz
3c0238e731 std/build: Add support for LTO configuration 2021-02-25 22:25:42 +02:00
Evan Haas
4f11a88b9f translate-c: Add support for pointer subtraction
When two pointers are subtracted, both shall point to elements of the
same array object, or one past the last element of the array object;
the result is the difference of the subscripts of the two array elements.

The size of the result is implementation-defined, and its type
(a signed integer type) is ptrdiff_t defined in the <stddef.h> header.
If the result is not representable in an object of that type,
the behavior is undefined.

See C Standard, §6.5.6 [ISO/IEC 9899:2011]

Fixes #7216
2021-02-25 22:24:11 +02:00
LemonBoy
53cc63f0c9 std: Clear old memory on free
Re-enable the clear-on-free step, it was previously disabled due to
translate-c using freed memory.
2021-02-25 22:20:30 +02:00
Andrew Kelley
449f4de382 zig fmt src/ 2021-02-24 21:54:23 -07:00
Andrew Kelley
9b8a94265a zig fmt: fix extern function with missing param name
Regressed in d7049fc8e0.
2021-02-24 21:50:57 -07:00
Andrew Kelley
5f35dc0c0d zig fmt the std lib 2021-02-24 21:29:23 -07:00
Andrew Kelley
d7049fc8e0
Merge pull request #7920 from ziglang/ast-memory-layout
Rework AST memory layout for better memory usage and performance
2021-02-24 18:49:07 -08:00
Andrew Kelley
9ada7638a5 zig fmt: function with labeled block as return type 2021-02-24 16:42:46 -07:00
Andrew Kelley
c79ee1fc8d build.zig: expose a strip option 2021-02-24 16:36:27 -07:00
Andrew Kelley
8e6c2b7a47 Merge remote-tracking branch 'origin/master' into ast-memory-layout 2021-02-24 15:08:23 -07:00
Andrew Kelley
38441b5eab MultiArrayList: use @memcpy as a workaround
Reverts bf642204b3 and uses a different
workaround, suggested by @LemonBoy.

There is either a compiler bug or a design flaw somewhere around here.
It does not have to block this branch, but I need to understand exactly
what's going on here and make it so that nobody ever has to run into
this problem again.
2021-02-24 12:49:12 -07:00
Isaac Freund
52c45bf44d
zig fmt: rework single statement if/while/for indentation
This approach properly handles nesting unlike the approach in the
previous commit.
2021-02-24 17:28:29 +01:00
Josh Wolfe
8b9434871e
Avoid concept of a "Unicode character" in documentation and error messages (#8059) 2021-02-24 08:26:13 -05:00
Isaac Freund
371b21bdfb
zig fmt: fix comment indent after multiline single statement if/while/for 2021-02-24 13:46:11 +01:00
Isaac Freund
15c7c6ab97
zig fmt: handle comments in switch case value list 2021-02-24 12:29:17 +01:00
Isaac Freund
1b8eca030e
zig fmt: fix firstToken() for switch_case 2021-02-24 12:14:15 +01:00
Andrew Kelley
db4c15be50 zig fmt: respect extra newline between fn and pub usingnamespace 2021-02-23 23:01:16 -07:00
Andrew Kelley
bf642204b3 std.MultiArrayList: add workaround for LLVM bug 2021-02-23 22:24:59 -07:00
Andrew Kelley
05f304807f zig fmt: add 3 more disabled failing test cases
Found by running `zig fmt` on the std lib.
2021-02-23 18:48:01 -07:00
Andrew Kelley
4420fe97be zig fmt: for loop with ptr payload and index 2021-02-23 18:33:13 -07:00
Andrew Kelley
988f1c6a6f zig fmt: fn proto end with anytype and comma
also

zig fmt: space after top level doc comment
2021-02-23 18:23:49 -07:00