Commit Graph

4513 Commits

Author SHA1 Message Date
Jonathan Marler
010ca69864
add functions to decode an epoch timestamp (#9040)
* add functions to decode an epoch timestamp

The code added here is alternative to the libc gmtime function. This function takes a unix epoch timestamp and decodes it into things like the year/day/time/etc. I looked at various libc implementations to see how it was implemented and this appears to be correct. I reorganized it so that applications can choose which data they need rather than calcualting it all in a single function. The data structures layout the order of operations required to decode various things like the year/month or time of day.

* set Month.jan to 1 instead of 0 to avoid +1 in conversion to numeric

* add another test

* remove unnecessary comptimeMod
2021-09-14 19:02:23 +03:00
Jakub Konka
85f065a511
Merge pull request #9676 from ziglang/zld-incr
MachO: merges stage1 with self-hosted codepath
2021-09-14 14:20:11 +02:00
Philipp Lühmann
d1908c9f66
zig fmt: Keep callconv(.Inline) on function pointer types
Co-authored-by: Philipp Lühmann <mail@philipp.lu>
2021-09-14 11:36:26 +02:00
Andrew Kelley
5529febab0 stage2: implement Value.copy for structs and unions
The stage2_os hack inside `@import("builtin")` is no longer needed.
2021-09-13 20:11:35 -07:00
Jakub Konka
a38b636045 Merge remote-tracking branch 'origin/master' into zld-incr 2021-09-13 23:40:38 +02:00
lucky
f011f13933
fix missing paths (#9754)
increase bcrypt benchmark rounds

Co-authored-by: lucky <>
2021-09-13 17:31:17 +02:00
Jakub Konka
50e34a063c
Merge pull request #9734 from Andoryuuta/macho-zld-win-filepath
link/include: fix invalid file path concatenation when cross-compiling for Windows -> Mac
2021-09-13 09:04:11 +02:00
Kenta Iwasaki
c4f97d3365 os: usingnamespace fixes for std.x.os.Socket and std.os.TCP
Extract existing constants to do with TCP socket options into a 'TCP'
namespace.

Export 'MSG' and 'TCP' from std.os.{linux, windows} into std.c.

Fix compile errors to do with std.x.os.Socket methods related to setting
TCP socket options.

Handle errors in the case that an interface could not be resolved in an
IPv6 address on Windows. Tested using Wine with the loopback interface
disabled.

Have all instantiations of std.x.os.Socket on Windows instantiate an
overlapped socket descriptor. Fixes the '1ms read timeout' test in
std.x.net.tcp.Client. The test would previously deadlock, as read
timeouts only apply to overlapped sockets.

Windows documentation by default recommends that most instantiations of
sockets on Windows be overlapped sockets (s.t. they may operate in both
blocking or nonblocking mode when operated with WSA* syscalls). Refer to
the documentation for WSASocketA for more info.
2021-09-12 23:36:44 -04:00
Andrew Gutekanst
ffb9891695 Fix same issue with dir/sysroot dir concatenation with includes on Windows 2021-09-12 19:35:03 -04:00
Silver
2118566931 std: publicize ArrayListUnmanaged.allocatedSlice to match ArrayList 2021-09-12 19:32:40 +03:00
Luuk de Gram
9e24727062
Fix compile error for p256 scalar arithmetic (#9715) 2021-09-10 15:41:15 +02:00
lucky
3611487952
reexport crypto/phc_encoding (#9712)
Co-authored-by: lucky <>
2021-09-09 14:25:44 +02:00
Sébastien Marie
175d95b591 openbsd: readapt event loop after usingnamespace changes 2021-09-08 13:40:43 -04:00
Jonathan Marler
375619820e changes to build zig-bootstrap aarch64-windows 2021-09-07 14:27:50 -06:00
Andrew Kelley
d305ba7f2d
Merge pull request #9636 from ehaas/hexfiles
stdlib: Add Intel HEX support to InstallRawStep
2021-09-07 15:12:00 -04:00
Jacob G-W
88e0f81eef plan9: change output executable name
Now object files have the `name.<target char>`
Executables are just `name`
Libs are `name.a`
2021-09-07 15:08:51 -04:00
Sébastien Marie
c2f585e435 openbsd: event loop: use EVFILT_TIMER instead of EVFILT_USER
OpenBSD doesn't implement EVFILT_USER filter for kqueue(2), so we couldn't use that for event loop.

instead, use a EVFILT_TIMER filter with EV_ONESHOT (trigger only once) and delay 0sec (which trigger immediatly).
it fits the usage of EVFILT_USER which is only used to "wakeup" the kevent(2) call from userland.
2021-09-07 14:59:33 -04:00
Andrew Kelley
f1126e854c
Merge pull request #9695 from g-w1/evloop-usingns
std: update event loop for recent usingnamespace changes
2021-09-07 14:58:25 -04:00
Andrew Kelley
a48e5af69d
Merge pull request #9684 from FnControlOption/astgen-string-table
AstGen: use string index as key for string table
2021-09-07 14:52:45 -04:00
Jonathan Marler
fd2c1d8605
Fix building aarch64-windows-gnu by adding missing libc files and compiler_rt functions (#9555)
* fix issue 9519

Added some missing files from mingw

* add missing compiler_rt functions

* finish PR

* add aarch64-windows-gnu to test targets

* add more compiler_rt

* add log2

* add pow

* add modti3
2021-09-07 19:44:21 +03:00
Jacob G-W
738395f9bc std: update event loop for recent usingnamespace changes 2021-09-06 15:16:29 -04:00
Takeshi Yoneda
34671b1d19 stdlib: fix ChildProcess.killPosix
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-09-06 20:10:42 +03:00
FnControlOption
fdf1918b39 std.hash_map: add StringIndexAdapter and StringIndexContext 2021-09-03 06:50:27 -07:00
Andrew Kelley
2264fca03e fix regression on linux with kernel_timespec
I incorrectly assumed that __kernel_timespec was used when not linking
libc, however that is not the case. `std.os.timespec` is used both for
libc and non-libc cases. `__kernel_timespec` is a special struct that is
used only for io_uring.
2021-09-01 17:54:07 -07:00
Andrew Kelley
0932b0d9b3 std.os reorg: regression fixes to stack_t, and std.Thread 2021-09-01 17:54:07 -07:00
Andrew Kelley
1a492d5156 re-apply a commit dropped in this branch due to conflicts
This commit reapplies 4f0aa7d639.
2021-09-01 17:54:07 -07:00
Andrew Kelley
5a4cc24c0e std: dirent is not part of posix 2021-09-01 17:54:07 -07:00
Andrew Kelley
f8dd4b13d6 std.os reorg: more fixes caught by CI 2021-09-01 17:54:07 -07:00
Andrew Kelley
057f0fec33 std.os fixes to get the test suite passing again 2021-09-01 17:54:07 -07:00
Andrew Kelley
8d2acff197 disable slow scrypt tests 2021-09-01 17:54:07 -07:00
Andrew Kelley
cca57042df std: fix regressions from this branch
Also move some usingnamespace test cases from compare_output to
behavior.
2021-09-01 17:54:07 -07:00
Andrew Kelley
3940a1be18 rename std.zig.ast to std.zig.Ast; use top-level fields 2021-09-01 17:54:07 -07:00
Andrew Kelley
a2ff3a13fe std, compiler-rt: remove test names where applicable
Tests with no names are executed when using `zig test` regardless of the
`--test-filter` used. Non-named tests should be used when simply
importing unit tests from another file. This allows `zig test` to find
all the appropriate tests, even when using `--test-filter`.
2021-09-01 17:54:06 -07:00
Andrew Kelley
ca21cad2bf move syntax tests out of behavior tests
parser_test.zig is where the syntax tests go
2021-09-01 17:54:06 -07:00
Andrew Kelley
c05a20fc8c std: reorganization that allows new usingnamespace semantics
The proposal #9629 is now accepted, usingnamespace stays but no longer
puts identifiers in scope.
2021-09-01 17:54:06 -07:00
Andrew Kelley
7884d84315 std.os.windows: reorg to avoid usingnamespace
Down to 19 uses of `usingnamespace`.
2021-09-01 17:54:06 -07:00
Andrew Kelley
b781ef464d std.os: fix FILENO constants mapped to wrong values
yikes!
2021-09-01 17:54:06 -07:00
Andrew Kelley
7f03cfe161 std.os: more reorganization efforts
* std lib tests are passing on x86_64-linux with and without -lc
 * stage2 is building from source on x86_64-linux
 * down to 38 remaining uses of `usingnamespace`
2021-09-01 17:54:06 -07:00
Andrew Kelley
c09ba8796c std.os.linux: remove the "bits" namespace altogether
Now there is only 1 architecture-specific file for Linux kernel bits.
2021-09-01 17:54:06 -07:00
Andrew Kelley
1bbfcb95ab std: reorganize std.c to eliminate usingnamespace
Behavior tests pass on x86_64-linux with -lc
2021-09-01 17:54:06 -07:00
Andrew Kelley
3deda15e21 std.os reorganization, avoiding usingnamespace
The main purpose of this branch is to explore avoiding the
`usingnamespace` feature of the zig language, specifically with regards
to `std.os` and related functionality.

If this experiment is successful, it will provide a data point on
whether or not it would be practical to entirely remove `usingnamespace`
from the language.

In this commit, `usingnamespace` has been completely eliminated from
the Linux x86_64 compilation path, aside from io_uring.

The behavior tests pass, however that's as far as this branch goes. It is
very breaking, and a lot more work is needed before it could be
considered mergeable. I wanted to put a pull requset up early so that
zig programmers have time to provide feedback.

This is progress towards closing #6600 since it clarifies where the
actual "owner" of each declaration is, and reduces the number of
different ways to import the same declarations.

One of the main organizational strategies used here is to do namespacing
with real namespaces (e.g. structs) rather than by having declarations
share a common prefix (the C strategy). It's no coincidence that
`usingnamespace` has similar semantics to `#include` and becomes much
less necessary when using proper namespaces.
2021-09-01 17:54:06 -07:00
Jan Philipp Hafer
81e2034d4a compiler_rt: add __clzdi2 and __clzti2
- structure derived from shift.zig
- rename clzsi2.zig to count0bits.zig
- test cases derived from clzsi2_test.zig

See #1290
2021-09-01 16:15:21 -04:00
Evan Haas
742fe65f3e
stdlib: Add test for generating HEX files.
Co-authored-by: Akbar Dhanaliwala <akbar.dhanaliwala@gmail.com>
2021-09-01 12:21:30 -07:00
Evan Haas
bf0d436087
stdlib: Add Intel HEX support to InstallRawStep
This allows writing HEX files with `exe.installRaw`, where `exe` is a
`LibExeObjStep`. A HEX file will be written if the file extension is `.hex`
or `.ihex`, otherwise a binfile will be written. The output format can be
explicitly chosen with `exe.installRawWithFormat("filename", .hex);`
(or `.bin`)

Part of #2826

Co-authored-by: Akbar Dhanaliwala <akbar.dhanaliwala@gmail.com>
2021-09-01 12:21:22 -07:00
Philip Åkesson
4f0aa7d639 std: Use truncating cast in WIFSTOPPED for Linux, FreeBSD and DragonFly
The intermediate value can be larger than an u16, so @truncate is needed
to match the behavior of musl.
2021-08-31 22:03:54 -04:00
Jakub Konka
50db993119 macho: fix allocating sections within segment when parsing objects 2021-08-31 23:05:01 +02:00
fn ⌃ ⌥
b25e58b0ac
std.hash_map: add getKey methods (#9607) 2021-08-31 00:32:34 -04:00
Lee Cannon
ede47d49eb
Print enum values for build options in help output (#9650) 2021-08-30 21:39:02 -04:00
Boo
ef39725055
Fix float formatting for 0.0 when precision is 0 (#9642) 2021-08-30 13:39:05 -04:00
jdmichaud
49c9975484
zig fmt: respect trailing commas in inline assembly 2021-08-29 11:57:32 +02:00