Commit Graph

567 Commits

Author SHA1 Message Date
Andrew Kelley
fd65cdc55a
fix incorrect Thread.getCurrentId test
Documentation comments copied here:

On Linux, it is possible that the thread spawned with `spawnThread`
finishes executing entirely before the clone syscall completes. In this
case, `std.os.Thread.handle` will return 0 rather than the
no-longer-existing thread's pid.
2019-04-05 16:06:35 -04:00
Andrew Kelley
e4d595a8ba
fix thread local variables for non- position independent code
This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:

"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"

This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.

closes #2063
2019-04-04 01:08:26 -04:00
Andrew Kelley
1d09cdaa6a munmap allows address 0
fixes test suite regression on macOS from previous commit
2019-03-25 16:04:25 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
01fb421031 fix regressions on Windows from previous commit 2019-03-15 18:57:07 -04:00
Andrew Kelley
9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00
Andrew Kelley
20c36949e1
fix target_requires_pic and reloc_mode
disable failing thread local variable test.
see #2063
2019-03-13 23:15:34 -04:00
Andrew Kelley
5046aa9403 fix running things with zig build on Windows
Windows doesn't have rpaths for DLLs so we instead add
search paths to Path environment variable when running
an executable that depends on DLLs built with zig build.
2019-03-09 00:42:14 -05:00
Andrew Kelley
e2f4df6065
std.os.changeCurDir no longer needs an allocator 2019-03-05 18:43:39 -05:00
Andrew Kelley
e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley
67b4de33d2
compile error for import outside package path
closes #2024

there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file

and a corresponding build.zig API:
foo.setMainPkgPath(path)
2019-03-02 10:38:27 -05:00
Andrew Kelley
76b4e49178
add mprotect syscall 2019-02-28 20:11:36 -05:00
Andrew Kelley
ade10387a5
breaking changes to the way targets work in zig
* CLI: `-target [name]` instead of `--target-*` args.
   This matches clang's API.
 * `builtin.Environ` renamed to `builtin.Abi`
   - likewise `builtin.environ` renamed to `builtin.abi`
 * stop hiding the concept of sub-arch. closes #1526
 * `zig targets` only shows available targets. closes #438
 * include all targets in readme, even those that don't
   print with `zig targets` but note they are Tier 4
 * refactor target.cpp and make the naming conventions
   more consistent
 * introduce the concept of a "default C ABI" for a given
   OS/Arch combo. As a rule of thumb, if the system compiler
   is clang or gcc then the default C ABI is the gnu ABI.
2019-02-26 15:58:10 -05:00
Andrew Kelley
28bf768883 export _mh_execute_header with weak linkage
* also fix extern variables with initialiaztion values to generate runtime code
 * remove the workaround in example/shared_library/mathtest.zig
 * introduce the ability for global variables to have Weak and LinkOnce
   linkage
 * fix `@export` to work for non-functions. this code needs to be
   audited though.
 * fix comptime ptrcast not keeping bigger alignment
 * fix linker warnings when targeting darwin

closes #1903
2019-02-18 16:47:30 -05:00
Andrew Kelley
3e586264e5
Merge pull request #1972 from coypoop/netbsd
Add NetBSD support
2019-02-18 00:10:31 -05:00
Quetzal Bradley
7e54954052 fix openWriteNoClobber and add test 2019-02-17 23:21:45 -05:00
Maya Rashish
b93405c24b Don't provide a bogus definition of EVFILT_USER 2019-02-17 23:50:30 +02:00
Maya Rashish
8d2a902945 freebsd: fix pointer cast in mmap 2019-02-17 02:25:37 -05:00
Maya Rashish
bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley
71d7100aa8 darwin: fix pointer cast in mmap 2019-02-14 23:38:14 -05:00
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
Andrew Kelley
d770333827
freebsd: fix os_self_exe_path function and update std lib 2018-12-12 22:28:15 -05:00
Andrew Kelley
b883bc873d
breaking API changes to all readInt/writeInt functions & more
* add `@bswap` builtin function. See #767
 * comptime evaluation facilities are improved to be able to
   handle a `@ptrCast` with a backing array.
 * `@truncate` allows "truncating" a u0 value to any integer
   type, and the result is always comptime known to be `0`.
 * when specifying pointer alignment in a type expression,
   the alignment value of pointers which do not have addresses
   at runtime is ignored, and always has the default/ABI alignment
 * threw in a fix to freebsd/x86_64.zig to update syntax from
   language changes
 * some improvements are pending #863

closes #638
closes #1733

std lib API changes
 * io.InStream().readIntNe renamed to readIntNative
 * io.InStream().readIntLe renamed to readIntLittle
 * io.InStream().readIntBe renamed to readIntBig
 * introduced io.InStream().readIntForeign
 * io.InStream().readInt has parameter order changed
 * io.InStream().readVarInt has parameter order changed
 * io.InStream().writeIntNe renamed to writeIntNative
 * introduced io.InStream().writeIntForeign
 * io.InStream().writeIntLe renamed to writeIntLittle
 * io.InStream().writeIntBe renamed to writeIntBig
 * io.InStream().writeInt has parameter order changed
 * mem.readInt has different parameters and semantics
 * introduced mem.readIntNative
 * introduced mem.readIntForeign
 * mem.readIntBE renamed to mem.readIntBig and different API
 * mem.readIntLE renamed to mem.readIntLittle and different API
 * introduced mem.readIntSliceNative
 * introduced mem.readIntSliceForeign
 * introduced mem.readIntSliceLittle
 * introduced mem.readIntSliceBig
 * introduced mem.readIntSlice
 * mem.writeInt has different parameters and semantics
 * introduced mem.writeIntNative
 * introduced mem.writeIntForeign
 * mem.writeIntBE renamed to mem.readIntBig and different semantics
 * mem.writeIntLE renamed to mem.readIntLittle and different semantics
 * introduced mem.writeIntSliceForeign
 * introduced mem.writeIntSliceNative
 * introduced mem.writeIntSliceBig
 * introduced mem.writeIntSliceLittle
 * introduced mem.writeIntSlice
 * removed mem.endianSwapIfLe
 * removed mem.endianSwapIfBe
 * removed mem.endianSwapIf
 * added mem.littleToNative
 * added mem.bigToNative
 * added mem.toNative
 * added mem.nativeTo
 * added mem.nativeToLittle
 * added mem.nativeToBig
2018-12-12 20:35:04 -05:00
Andrew Kelley
a40d160a5c
introduce std.io.SeekableStream
Relevant #764

dwarf debug info is modified to use this instead of std.os.File
directly to make it easier for bare metal projects to take advantage
of debug info parsing
2018-12-02 18:36:18 -05:00
Suirad
cf266ff80a Update tests 2018-11-30 02:15:33 -06:00
Suirad
e8e6ae57d4 Find CI env variables 2018-11-30 02:08:34 -06:00
Suirad
1fa2217c10 Simplify implementation 2018-11-30 02:08:34 -06:00
Suirad
24592d0216 Add more padding to parse buffer 2018-11-30 02:08:34 -06:00
Suirad
0abd5520bd Platform specific tests 2018-11-30 02:08:34 -06:00
Suirad
5dfca87a65 Update windows imports 2018-11-30 02:08:33 -06:00
kristopher tate
2b78a90424
std.os.path: remove dependance on std.mem.join;
std/os/child_process.zig: windows

test/cli.zig: godbolt;

doc/docgen.zig
2018-11-30 03:52:27 +09:00
Josh Wolfe
11e8afb37c fix child_process piped streams not getting closed 2018-11-28 18:33:55 -05:00
Andrew Kelley
dd2450b1b2
tier 2 support for freebsd 2018-11-27 20:56:43 -05:00
Andrew Kelley
e3bf40742d
Merge branch 'master' into freebsd2 2018-11-27 20:36:44 -05:00
kristopher tate
0f7de58b64
std.mem: add new separate method and rework SplitIterator; 2018-11-26 02:02:17 +09:00
Andrew Kelley
4d747d452f
update zen os std lib for latest zig changes 2018-11-24 16:51:52 -05:00
Andrew Kelley
56a8f2b018
fix @intCast not catching negative numbers to unsigned 2018-11-24 14:36:16 -05:00
Andrew Kelley
b953e322a8
std.os.path.realC: make overflow more clearly impossible 2018-11-21 13:41:10 -05:00
Andrew Kelley
bb3ac177a8
fix incorrect buf len 2018-11-20 12:37:42 -05:00
Andrew Kelley
4dafdc00d5
zig fmt 2018-11-19 17:28:18 -05:00
Andrew Kelley
9493738e54
Merge branch 'freebsd-up' of https://github.com/myfreeweb/zig into freebsd2 2018-11-19 17:24:41 -05:00
Duncan
e9b47d960b Fix setsockopt syscall on linux 2018-11-18 10:45:38 -05:00
Vallentin
398914eb71 Fixed typos 2018-11-16 14:03:39 -05:00
Jimmi Holst Christensen
8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
emekoi
8e69a18d8c made colored output more consistent (#1706)
* made colored output more consistent
* added os.supportsAnsiEscapeCodes
2018-11-08 00:36:36 -05:00
Andrew Kelley
2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Jimmi Holst Christensen
65b7d85524 Fixed code still using old ptr syntax 2018-10-20 17:59:06 +02:00
Greg V
e5627f8e63 Support more of std on FreeBSD 2018-10-20 15:21:35 +03:00
Greg V
d6cab0d4b6 Various fcntl flags are also machine-independent on FreeBSD 2018-10-20 15:15:01 +03:00
Greg V
afe26bbcbd System call numbers on FreeBSD are machine-independent
But e.g. sbrk is only removed in new architectures (aarch64, riscv),
so keep it in x86_64
2018-10-20 15:15:01 +03:00
Greg V
7a3f0a55d9 Add freebsd to more things 2018-10-20 15:15:01 +03:00
Greg V
1829c09303 Fix os/freebsd files 2018-10-20 15:15:01 +03:00
Marc Tiehuis
19659c3bd3 freebsd: Fix argc resolution in _start
FreeBSD appears to use rdi instead of rsp as in other posix systems.
According to some loose documentation, x86 passes values on the stack,
so amd64 freebsd may be the only exception.
2018-10-20 15:15:01 +03:00
Marc Tiehuis
102cb61e40 Get freebsd std compiling again 2018-10-20 15:15:01 +03:00
Marc Tiehuis
e2b9c153bd Add initial freebsd stdlib functionality
Trivial program now compiles with now warnings.
2018-10-20 15:15:01 +03:00
Andrew Kelley
49bc33efe1 fix windows 2018-10-15 21:38:01 -04:00
Andrew Kelley
d5648d2640
remove implicit cast from T to *const T
closes #1465
2018-10-15 18:23:47 -04:00
Jimmi Holst Christensen
378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Marc Tiehuis
67fb4d1359 Improve time.sleep api 2018-10-11 11:57:59 -04:00
Andrew Kelley
d40c4e7c89
Merge pull request #1429 from shawnl/arm64
initial arm64 support
2018-10-06 00:11:39 -04:00
Shawn Landden
2d27341724 arm64: respond to code review 2018-10-06 03:31:52 +00:00
emekoi
31469daca3 removed unneeded dll extension 2018-10-04 11:43:53 -04:00
Andrew Kelley
66cb75d114
std.Mutex: implement blocking mutexes on linux
closes #1463

Thanks to Shawn Landden for the original pull request.
This commit is based on that code.
2018-10-03 13:19:10 -04:00
Andrew Kelley
acefcdbca5
add std.os.linux.vfork and std.os.linux.exit_group 2018-10-02 14:08:32 -04:00
Andrew Kelley
af229c1fdc
std lib (breaking): posixRead can return less than buffer size
closes #1414

std.io.InStream.read now can return less than buffer size
introduce std.io.InStream.readFull for previous behavior

add std.os.File.openWriteNoClobberC
rename std.os.deleteFileWindows to std.os.deleteFileW
remove std.os.deleteFilePosix
add std.os.deleteFileC

std.os.copyFile no longer takes an allocator
std.os.copyFileMode no longer takes an allocator
std.os.AtomicFile no longer takes an allocator

add std.os.renameW
add windows support for std.os.renameC

add a test for std.os.AtomicFile
2018-10-01 13:50:55 -04:00
Andrew Kelley
d1ec8377d1
std lib: flesh out the async I/O streaming API a bit 2018-10-01 10:53:39 -04:00
Andrew Kelley
9d4eaf1e07
update std lib API for I/O
std.io.FileInStream -> std.os.File.InStream
std.io.FileInStream.init(file) -> file.inStream()
std.io.FileOutStream -> std.os.File.OutStream
std.io.FileOutStream.init(file) -> file.outStream()

remove a lot of error code possibilities from os functions

std.event.net.socketRead -> std.event.net.read
std.event.net.socketWrite -> std.event.net.write
add std.event.net.readv
add std.event.net.writev
add std.event.net.readvPosix
add std.event.net.writevPosix
add std.event.net.OutStream
add std.event.net.InStream

add std.event.io.InStream
add std.event.io.OutStream
2018-09-30 17:28:35 -04:00
emekoi
623f5085f1 merged windows dll apis 2018-09-30 01:05:13 -05:00
emekoi
d3bf267136 added dynamic library loading for windows 2018-09-30 01:05:13 -05:00
Andrew Kelley
9485043b3c
fix implicit casting to *c_void
closes #1588

also some small std lib changes regarding posix sockets
and one doc typo fix
2018-09-26 11:06:09 -04:00
Wink Saville
a170a64776 Fix typo in argsAlloc comment
Changed freeArgs to argsFree.
2018-09-23 13:12:57 -04:00
Andrew Kelley
15e59eb142
remove deprecated, unused windows functions
* `CryptAcquireContextA`
 * `CryptReleaseContext`
 * `CryptGenRandom`

See https://github.com/ziglang/zig/issues/534#issuecomment-422208368
2018-09-17 20:07:48 -04:00
Andrew Kelley
c06a61e9bf
remove this. add @This().
closes #1283
2018-09-13 16:34:33 -04:00
Andrew Kelley
a757533386 fix zig fmt on windows
closes #1069
2018-09-12 14:26:21 -04:00
emekoi
54f7d58722 fixed WriteFile segfault 2018-09-12 07:01:48 -05:00
Andrew Kelley
7dd3c3814d
fix incorrect error union const value generation
closes #1442

zig needed to insert explicit padding into this structure before
it got bitcasted.
2018-09-11 15:16:50 -04:00
Shawn Landden
17cb69cebc fix elf auxv handling
Auxillery vectors are not guaranteed to be in any order, this
just happens to work on x86_64.
2018-09-08 14:47:21 +00:00
Shawn Landden
cba0d76fbc clone() on arm64 2018-09-08 03:52:28 +00:00
Shawn Landden
342cff28f5 initial arm64 support 2018-09-08 03:52:28 +00:00
Shawn Landden
4a8c992ef1 os: use less syscalls
these don't exist on new platforms (such as arm64)

also switch from the deprecated dirent to dirent64
2018-09-08 03:52:28 +00:00
Shawn Landden
d956d30167 this is not arch-specific 2018-09-08 03:52:28 +00:00
Andrew Kelley
92f7474359 switch most windows calls to use W versions instead of A
See #534
2018-09-02 23:25:04 -04:00
Andrew Kelley
832caefc2a fix regressions 2018-09-02 18:35:32 -04:00
Andrew Kelley
98dc943c07 rework code to avoid duplicate operations 2018-09-02 15:58:08 -04:00
Andrew Kelley
686663239a printing info from the ModuleInfo substream of DebugInfo 2018-08-29 19:00:24 -04:00
Andrew Kelley
f1b71053de use RtlCaptureStackBackTrace on windows 2018-08-29 16:35:51 -04:00
Andrew Kelley
41723f842c Merge branch 'windows-coff-issue721' of https://github.com/Sahnvour/zig into Sahnvour-windows-coff-issue721 2018-08-28 17:32:32 -04:00
Andrew Kelley
fb6d3859e8
zig fmt 2018-08-27 19:25:40 -04:00
Andrew Kelley
ac36f98e72 fix stack traces on linux 2018-08-25 03:07:37 -04:00
Andrew Kelley
478db39866 fix selfExePath on macosx 2018-08-21 20:52:21 -04:00
Andrew Kelley
ea1b21dbdb fix linux
* error.BadFd is not a valid error code. it would always be a bug to
   get this error code.
 * merge error.Io with existing error.InputOutput
 * merge error.PathNotFound with existing error.FileNotFound.
   Not all OS's support both.
 * add os.File.openReadC
 * add error.BadPathName for windows file operations with invalid
   characters
 * add os.toPosixPath to help stack allocate a null terminating byte
 * add some TODOs for other functions to investigate removing the
   allocator requirement
 * optimize some implementations to use the alternate functions when
   a null byte is already available
 * add a missing error.SkipZigTest
 * os.selfExePath uses a non-allocating API
 * os.selfExeDirPath uses a non-allocating API
 * os.path.real uses a non-allocating API
 * add os.path.realAlloc and os.path.realC
 * convert many windows syscalls to use the W versions (See #534)
2018-08-21 20:31:50 -04:00
Andrew Kelley
51852d2587 fix windows 2018-08-21 16:07:28 -04:00
Andrew Kelley
bda5539e9d *WIP* std.os assumes comptime-known max path size
this allows us to remove the requirement of allocators for a lot
of functions

See #1392
2018-08-21 00:46:42 -04:00
Andrew Kelley
302936309a Merge branch 'path_max' of https://github.com/shawnl/zig into shawnl-path_max 2018-08-20 17:57:49 -04:00
Andrew Kelley
9e9dce76ff refactor std.os.makePath to use a switch instead of if 2018-08-20 17:57:03 -04:00
Shawn Landden
bb93886791 do not use an allocator when we don't need to because of the existance of PATH_MAX 2018-08-19 21:42:48 -07:00
Andrew Kelley
c4b9466da7
Merge pull request #1294 from ziglang/async-fs
introduce std.event.fs for async file system functions
2018-08-10 15:51:17 -04:00
Andrew Kelley
598e80957e windows: call CancelIo when canceling an fs watch 2018-08-10 13:19:07 -04:00
Andrew Kelley
23af36c54f windows fs watching: fix not initializing table value 2018-08-09 21:48:25 -04:00
Andrew Kelley
26a842c264 windows: only create io completion port once 2018-08-09 20:12:46 -04:00
Andrew Kelley
b219feb3f1 initial windows implementation of std.event.fs.Watch 2018-08-09 16:48:44 -04:00