252 Commits

Author SHA1 Message Date
daurnimator
63409cf422 std: linux syscall numbers are now an extensible enum 2020-03-31 10:16:20 -04:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
daurnimator
8cad453495 std: fix compile error since WinsockError was changed 2020-03-30 11:02:06 -04:00
daurnimator
9bc8a1e1d0 std: add some missing errnos on linux 2020-03-30 10:55:18 -04:00
daurnimator
356ef3840f std: update for linux 5.6 release 2020-03-30 10:55:18 -04:00
LemonBoy
d788b0cd8b std: Minor changes to TLS handling
* Always allocate an info block per-thread so that libc can store
  important stuff there.
* Respect ABI-mandated alignment in more places.
* Nicer code, use slices/pointers instead of raw addresses whenever
  possible.
2020-03-28 11:20:38 -04:00
Andrew Kelley
f7f563ea53
Revert "Merge pull request #4807 from LemonBoy/tls-touchups"
This reverts commit ee6fda2297bf75432b8d7115ec4c60c213535bbe, reversing
changes made to f313ab18aecea1ade0b6a90d671352a641ad351a.

This caused a test failure:

```
behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable"...test failure
/home/vsts/work/1/s/lib/std/testing.zig:191:14: 0x4608f in std.testing.expect (test)
    if (!ok) @panic("test failure");
             ^
/home/vsts/work/1/s/test/stage1/behavior/misc.zig:616:11: 0x53e93 in behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable" (test)
    expect(S.t == 1235);
          ^
```
2020-03-25 21:12:24 -04:00
Andrew Kelley
ee6fda2297
Merge pull request #4807 from LemonBoy/tls-touchups
std: Minor changes to TLS handling
2020-03-25 18:53:04 -04:00
LemonBoy
a34f67aa66 std: Minor changes to TLS handling
* Always allocate an info block per-thread so that libc can store
  important stuff there.
* Respect ABI-mandated alignment in more places.
* Nicer code, use slices/pointers instead of raw addresses whenever
  possible.
2020-03-25 12:08:50 +01:00
LemonBoy
cda73c3c18 std: Add missing C bits and defines for NetBSD 2020-03-23 18:55:45 +01:00
LemonBoy
27344464ed std: Add missing C defines for NetBSD 2020-03-23 18:47:40 +01:00
Andrew Kelley
dc04e97098
Merge pull request #4752 from ziglang/slice-array
slicing with comptime start and end indexes results in pointer-to-array
2020-03-19 18:06:16 -04:00
Andrew Kelley
555a2c0328
(breaking) std.fs.copyFile now integrates with Dir
Removed:
 * `std.fs.updateFile`
 * `std.fs.updateFileMode`
 * `std.fs.copyFile`
 * `std.fs.copyFileMode`

Added:
 * `std.fs.Dir.copyFile`
 * `std.fs.copyFileAbsolute`
 * `std.fs.updateFileAbsolute`

Moved:
 * `std.fs.Dir.UpdateFileOptions` => `std.fs.CopyFileOptions`

Deprecated:
 * `std.fs.deleteDir`
 * `std.fs.deleteDirC`
 * `std.fs.deleteDirW`
 * `std.fs.readLink`
 * `std.fs.readLinkC`
2020-03-19 14:43:41 -04:00
Andrew Kelley
61266d2621
test & docs fixups to work with new semantics 2020-03-19 09:53:55 -04:00
Andrew Kelley
46ffc798b6
fix swapped logic for Windows
Remove `std.fs.deleteTree`. Callers instead should use
`std.fs.cwd().deleteTree`.

Add `std.fs.deleteTreeAbsolute` for when the caller has an absolute
path.
2020-03-18 16:42:47 -04:00
Andrew Kelley
27affde592
(breaking) clarify openDir API
* remove deprecated `std.fs.Dir` APIs
 * `std.fs.Dir.openDir` now takes a options struct with bool fields for
   `access_sub_paths` and `iterate`. It's now much more clear how
   opening directories works.
 * fixed the std lib and various zig code calling the wrong openDir
   function.
 * the runtime safety check for dir flags is removed in favor of the
   cheaper option of putting a comment on the same line as handling
   EBADF / ACCESS_DENIED, since that will show up in stack traces.
2020-03-18 16:10:57 -04:00
LemonBoy
4843c3b4c3
std: Introduce fnctl wrapper 2020-03-18 13:45:52 -04:00
Andrew Kelley
66e76a0209
zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
Andrew Kelley
2dd920ee39
Merge branch 'format-stream' of https://github.com/fengb/zig into fengb-format-stream 2020-03-13 11:31:11 -04:00
Andrew Kelley
a9297f2267
Merge pull request #4716 from LemonBoy/sys-misc
Introduce std.fs.file.setEndPos
2020-03-13 11:18:08 -04:00
LemonBoy
de53537f10 Add NtDll-based ftruncate implementation 2020-03-13 08:45:37 +01:00
Nick Erdmann
f44530302e std/os/uefi: file protocol improvements 2020-03-12 23:23:21 +01:00
Nick Erdmann
92beb13914 std/os/uefi: status reform 2020-03-12 23:23:12 +01:00
Nick Erdmann
6c368b9e73 std/os/uefi: device path protocol improvements 2020-03-12 23:23:02 +01:00
Nick Erdmann
9f475dae14 std/os/uefi: Add shell parameters protocol 2020-03-12 23:22:49 +01:00
Nick Erdmann
52eb4129de std/os/uefi: loaded image protocol improvements 2020-03-12 23:22:08 +01:00
Nick Erdmann
e617e8a798 std/os/uefi: require guid output function be comptime 2020-03-12 23:22:08 +01:00
Nick Erdmann
7c12f93734 std/os/uefi: boot services and runtime services improvements
- Several function signatures added
- Add getNextVariableName sentinel termination annotation
2020-03-12 23:22:08 +01:00
Benjamin Feng
4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng
c11d1055b8 Integrated outstreams with new formatter 2020-03-12 10:26:28 -05:00
LemonBoy
11df0d0cf8 std: Add setEndPos to fs.file
Allow the user to shrink/grow the file size as needed.
2020-03-12 09:43:45 +01:00
LemonBoy
89d7fc773d std: Fix pwrite invocation on 32bit architectures 2020-03-12 09:43:45 +01:00
Heppokoyuki
3f1c8e3d58 fix bug 2020-03-12 00:29:30 -04:00
Andrew Kelley
3ded862cdf
Merge pull request #4713 from Heppokoyuki/uefi-file-protocols
UEFI library improvements
2020-03-11 21:44:50 -04:00
Andrew Kelley
06d2f53ece
windows: detect HANDLE_EOF in ReadFile 2020-03-11 17:39:53 -04:00
Andrew Kelley
d96b6c0d9f
fix footguns in File readAll functions 2020-03-11 13:06:30 -04:00
Heppokoyuki
58941927c4 refactor 2020-03-12 00:24:00 +09:00
Heppokoyuki
02ba1d8fe1 add file protocols 2020-03-12 00:24:00 +09:00
Andrew Kelley
18f1fef142
update standard library to new I/O streams API 2020-03-10 18:44:30 -04:00
LemonBoy
3e93dce0a1 std: Fix detection of Linux kernel version 2020-03-10 12:55:35 -04:00
daurnimator
648f94c027 std: add some definitions for netlink sockets 2020-03-09 13:02:38 -04:00
LeRoyce Pearson
25d9ab95dd Use os.ino_t for everything
Also, define ino_t for windows
2020-03-08 21:52:36 -06:00
LeRoyce Pearson
cb84875eed Define ino_t for systems not yet defining it
Also, use ino_t instead of u64 in fs.File.INode
2020-03-08 18:31:18 -06:00
Andrew Kelley
6ac76bc25e
add missing errors to std.os.windows.CreateDirectoryError 2020-03-07 19:13:21 -05:00
Andrew Kelley
7df9169081
Merge pull request #4651 from LemonBoy/fix-4645
std: Nicer way to access the PEB
2020-03-06 17:33:05 -05:00
Andrew Kelley
3163a16617
?HMODULE instead of HMODULE 2020-03-06 16:57:59 -05:00
LemonBoy
2e04b61275 std: Work around unexported NtCurrentTeb
Apparently NtCurrentTeb is only exported for i386 and some other
platforms but not for x86_64 nor AArch64. Let's go with the flow and
provide our own NtCurrentTeb like the Windows headers do.

Thank you Microsoft.
2020-03-06 09:17:14 +01:00
LemonBoy
b9a1d67637 std: Nicer way to access the PEB
Use the NtCurrentTeb API instead of using some inline asm, this is much
nicer and also more portable.

Closes #4645
2020-03-06 09:06:26 +01:00
Andrew Kelley
4a67dd04c9
breaking changes to std.fs, std.os
* improve `std.fs.AtomicFile` to use sendfile()
   - also fix AtomicFile cleanup not destroying tmp files under some
     error conditions
 * improve `std.fs.updateFile` to take advantage of the new `makePath`
   which no longer needs an Allocator.
 * rename std.fs.makeDir to std.fs.makeDirAbsolute
 * rename std.fs.Dir.makeDirC to std.fs.Dir.makeDirZ
 * add std.fs.Dir.makeDirW and provide Windows implementation of
   std.os.mkdirat. std.os.windows.CreateDirectory is now implemented
   by calling ntdll, supports an optional root directory handle,
   and returns an open directory handle. Its error set has a few more
   errors in it.
 * rename std.fs.Dir.changeTo to std.fs.Dir.setAsCwd
 * fix std.fs.File.writevAll and related functions when len 0 iovecs
   supplied.
 * introduce `std.fs.File.writeFileAll`, exposing a convenient
   cross-platform API on top of sendfile().
 * `NoDevice` added to std.os.MakeDirError error set.
 * std.os.fchdir gets a smaller error set.
 * std.os.windows.CloseHandle is implemented with ntdll call rather than
   kernel32.
2020-03-03 15:23:27 -05:00
daurnimator
1ca5f06762
Update callers of fs.makePath 2020-03-03 13:25:43 -05:00