Commit Graph

267 Commits (733f1c25bd34270b76c5fa43928dfffda1ecd5e3)

Author SHA1 Message Date
LeRoyce Pearson ea6525797d Use `flock` instead of `fcntl` to lock files
`flock` locks based on the file handle, instead of the process id.
This brings the file locking on unix based systems closer to file
locking on Windows.
2020-04-02 22:57:02 -06:00
LeRoyce Pearson 35c462caf0 Merge branch 'master' into feature-file-locks 2020-04-02 21:46:48 -06:00
LemonBoy 5047cd3d78 Workaround for #4789 2020-04-01 12:46:16 +02:00
LemonBoy 070ace4b22 std: Fix more NetBSD bits
Fix some more libc definitions.
2020-04-01 12:11:19 +02:00
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
LeRoyce Pearson 457f557c37
Merge branch 'master' into feature-file-locks 2020-03-28 17:24:19 -06: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
LeRoyce Pearson c7f4e68464
Merge branch 'master' into feature-file-locks 2020-03-27 11:32:33 -06:00
Andrew Kelley f7f563ea53
Revert "Merge pull request #4807 from LemonBoy/tls-touchups"
This reverts commit ee6fda2297, reversing
changes made to f313ab18ae.

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
LeRoyce Pearson 1a6c3aeec9 Block until file is unlocked on windows 2020-03-23 23:20:17 -06:00
LeRoyce Pearson 8bec1304c3 Fix compile error on windows 2020-03-23 22:34:00 -06:00
LeRoyce Pearson 113b217593 Merge branch 'master' into feature-file-locks 2020-03-23 21:39:16 -06:00
LeRoyce Pearson 0b93932a21 Add O_SHLOCK and O_EXLOCK to freebsd and netbsd 2020-03-23 21:07:50 -06: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
LeRoyce Pearson 32c5825030 Match netbsd's flock fields with others 2020-03-17 20:54:38 -06:00
LeRoyce Pearson 4532f5ecad Change fcntl params to ?*c_void
As recommended by LemonBoy
2020-03-16 21:50:52 -06:00
LeRoyce Pearson f66a607607 Define Flock for all posix systems 2020-03-14 10:12:46 -06:00
LeRoyce Pearson e1868029e9 Implement blocking file locking API for windows 2020-03-14 10:12:46 -06:00
LeRoyce Pearson 9af0590a28 Add fnctlFlock system call, use it to lock files 2020-03-14 10:12:46 -06: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