200 Commits

Author SHA1 Message Date
Andrew Kelley
f4a249325e stage1: avoid anytype fields for type info
prerequisite for #10705
2022-02-01 18:10:19 -07:00
Andrew Kelley
75bbc74d56 a small crusade against std.meta.declarations 2022-01-31 22:25:49 -07:00
Meghan Denny
b7ba728929 std: add meta.DeclEnum 2022-01-20 10:54:45 +02:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Lewis Gaul
bc3e86c4b7 Add std.meta.Float, alongside std.meta.Int 2021-11-22 21:30:20 -05:00
InKryption
eeb8629bea Use debug.assert instead of testing.expect.
`testing.expect` and friends are intended to be used only in tests; this change reflects that intention.
2021-10-29 20:01:59 +00:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Robin Voetter
c5945467ac Address Spaces: Pointer and function info in @Type 2021-09-20 02:29:04 +02: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
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Veikka Tuominen
699b6cdf01 translate-c: move utility functions to a separate namespace 2021-06-14 20:13:34 +03:00
Veikka Tuominen
029fe6c9ab meta.cast: handle casts from negative ints to ptrs 2021-06-13 16:53:01 +03:00
Evan Haas
45212e3b33 translate-c: Implement flexible arrays
Fixes #8759
2021-06-11 21:31:39 +03:00
Andrew Kelley
c9cc09a3bf Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux.zig
 * lib/std/os/windows/bits.zig
 * src/Module.zig
 * src/Sema.zig
 * test/stage2/test.zig

Mainly I wanted Jakub's new macOS code for respecting stack size, since
we now depend on it for debug builds able to pass one of the test cases
for recursive comptime function calls with `@setEvalBranchQuota`.

The conflicts were all trivial.
2021-05-12 16:41:20 -07:00
Isaac Freund
c036957521
std.meta.Elem: support all optional types 2021-05-11 22:22:21 +02:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
474ade88b5 std: fix compile errors found by stage2 AstGen 2021-04-29 20:33:29 -07:00
Andrew Kelley
df24ce52b1 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
Andrew Kelley
2fc6b347ec
Merge pull request #8616 from LemonBoy/fn-align
Function pointer alignment
2021-04-25 19:12:06 -04:00
Andrew Kelley
6f61594692
Merge pull request #8496 from xackus/isError
std.meta: add isError
2021-04-25 13:27:44 -04:00
LemonBoy
19cec0db1e std: Make met.alignment work on more types
Make it return the correct value for function types and optional
pointers.
2021-04-25 16:49:21 +02:00
Andrew Kelley
e86cee258c Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted the change that makes `suspend;` illegal in the
parser.
2021-04-24 10:44:41 -07:00
Andrew Kelley
507a8096d2 std: fix compile errors caught by stage2 AstGen
* `comptime const` is redundant
 * don't use `extern enum`; specify a tag type.
   `extern enum` is only when you need tags to alias. But aliasing tags
   is a smell. I will be making a proposal shortly to remove `extern enum`
   from the language.
 * there is no such thing as `packed enum`.
 * instead of `catch |_|`, omit the capture entirely.
 * unused function definition with missing parameter name
 * using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
Evan Haas
d4d21dd46d translate-c: better handling of int -> enum casts
In std.meta.cast when casting to an enum type from an integer type, first
do a C-style cast from the source value to the tag type of the enum.
This ensures that we don't get an error due to the source value not being
representable by the enum.

In transCCast() use std.meta.cast instead of directly emitting the cast
operation since the enum's underlying type may not be known at translation
time due to an MSVC bug, see https://github.com/ziglang/zig/issues/8003

Fixes #6011
2021-04-15 22:46:22 -04:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
xackus
89c41f30c3 zig fmt 2021-04-11 20:16:17 +02:00
xackus
a5007d819a std.meta: add isError 2021-04-11 16:26:29 +02:00
xackus
2d2316f5c0 translate-c: fix meta.cast to ?*c_void 2021-04-08 08:33:26 +03:00
Evan Haas
8de14a98a6 translate-c: Add support for vector expressions
Includes vector types, __builtin_shufflevector, and __builtin_convertvector
2021-04-06 11:22:27 -07:00
xackus
9a94415680 translate-c: improve std.meta.cast 2021-03-17 00:05:42 +02: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
Andrew Kelley
5f35dc0c0d zig fmt the std lib 2021-02-24 21:29:23 -07:00
Tadeo Kondrak
0b5f3c2ef9
Replace @TagType uses, mostly with std.meta.Tag 2021-01-30 22:26:44 +02:00
Tadeo Kondrak
b7767eb834
std.meta: rename TagPayloadType to TagPayload 2021-01-30 13:19:52 +02:00
Tadeo Kondrak
68ec54f386
std.meta: rename TagType to Tag 2021-01-30 13:19:52 +02:00
Martin Wickham
3d4eeafb47 Fill out more cases for std.meta.sizeof 2021-01-30 11:13:20 +02:00
daurnimator
9c97a07f18 std: have std.meta.fieldInfo take an enum rather than a string 2021-01-01 15:48:46 -07:00
daurnimator
73bf2e1525 std: add std.meta.FieldEnum 2021-01-01 15:48:04 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Andrew Kelley
53987c932c std.crypto.random: introduce fork safety
Everybody gets what they want!

 * AT_RANDOM is completely ignored.
 * On Linux, MADV_WIPEONFORK is used to provide fork safety.
 * On pthread systems, `pthread_atfork` is used to provide fork safety.
 * For systems that do not have the capability to provide fork safety,
   the implementation falls back to calling getrandom() every time.
 * If madvise is unavailable or returns an error, or pthread_atfork
   fails for whatever reason, it falls back to calling getrandom() every
   time.
 * Applications may choose to opt-out of fork safety.
 * Applications may choose to opt-in to unconditionally calling
   getrandom() for every call to std.crypto.random.fillFn.
 * Added `std.meta.globalOption`.
 * Added `std.os.madvise` and related bits.
 * Bumped up the size of the main thread TLS buffer. See the comment
   there for justification.
 * Simpler hot path in TLS initialization.
2020-12-18 15:54:01 -07:00
Vexu
7e30e83900
small fixes and zig fmt 2020-12-09 13:54:26 +02:00
Jonathan Marler
48660371a2 std.meta: add assumeSentinel 2020-11-29 10:36:02 -08:00
LemonBoy
a2e9554699 std: Add test for meta.declarations on opaque{} 2020-11-21 14:03:49 -08:00
Isaac Freund
a5691ee363 std.meta.declarations: support opaque {} 2020-11-19 15:04:38 -08:00
Tadeo Kondrak
25ec2dbc1e Add builtin.Signedness, use it instead of is_signed 2020-11-19 18:59:21 +02:00
Alexandros Naskos
252924ae33 Added std.meta.fieldNames 2020-11-18 13:16:56 +02:00