Commit Graph

4029 Commits

Author SHA1 Message Date
ZapAnton
e94bbc2237 std.testing: Added newline to the error messages
Added newline to every `std.debug.print` message.
Closes https://github.com/ziglang/zig/issues/8777
2021-05-15 01:27:39 -04:00
Andrew Kelley
2dcec42b74
Merge pull request #8757 from Snektron/spirv-stuff
SPIR-V: Features + some other stuff
2021-05-14 17:02:51 -04:00
viri
612ad779bb
std: rework math.scalbn (#8733)
* std: fix overflow in math.scalbn32

* std: rewrite math.scalbn to be generic

* std: support f128 in math.isNormal

* std: enable f128 tests in math.scalbn
2021-05-14 16:15:53 -04:00
Andrew Kelley
114c6612cb
Merge pull request #8764 from mattbork/json-usefirst
Fix duplicate_field_behavior UseFirst for parse in json.zig
2021-05-14 15:32:32 -04:00
Andrew Kelley
826d833416
Merge pull request #8746 from koachan/sparc64-fixes
Various Linux/SPARCv9 fixes
2021-05-14 15:21:17 -04:00
Sahnvour
2d4d4baa42 std.hash_map: use 7 bits of metadata instead of 6
we only effectively need 1 control bit to represent 2 special states for
the metadata (free and tombstone)
this should reduce the number of actual element equality tests, but since
it's very low already, the impact is negligible
2021-05-14 15:15:55 -04:00
LemonBoy
5185b5619a compiler-rt: Fix signedness mismatch in f128 mul impl
The `1 - shift` expression was computed using small unsigned types and
then casted to i32, producing either an underflow error or an incorrect
result.

Reported by `@notviri` in #8733
2021-05-14 15:11:54 -04:00
Robin Voetter
98dc8eb7d9 SPIR-V: Add generated SPIR-V features 2021-05-14 19:49:32 +02:00
Robin Voetter
fa3afede58 SPIR-V: Set default ofmt to spirv 2021-05-14 19:49:32 +02:00
Matthew Borkowski
11fd2aa767 fix logic for duplicate comptime fields and avoid freeing comptime fields in parseFree and parseInternal 2021-05-14 01:51:39 -04:00
Andrew Kelley
173142cc36
Merge pull request #8611 from shachaf/precedence
parser: Use an operator precedence table
2021-05-13 17:40:03 -04:00
Jakub Konka
1b222cb1ff start.zig: export main with strong linkage
Unmarks `_main` as weak symbol making it global (the entire linked
program) in scope.
2021-05-13 17:24:32 -04:00
Jakub Konka
402264ab0e Add experimental Darling support for cross testing macOS
* for cross testing stage2 tests, we use `darling shell` command
  since the path to the tested binary is relative to cwd
* for the `zig test` command, we simply use `darling` since the
  path to the binary is absolute
2021-05-13 20:31:33 +02:00
Matthew Borkowski
cadb84b3ac fix duplicate_field_behavior UseFirst in json.zig 2021-05-13 09:43:55 -04:00
Matthew Borkowski
e902c19c0e
std/json: Fix premature closing brace being considered valid JSON
return error from StreamingParser when reading closing brace when expecting value for an object key
2021-05-13 11:11:28 +02:00
Andrew Kelley
799d1f0d36 build system: fix wrong glibc dir passed to qemu for i386
Without this, and with `-Denable-qemu -Denable-foreign-glibc`,
i386-linux-gnu tests failed because the `-L` path passed to qemu
was "i386-linux-gnu" (nonexistent) rather than "i686-linux-gnu".

Fixes std lib and behavior tests when using these options to enable
test coverage with cross compiled glibcs.
2021-05-12 20:34:54 -07:00
Koakuma
90a54f06e5 Add a comment to explain the alignment directive 2021-05-13 06:18:51 +07:00
Matthew Borkowski
40a47eae65 fix shrinkAndFree and remove shrinkRetainingCapacity in PriorityQueue and PriorityDequeue 2021-05-12 18:33:25 -04:00
Andrew Kelley
43da102920
Merge pull request #8698 from ifreund/scanZ
std/mem: add sliceTo(), deprecate spanZ(), lenZ()
2021-05-12 18:15:36 -04:00
LemonBoy
893a428656 stage2: Drop LLVM's host CPU detection method as fallback
The CPU detection code is nearly at feature parity, we do support
detecting the native CPU on Sparc systems and macos, our ARM/AArch64
model list is quite comprehensive and so is our PPC one.

The only missing pieces are:
- ARM32 detection on Darwin hosts (I don't think anybody is planning on
  running the compiler on a old-ass iPhone)
- s390x detection on Linux hosts, this can be easily added at a later
  stage.
2021-05-12 14:03:59 -04:00
Koakuma
9e67c062c4 Add missing f128 compiler-rt shim 2021-05-12 20:13:29 +07:00
Isaac Freund
cd7b5a3718
std/mem: add sliceTo(), deprecate spanZ(), lenZ()
The current spanZ() function will not scan for a 0 terminator if the
type is not 0 terminated. This encourages using 0 terminated array
types to bind C arrays which hold 0 terminated strings. However, this is
a big footgun as nothing in the C type system guarantees there to be a
0 terminator at the end of the array and if there is none this becomes
Illegal Behavior in Zig.

To solve this, deprecate spanZ() and lenZ(), adding a new sliceTo()
function that always scans for the given terminator even if the type is
not sentinel terminated.
2021-05-12 11:24:49 +02:00
Koakuma
f24d0fbb07 Remove SPARC pthreadtypes-arch.h to match upstream glibc
This is only a temporary measure, we need to properly update the bundled glibc.
2021-05-12 14:54:13 +07:00
Koakuma
5dd6f9616e Fix linux dirent64 buffer align directive 2021-05-12 14:52:53 +07:00
LemonBoy
e260cfae85 stage2: Add CPU feature detection for macos
This is mostly meant to detect the current and future AArch64 core types
as the x86 part is already taken care of with OS-independent machinery.
2021-05-12 09:43:49 +02:00
Koakuma
6e5330ee38 Define ENOTSUP for SPARC 2021-05-12 14:23:08 +07:00
Michael Dusan
30ace64fc4 bsd: detect os version
- netbsd, dragonly: use sysctlbyname
- openbsd: use sysctl
- updated default semver ranges
2021-05-11 22:05:08 -04:00
Isaac Freund
e6881d4373
std/json: fix previous commit for std.testing changes 2021-05-11 23:09:25 +02:00
Matthew Borkowski
1b87d45494 fix a double free in parse when duplicate_field_behavior is UseLast and a leak in parse when allocating a single item 2021-05-11 22:54:02 +02:00
Isaac Freund
c036957521
std.meta.Elem: support all optional types 2021-05-11 22:22:21 +02:00
Andrew Kelley
ace5714551
Merge pull request #8705 from LemonBoy/libc-fix
32bit glibc fixes
2021-05-11 15:15:00 -04:00
Andrew Kelley
c3d4733a00 test runner: avoid an "out of memory" error return trace entry
The long term solution to this will be #1923
2021-05-11 11:47:22 -07:00
Andrew Kelley
65d279bc05 test runner: print error return trace after failed test 2021-05-11 10:50:17 -07:00
LemonBoy
8bb58fb428 std: Fix offset param splitting for preadv/pwritev
The kernel interface expects the offset as a low+high pair even on BE
systems.
2021-05-11 15:49:53 +02:00
Matthew Borkowski
75ed835d08 fix AutoArrayHashMap's store_hash logic 2021-05-11 16:14:23 +03:00
LemonBoy
780f510ac0 std: Fix fallocate offset type 2021-05-11 12:33:48 +02:00
LemonBoy
c065e12dbe std: Add more tests, fix broken code
It turns out that nothing in the test suite was exercising
preadv/pwritev and so the previous commits silently broke them.

Adding tests revealed readvAll and preadvAll were also broken and not
covered by any test.
2021-05-11 12:33:48 +02:00
LemonBoy
31f1cc9a0d std: Harmonize use of off_t between libc and Zig impls
Let's follow the libc/kernel convention and use an i64 for offsets, we
bitcast as needed and avoid the useless conditional casts.
2021-05-11 12:33:48 +02:00
LemonBoy
f4a05286d3 std: Fix cast that's sometimes invalid 2021-05-11 12:33:48 +02:00
LemonBoy
679876ba72 c: Fix prototypes for bcmp and memcmp
They return c_int and not isize.
2021-05-11 12:33:47 +02:00
LemonBoy
a909db6aea std: Prefer 64bit libc functions where possible
While musl decided to hard-wire off_t to a 64bit quantity, glibc is much
older and defaults to 32bit offsets and offers some -64 suffixed
versions of I/O functions.

There's a weird mix-up of types: sometimes off_t is used, sometimes not,
sometimes it's defined as a signed quantity and sometimes as an unsigned
one, but we'll sort this problem later.
2021-05-11 12:33:47 +02:00
LemonBoy
28a9e4c4aa libc: Add workaround for #4926
This change was cherry-picked from an updated version of the sysdep
folder contents, we're still shipping an outdated and incomplete set of
files.
2021-05-11 12:33:47 +02:00
Andrew Kelley
55d235dc38
Merge pull request #8711 from lithdew/master
std/os, x/os/socket: windows support, socket helpers, getpeername()
2021-05-10 19:00:53 -04:00
jacob gw
24dfa61236 stage1: remove outdated error message regarding #447 2021-05-10 21:00:10 +02:00
lithdew
0d0edd23a8 std/os: add missing sockaddr_storage defs 2021-05-10 19:22:31 +09:00
lithdew
e652595f2a std/os: fix sockaddr_storage padding size 2021-05-10 19:22:31 +09:00
lithdew
6d41e08664 x/os, os: fix setsockopt on windows, simplify Socket.setOption error set 2021-05-10 19:22:31 +09:00
lithdew
6cb6edb6f6 std/os/windows/ws2_32: add missing FIONBIO constant 2021-05-10 19:22:31 +09:00
lithdew
77f8a9ae22 x/os/socket, std/os/windows: implement loading winsock extensions
Implement loading Winsock extensions.

Add missing Winsock extension GUID's.

Implement readVectorized() for POSIX sockets and
readVectorized() / writeVectorized() for Windows
sockets.

Inverse how mixins are used to implement platform-independent syscalls
for the std.x.os.Socket abstraction. This cleans up the API as suggested
by @komuw.
2021-05-10 19:22:31 +09:00
lithdew
3d946ef5eb x/os, x/net, os:, fix typos/errors, add missing constants/docs
Add missing constants to ws2_32 such as SIO_BASE_HANDLE.

Made all declared constants in ws2_32 comptime_int, and fixed a few
broken constants (i.e. GUID's).

Fixed a few syscalls not having callconv(WINAPI) in ws2_32.

Fixed a typo in std.x.net.tcp.Client.

Removed unnecessary @alignCast's for socket addresses in
std.x.net.Socket.

Added a warning on using timeout methods for std.x.net.Socket.

Fixed compilation error spotted by CI in std.os that references
std.os.windows.ws2_32.SD_RECEIVE.

Renamed std.x.os.Socket.setOption()'s parameter `name: u32` to `code:
u32`.
2021-05-10 19:22:31 +09:00