Commit Graph

447 Commits (270933b1e997c91a9c2d28b6896d625c0ae1b163)

Author SHA1 Message Date
Andrew Kelley c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
Andrew Kelley 36bade5c56
fixups, and modify std.mem.join and std.os.path.resolve API
* zig fmt
 * std.mem.join takes a slice of slices instead of var args
 * std.mem.join takes a separator slice rather than byte,
   and always inserts it. Previously it would not insert the separator
   if there already was one, violating the documented behavior.
 * std.mem.join calculates exactly the correct amount to allocate
   and has no call to allocator.shrink()
 * bring back joinWindows and joinPosix and the corresponding tests.
   it is intended to be able to call these functions from any OS.
 * rename std.os.path.resolveSlice to resolve (now resolve takes
   a slice of slices instead of var args)
2019-02-07 00:42:41 -05:00
Andrew Kelley c804ae2d6b
Merge branch 'zig-backport-std.os.path' of https://github.com/kristate/zig into kristate-zig-backport-std.os.path 2019-02-06 22:53:34 -05:00
Andrew Kelley 8a5d3e2eaf
Merge pull request #1924 from ziglang/tls
Implement Thread Local Variables
2019-02-06 20:21:13 -05:00
Andrew Kelley 89ffb58197 implement Thread Local Storage on Windows 2019-02-06 18:32:41 -05:00
Andrew Kelley d2602b442e
require running std lib tests coherently
this should actually improve CI times a bit too

See the description at the top of std/os/startup.zig (deleted in this
commit) for a more detailed understanding of what this commit does.
2019-02-06 14:32:20 -05:00
Andrew Kelley b1775ca168
thread local storage working for linux x86_64 2019-02-06 13:48:04 -05:00
Sahnvour 6860db66fe Typo: use the joined path to try executables available from PATH. 2019-02-05 23:13:17 +01:00
Sahnvour a9faace8b4 Notify failure to create a process when the executable is not found even in PATH. 2019-02-05 23:12:54 +01:00
Andrew Kelley 67bd45f0cf
adjustments to std.mem split / separate
* rename std.mem.split to std.mem.tokenize
 * add future deprecation notice to docs
 * (unrelated) add note to std.os.path.resolve docs
 * std.mem.separate - assert delimiter.len not zero
 * fix implementation of std.mem.separate to respect the delimiter
 * separate the two iterators to different structs
2019-02-04 15:24:06 -05:00
Andrew Kelley f44ce7836a
Merge branch 'zig-backport-std.mem.separate' of https://github.com/kristate/zig into kristate-zig-backport-std.mem.separate 2019-02-04 13:29:17 -05:00
Andrew Kelley dfbc063f79
`std.mem.Allocator.create` replaced with better API
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`.

The problem with the previous API is that even after copy elision,
the initalization value passed as a parameter would always be a copy.
With the new API, once copy elision is done, initialization
functions can directly initialize allocated memory in place.

Related:
 * #1872
 * #1873
2019-02-03 16:13:28 -05:00
Andrew Kelley 9b8e23934b
introduce --single-threaded build option
closes #1764

This adds another boolean to the test matrix; hopefully it does not
inflate the time too much.

std.event.Loop does not work with this option yet. See #1908
2019-02-01 18:05:54 -05:00
Andrew Kelley bfc1772d8e fixups 2019-02-01 12:22:21 -05:00
Andrew Kelley 8d3eb25e92 Merge branch 'windows-mutex' of https://github.com/emekoi/zig into emekoi-windows-mutex 2019-02-01 10:21:16 -05:00
Andrew Kelley 7a4ed10981 darwin: fix incorrect timeval struct type
closes #1648

I also added some more extern functions for darwin time functions,
although nothing depends on them currently.
2019-01-31 18:57:53 -05:00
Andrew Kelley ecb0cb661a
darwin time code: don't cast to int until the end
See #1648
2019-01-30 02:53:59 -05:00
emekoi 3ff9ab332c fixed type signature 2019-01-11 09:56:37 -06:00
emekoi 51fff9fa82 fixed initializer and typos 2019-01-11 09:56:36 -06:00
emekoi 35d93d22db removed nullables 2019-01-11 09:56:36 -06:00
emekoi 9385127052 changed pointer types 2019-01-11 09:56:35 -06:00
emekoi bb31695fbf fixed mutex on windows 2019-01-11 09:56:35 -06:00
emekoi 207fa3849c moved to InitializeCriticalSection to init 2019-01-11 09:56:34 -06:00
emekoi 25d7f5b654 switching back to EnterCriticalSection 2019-01-11 09:56:34 -06:00
emekoi aaae2f5705 switching from EnterCriticalSection to TryEnterCriticalSection 2019-01-11 09:56:33 -06:00
emekoi b61bce254c added mutex for windows 2019-01-11 09:56:32 -06:00
Marcio 5f26d1dddb freebsd: fix wrong call to clock_getres (#1871)
Reported-by: daurnimator
2019-01-05 13:34:47 -05:00
Marcio Giaxa 5c2a1055a0 freebsd: add sockaddr structs 2019-01-04 16:31:57 -05:00
Marcio Giaxa 4d9547ff2e freebsd: implement clock related functions
- clock_gettime
 - clock_getres
2019-01-04 16:31:57 -05:00
Marcio Giaxa 1e781a30f6 freebsd: add clock const definitions 2019-01-04 16:31:57 -05:00
Andrew Kelley d8b6fa9134
Merge pull request #1859 from mgxm/fbsd2
Progress towards tier 1 support for FreeBSD x86_64
2018-12-29 12:49:23 -05:00
Andrew Kelley a918ce26b8
fixups 2018-12-26 15:25:54 -05:00
Marcio Giaxa 52be7d7404 freebsd: fix flags for opening files
Prior to this fix, the compare-outputs test suite was showing a strange
behavior, the tests always stopped between tests 6-8 and had a stack track
similar to each other.

```
Test 8/68 compare-output multiple files with private function (ReleaseSmall)...OK
/usr/home/mgxm/dev/zig/zig-cache/source.zig:7:2: error: invalid token: '&'
}&(getStdOut() catch unreachable).outStream().stream;
 ^
The following command exited with error code 1:

```

With the wrong O_* flags, the source code was being written in append mode which
resulted in an invalid file

```zig
use @import("foo.zig");
use @import("bar.zig");

pub fn main() void {
	foo_function();
	bar_function();
}&(getStdOut() catch unreachable).outStream().stream;
	stdout.print("OK 2\n") catch unreachable;
}

fn privateFunction() void {
	printText();
}
```
2018-12-24 11:45:55 -02:00
Marcio Giaxa de473d4423
freebsd: implement std.os.time.sleep 2018-12-24 10:27:08 -02:00
nebulaeonline fdea12b2d9 msvc subsystem option handling; added uefi os type 2018-12-23 22:44:02 -05:00
Marcio Giaxa 682815f6e9
freebsd: remove syscall and use libc
Use libc interface for:
 - getdents
 - kill
 - openat
 - setgid
 - setuid
2018-12-23 23:30:31 -02:00
Marcio Giaxa 773bf80133 Merge branch 'master' into fbsd2 2018-12-23 23:21:59 -02:00
Andrew Kelley 0eba5b6744
I observed open() return EBUSY on linux
when trying to open for writing a tty fd that is already opened with
screen
2018-12-21 19:50:21 -05:00
Marcio Giaxa a6f33e3dc5
freebsd: add realpath to freebsd/index.zig 2018-12-20 21:05:31 -02:00
Marcio Giaxa 46a0f60e4c
freebsd: use realpath() to resolve symbolic links 2018-12-20 20:57:58 -02:00
Greg V 76efc462e7 Add preadv/pwritev on FreeBSD 2018-12-20 23:55:44 +03:00
Marcio Giaxa 9900f94afe freebsd: use sysctl to get the current executable path
FreeBSD doesn't mount procfs as default on the base system, so we can't
depend on it to get the current path, In this case, we use sysctl(3) to
retrieves the system information and get the same information.

 - CTL_KERN: High kernel limits

 - KERN_PROC: Return selected information about specific running
   processes.

 - KERN_PROC_PATHNAME: The path of the process

 - Process ID: a process ID of -1 implies the current process.
2018-12-19 18:42:00 -02:00
Marcio Giaxa 1811e7e6c9 freebsd: remove getrandom dependency from libc
The system call getrandom(2) just landed on FreeBSD 12, so if we want to
support some earlier version or at least FreeBSD 11, we can't depend on
the system call.
2018-12-19 18:42:00 -02:00
Marcio Giaxa 11ced4f99d freebsd: use libc interface instead system calls
Remove all syscalls references

 * dup2()
 * chdir()
 * execve()
 * fork()
 * getcwd()
 * isatty()
 * readlink()
 * mkdir()
 * mmap()
 * munmap()
 * read()
 * rmdir()
 * symlink()
 * pread()
 * write()
 * pwrite()
 * rename()
 * open()
 * close()
 * lseek()
 * exit()
 * unlink()
 * waitpid()
 * nanosleep()
 * setreuid()
 * setregid()
 * raise()
 * fstat()
 * pipe()
 * added pipe2() extern c fn
2018-12-19 18:42:00 -02:00
Marcio Giaxa 0273fbf710 freebsd: add access 2018-12-19 18:42:00 -02:00
Marcio Giaxa 5ea37f6e8c freebsd: add getdirentries 2018-12-19 18:41:59 -02:00
Marcio Giaxa 666b153144 freebsd: remove syscall files 2018-12-19 18:41:40 -02:00
Andrew Kelley fff6e47125
fixups 2018-12-13 17:13:10 -05:00
Andrew Kelley 457f03e37d
Merge branch 'windows-wide-imports' of https://github.com/suirad/zig into suirad-windows-wide-imports 2018-12-13 15:57:24 -05:00
Andrew Kelley 7417f2e4b3
freebsd: fix issues with syscalls 2018-12-13 00:33:13 -05:00