Commit Graph

57 Commits (295bca9b5f397ff98e5a0162fcb2a9f5e0a3e35c)

Author SHA1 Message Date
Michael Dusan e05923f34b macos: use realpath$DARWIN_EXTSN
macOS 10.15 Catalina causes an ancient variant of `realpath` to fail,
likely due to 10.15's evolving security model.

closes #5325
2020-05-16 12:41:53 -04:00
Tadeo Kondrak 6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Cato 07bee9da42 Fixed Darwin-incompatible socket flags and unavailable system calls 2020-05-02 16:37:39 -04:00
Tadeo Kondrak 17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
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
LemonBoy 4209ab90a8 std: Use the versioned libc symbols if needed
Many symbols on NetBSD and some on OSX require the definition of an
alias.
2020-04-01 12:23:18 +02: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
Andrew Kelley 3869e80331
Merge pull request #4793 from LemonBoy/netbsd-forever
Netbsd forever
2020-03-25 10:19:49 -04:00
LemonBoy 778dbc17ac std: Fix setsockopt definition
* Add socketpair definition
2020-03-24 16:06:25 -04:00
LemonBoy 3ccf99c0bd std: Slim duplicate logic for some calls 2020-03-24 19:47:18 +01:00
LemonBoy c3f93be00c std: Tell pthread the guard page size is zero
On NetBSD this is needed to avoid crashes in pthread_join as the default
value for the guard page size is not ignored even though a custom stack
address is specified.
2020-03-23 23:26:34 +01: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
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
daurnimator bfc569bc98
std: add os.fstatat 2020-03-03 13:25:43 -05:00
daurnimator 627618a38d
std: add Dir.changeDir as wrapper around fchdir 2020-03-03 13:25:43 -05:00
daurnimator 88e27f01c8
std: add mkdirat 2020-03-03 13:25:40 -05:00
Andrew Kelley c81345c8ae
breaking: std.os read/write functions + sendfile
* rework os.sendfile and add macosx support, and a fallback
   implementation for any OS.
 * fix sendto compile error
 * std.os write functions support partial writes. closes #3443.
 * std.os pread / pwrite functions can now return `error.Unseekable`.
 * std.fs.File read/write functions now have readAll/writeAll variants
   which loop to complete operations even when partial reads/writes
   happen.
 * Audit std.os read/write functions with respect to Linux returning
   EINVAL for lengths greater than 0x7fff0000.
 * std.os read/write shim functions do not unnecessarily loop. Since
   partial reads/writes are part of the API, the caller will be forced
   to loop anyway, and so that would just be code bloat.
 * Improve doc comments
 * Add a non-trivial test for std.os.sendfile
 * Fix std.os.pread on 32 bit Linux
 * Add missing SYS_sendfile bit on aarch64
2020-03-03 02:25:26 -05:00
Andrew Kelley 07f52119de
implement native OS version detection for linux 2020-02-28 14:51:56 -05:00
Andrew Kelley 3683ba87ac
complete the native target detection based on /usr/bin/env 2020-02-28 14:51:56 -05:00
Andrew Kelley 4616af0ca4
introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Andrew Kelley 936d0b18b1
update std lib to integrate with libc for environ
closes #3511
2020-02-22 15:59:13 -05:00
Andrew Kelley 4b02a39aa9
self-hosted libc detection
* libc_installation.cpp is deleted.
   src-self-hosted/libc_installation.zig is now used for both stage1 and
   stage2 compilers.
 * (breaking) move `std.fs.File.access` to `std.fs.Dir.access`. The API
   now encourages use with an open directory handle.
 * Add `std.os.faccessat` and related functions.
 * Deprecate the "C" suffix naming convention for null-terminated
   parameters. "C" should be used when it is related to libc. However
   null-terminated parameters often have to do with the native system
   ABI rather than libc. "Z" suffix is the new convention. For example,
   `std.os.openC` is deprecated in favor of `std.os.openZ`.
 * Add `std.mem.dupeZ` for using an allocator to copy memory and add a
   null terminator.
 * Remove dead struct field `std.ChildProcess.llnode`.
 * Introduce `std.event.Batch`. This API allows expressing concurrency
   without forcing code to be async. It requires no Allocator and does
   not introduce any failure conditions. However it is not thread-safe.
 * There is now an ongoing experiment to transition away from
   `std.event.Group` in favor of `std.event.Batch`.
 * `std.os.execvpeC` calls `getenvZ` rather than `getenv`. This is
   slightly more efficient on most systems, and works around a
   limitation of `getenv` lack of integration with libc.
 * (breaking) `std.os.AccessError` gains `FileBusy`, `SymLinkLoop`, and
   `ReadOnlyFileSystem`. Previously these error codes were all reported
   as `PermissionDenied`.
 * Add `std.Target.isDragonFlyBSD`.
 * stage2: access to the windows_sdk functions is done with a manually
   maintained .zig binding file instead of `@cImport`.
 * Update src-self-hosted/libc_installation.zig with all the
   improvements that stage1 has seen to src/libc_installation.cpp until
   now. In addition, it now takes advantage of Batch so that evented I/O
   mode takes advantage of concurrency, but it still works in blocking
   I/O mode, which is how it is used in stage1.
2020-02-16 13:25:30 -05:00
Andrew Kelley 7f4cce3345 add fcntl support on darwin 2020-02-07 12:11:15 -05:00
nofmal a697de3eac Add basic linux termios implementation 2020-02-04 14:09:57 -05:00
Andrew Kelley 0cc2489d22
Merge pull request #4317 from Vexu/std-c
Add (unfinished) C parser to std lib
2020-01-29 12:13:53 -05:00
daurnimator 72ec445677 std: turn EAI_ constants into a non-exhaustive enum 2020-01-18 17:46:44 -05:00
Andrew Kelley fee9318b17
std.os.getrusage: add C extern fn and reserved field
* add reserved field to match musl struct definition so that
   it will work with musl libc.
 * add libc getrusage so that it will work with libc

what's not done in this branch is:
 * test coverage. See #1629, which should also aim to provide
   general test coverage for the std lib.
 * rusage struct bits for non-linux operating systems
2020-01-05 16:57:14 -05:00
Vexu 46f292982d
std-c parser DeclSpec 2020-01-05 20:25:51 +02:00
Vexu 73a53fa263
std-c outline parser 2020-01-05 20:25:50 +02:00
Vexu e1b01d32f0
std-c ast base 2020-01-05 20:25:50 +02:00
Luna ea8f496970
std.c: c_uint -> u32 for sockopt functions 2019-12-30 19:26:30 -05:00
Luna 3ccbf3cfc2
move parameters on sockopt functions to c_uint
this makes them consistent with the linux syscalls
2019-12-30 19:26:30 -05:00
Luna d423bb3808
std.c: add setsockopt 2019-12-30 19:26:30 -05:00
Andrew Kelley 6b960331ee
Merge pull request #3968 from daurnimator/sigprocmask
Clean up linux sigprocmask, raise
2019-12-29 18:03:09 -05:00
kprotty b8fabb3426 ResetEvent: broadcast by default 2019-12-22 21:45:26 -06:00
daurnimator 96c9c38b35
std: sigprocmask set is optional 2019-12-22 12:03:03 +11:00
Raul Leal 62c817420d [#3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types (#3900)
* #3844 update std.c functions to use null-terminated pointer types

* check linux functions

* fix callsites

* fix io test

* Add allocPrintCstr function to remove other cast
2019-12-17 15:43:49 -05:00
Andrew Kelley fd6b7b160d
improve dynamic library API 2019-12-10 12:28:28 -05:00
kprotty ef208fee3c
Definition fixups & ResetEvent test cases 2019-11-26 20:40:04 -05:00
kprotty 9bce97a479
Start on ResetEvent 2019-11-26 20:40:04 -05:00
Andrew Kelley 29e438fd1f
more sentinel-terminated pointers std lib integration
See #3767
2019-11-25 00:43:36 -05:00
Andrew Kelley 15d415e10b
make std.mem.toSlice use null terminated pointers
and fix the fallout
2019-11-24 21:21:05 -05:00
Andrew Kelley 7597735bad
update the stage1 implementation to the new proposal
See #3731
2019-11-23 04:45:35 -05:00
Andrew Kelley cf2fe2536e
better error message when null termination does not match 2019-11-21 20:43:41 -05:00
Andrew Kelley 2723ffc2b2
fixups and zig fmt 2019-11-08 01:52:23 -05:00
Andrew Kelley fbbcf2f30d
Merge branch 'adaptive_lock' of https://github.com/kprotty/zig into kprotty-adaptive_lock 2019-11-08 01:21:22 -05:00
kprotty 12e68cbeb6 pthread_sched_yield -> sched_yield 2019-11-07 16:33:25 -06:00
kprotty b535e86cc0 move SpinLock definitions around 2019-11-07 15:32:20 -06:00
daurnimator c8463ce9b0
std: Add definitions for (deprecated) futimes and utimes C functions 2019-11-05 02:19:25 +11:00
daurnimator 6e635c6406
std: close is OSX specific 2019-11-05 02:16:30 +11:00