Commit Graph

267 Commits (733f1c25bd34270b76c5fa43928dfffda1ecd5e3)

Author SHA1 Message Date
LemonBoy 0bf91cce58 windows: Minor changes to psapi prototypes 2020-02-01 13:43:46 -05:00
LemonBoy 3640c682a2 Run `zig fmt` 2020-02-01 11:32:53 +01:00
Andrew Kelley e6a812c827
Merge pull request #4340 from daurnimator/ntstatus-as-enum
Windows error codes as non-exhaustive enums
2020-01-31 18:27:17 -05:00
LemonBoy c910aa8555 windows: Add GetCurrentProcess definition 2020-02-01 00:01:09 +01:00
LemonBoy 9ffc13b6c4 windows: Add psapi API
Export both the "old-style" definitions from psapi and the "new-style"
ones from kernel32.
2020-01-31 23:50:26 +01:00
daurnimator ab46713fa6 std: update for linux 5.5 release 2020-01-31 10:18:17 -05:00
daurnimator b9f720365c
Turn win32 errors into a non-exhaustive enum 2020-01-31 22:33:55 +11:00
daurnimator 7cf0b02ab4
NTSTATUS is a non-exhaustive enum 2020-01-31 22:33:17 +11:00
Andrew Kelley 65b1a4953f
Merge pull request #4324 from fengb/testing-allocator
Remove debug.global_allocator in favor of testing.allocator
2020-01-30 10:01:40 -05:00
Andrew Kelley 0303e7bd8e
Merge pull request #4319 from Rocknest/windows-traces
Bring windows segfault handler on par with linux
2020-01-30 09:26:39 -05:00
Rocknest 94f29ae117 Remove intCast's 2020-01-30 08:53:38 +02:00
Benjamin Feng b7a236d68e Convert a bunch of page_allocator to testing.allocator 2020-01-29 22:22:01 -06:00
Benjamin Feng b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Rocknest b1884b3a62 Fix aarch64 2020-01-30 01:17:34 +02:00
Rocknest 4a4d6f2be9 Reorganize definitions 2020-01-29 23:15:17 +02:00
Benjamin Feng aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng 4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
LemonBoy 1ba4554855 Correct dl_iterate_phdr address
The base should be zero so that p_vaddr + dlpi_addr = p_vaddr
2020-01-29 12:05:36 -05:00
Andrew Kelley a867b43366
progress towards merging
see BRANCH_TODO file
2020-01-19 20:54:04 -05:00
LemonBoy fa52c9e36e Small cleanups 2020-01-19 00:11:45 +01:00
LemonBoy c5cfc9bf68 Move definition of __aeabi_read_tp 2020-01-15 17:50:51 +01:00
LemonBoy c85afff5a8 Correct l_name field type 2020-01-14 23:11:10 +01:00
LemonBoy c1f3766f1c Correct dlpi_name field type 2020-01-14 21:15:33 +01:00
Jonathan Marler 0827e298ed Add WaitForSingleObject function to std.os.windows 2020-01-11 15:49:48 -05:00
Ryan Liptak 834218d789 Fix remaining variadic formatted prints
Used a series of regex searches to try to find as many instances of the old pattern as I could and update them.
2020-01-09 13:36:44 -05:00
Andrew Kelley 7b73c7fe12
Merge branch 'std-utf16-sentinel-terminated' of https://github.com/daurnimator/zig 2020-01-07 16:13:34 -05:00
Andrew Kelley 633b6bf920
Merge branch 'LemonBoy-cc-work' 2020-01-06 18:53:17 -05:00
Andrew Kelley 53913acaf7
zig fmt and update `extern fn` to `callconv(.C)` 2020-01-06 15:34:50 -05:00
Andrew Kelley 0a9daeb37e
Merge branch 'cc-work' of https://github.com/LemonBoy/zig into LemonBoy-cc-work 2020-01-06 14:07:56 -05:00
Colin Svingen 4e6ad8efd9 Removes proc_raise from WASI implementation 2020-01-06 14:04:55 -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
data-man 2f6b045fb1
Add std.os.getrusage 2020-01-05 16:52:36 -05:00
LemonBoy 563d9ebfe5 Implement the callconv() annotation 2020-01-02 18:53:16 +01:00
Andrew Kelley 0c8ec369f0
std.os.memfd_create: add error.SystemOutdated 2019-12-31 17:57:20 -05:00
Andrew Kelley 8186211404
improvements to memfd_create
* move test from std/io/test.zig to std/os/test.zig
 * do glibc version check, and make direct system call if
   glibc is too old
 * disable test when not linking libc, to avoid not working
   with outdated qemu version on the CI server. see #4019
2019-12-31 16:34:14 -05:00
Luna f0cbf63e1a
os: use system for memfd_create
- os: update flags type for memfd_create
2019-12-31 15:58:03 -05:00
Luna 997812e8fb
os: add memfd_create
currently only linux is supported
2019-12-31 15:58:03 -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
daurnimator 2662e50d27
std: sentinel terminated pointers for utf16 apis 2019-12-29 10:35:05 +11:00
daurnimator 95c83388e4
std: use pid_t where appropriate 2019-12-22 20:20:58 +11:00
daurnimator 6de4bd850c
std: add tkill and tgkill for linux 2019-12-22 20:20:58 +11:00
daurnimator c31afc3736
std: remove high level linux sigprocmask wrappers 2019-12-22 20:20:58 +11:00
daurnimator 9577ff1c90
std: use simpler sigset_t definition 2019-12-22 20:20:53 +11:00
Jethro Nederhof ba1d213f48 freebsd: add missing OS and libc bits 2019-12-22 02:27:23 -05: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
LemonBoy 19ddbd9e9e Make sure the address is aligned for intToPtr ops
Closes #773
2019-12-15 14:41:05 -05:00
Heppokoyuki 5ada11449a fix con_in difinition and add EFI_SIMPLE_TEXT_INPUT_PROTOCOL difinition 2019-12-10 13:25:28 -05:00
emekoi 29fd727b79
fixed windows dynamic library loading and added loading for darwin 2019-12-10 11:41:54 -05:00
Robin Voetter 4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley 03396b3caa
update docs to new fmt API 2019-12-08 23:46:50 -05:00
Andrew Kelley 8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley 525b1e8fb4
Merge pull request #3856 from ziglang/builtin-call
introduce `@call` and remove other builtin calls
2019-12-06 15:49:47 -05:00
Andrew Kelley 343987cd05
remove `@inlineCall` from zig 2019-12-06 14:12:01 -05:00
Vexu bfb15f1c9f fix casts 2019-12-05 15:47:06 -05:00
Andrew Kelley b7be57766b
Merge pull request #3715 from daurnimator/towards-afd
Misc windows additions+fixes
2019-12-02 16:12:55 -05:00
Andrew Kelley ad214c7aa0
bring your own OS layer in the std lib
closes #3784
2019-12-02 15:02:17 -05:00
Andrew Kelley b36c07a95a
Merge remote-tracking branch 'origin/master' into remove-array-type-coercion 2019-12-01 09:56:01 -05:00
Andrew Kelley 951dc451d6
Merge pull request #3808 from LemonBoy/i386-for-ya
linux-i386 support
2019-11-30 22:00:00 -05:00
Andrew Kelley 413f9a5cfc
move `std.fs.Dir.cwd` to `std.fs.cwd`
update to non-deprecated std.fs APIs throughout the codebase

Related: #3811
2019-11-30 15:35:27 -05:00
LemonBoy e1e06e6766 linux-i386 support 2019-11-30 16:13:33 +01:00
Andrew Kelley d87b13f2f7
fix windows std lib regressions 2019-11-29 21:55:27 -05:00
Andrew Kelley bf3ac66150
remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
daurnimator 8a71f77c4a
std: lie about windows socklen_t signed-ness 2019-11-27 13:01:34 +11:00
daurnimator edc84e7ef7
std: add more winsock functions 2019-11-27 13:01:33 +11:00
daurnimator 19f26578c0
std: windows sockaddr constants come from ws2_32 2019-11-27 13:01:32 +11:00
daurnimator 8aa3d6019c
std: add windows.USHORT definition 2019-11-27 13:01:30 +11:00
daurnimator 254c79125b
std: fix WSAIoctl definition
zig automatically passes functions as pointers
2019-11-27 13:01:28 +11:00
daurnimator d99f0a2b8f
std: IO_STATUS_BLOCK's status member is an NTSTATUS; add union 2019-11-27 13:01:10 +11:00
daurnimator 1537d4701e
std: fix definition of NtDeviceIoControlFile 2019-11-27 13:01:09 +11:00
daurnimator a453c99ba9
std: add comments for some nt status codes 2019-11-27 13:01:08 +11:00
daurnimator 2c6788d7de
std: add windows.closesocket 2019-11-27 13:01:07 +11:00
daurnimator 6b5b0e6cd6
std: fix windows.GetOverlappedResult 2019-11-27 13:01:05 +11:00
daurnimator ce9966a39b
std: improved windows.DeviceIoControl 2019-11-27 13:01:04 +11:00
daurnimator b05a5a3e52
std: add CreateEvent for windows 2019-11-27 13:01:03 +11:00
daurnimator 78c0d33eb7
std: add WaitForMultipleObjects for windows 2019-11-27 13:01:02 +11:00
daurnimator 21ca54f560
std: add alertable argument for windows.WaitForSingleObject 2019-11-27 13:00:59 +11:00
Jonathan S 4014a8e4b4 Avoid deprecated cwd-based functions for opening directories, preferring to open explicitly relative to `Dir.cwd()`. 2019-11-25 23:46:48 -05:00
Jonathan S 51c5740879 Use a specific access mask in `Dir.openDirListW` instead of a generic one. Untested.
The actual desired access mask in this case seems quite confusing and badly documented. The previous combination of `GENERIC_READ` and `SYNCHRONIZE` seems both illegal and redundant according to the [`ntifs.h` documentation](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile), which specifies that `GENERIC_READ` should not be used for directories and includes `SYNCHRONIZE`. `winnt.h` contains a number of relevant-sounding flags such as `FILE_ADD_FILE`, `FILE_ADD_SUBDIRECTORY`, and `FILE_DELETE_CHILD` that do not show up in documentation at all. These are equal in value to file-specific flags that are documented as flags you should not specify when opening a directory.
2019-11-25 23:46:47 -05:00
Andrew Kelley 4261fa3c49
move logic to the appropriate layers; add new compile error 2019-11-25 18:46:17 -05:00
Andrew Kelley 659c1bdeee
Merge branch 'wasi-run-tests' of https://github.com/fengb/zig into fengb-wasi-run-tests 2019-11-25 17:53:26 -05:00
Andrew Kelley cb38bd0a14
rename std.heap.direct_allocator to std.heap.page_allocator
std.heap.direct_allocator is still available for now but it is marked
deprecated.
2019-11-25 17:25:06 -05:00
Andrew Kelley bdf3680be1
zig fmt 2019-11-25 13:53:13 -05:00
Andrew Kelley 5a98dd42b3
Merge pull request #3728 from ziglang/null-terminated-pointers
sentinel-terminated pointers
2019-11-25 02:20:08 -05:00
daurnimator 69b780647a std: update for linux 5.4 2019-11-25 02:07:23 -05:00
Andrew Kelley d2cb740dd9 add missing null terminator in windows file path helper function 2019-11-25 01:10:30 -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 47f06be369
string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
Andrew Kelley cd5f4de2a6
std: remove O_LARGEFILE from OS bits when the OS does not define it 2019-11-21 20:34:55 -05:00
Benjamin Feng 0f0d01a037 Replace magic numbers with named constants 2019-11-21 18:41:02 -06:00
Andrew Kelley bf1cbebea1 improve std.fs.selfExePath and related functions on Windows 2019-11-21 18:51:12 -05:00
Andrew Kelley cd37c1a377
add std.fs.Dir.openRead
This is progress towards file system APIs that encourage avoiding
Time Of Check, Time Of Use bugs.
2019-11-21 17:07:29 -05:00
Benjamin Feng b88bb93af3 WASI isatty 2019-11-19 20:17:00 -06:00
Benjamin Feng 14e9c7d1f2 WASI clock functions 2019-11-19 19:44:19 -06:00
Benjamin Feng c3d93cd9f2 WASI time_t / timespec 2019-11-19 16:12:26 -06:00
daurnimator 431eeb5e20
std: add pieces for WSAIoctl on windows 2019-11-15 10:31:52 +11:00
daurnimator 3b8afe31a0
std: add NtDeviceIoControlFile definition for windows 2019-11-15 10:31:51 +11:00
daurnimator 6469900e79
std: add WSAStartup and WSACleanup for windows 2019-11-15 10:31:47 +11:00
daurnimator 4cf535a01b
std: add WSASocketW for windows 2019-11-14 17:09:22 +11:00
daurnimator d9d3268cc1
std: add DeviceIoControl and GetOverlappedResult for windows 2019-11-14 17:09:21 +11:00
daurnimator f4c6cc3270
std: add winsock some definitions 2019-11-14 17:09:19 +11:00
daurnimator a832b35c19
std: add windows socket constants
Taken from https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw
2019-11-14 17:09:17 +11:00
daurnimator be86e41d97
std: add CTL_CODE function for windows 2019-11-14 17:09:16 +11:00
daurnimator 4830415071
std: add FILE_ANY_ constants for windows 2019-11-14 17:00:09 +11:00
daurnimator 0270545edb
std: add windows ioctl transfer types 2019-11-14 17:00:07 +11:00
daurnimator ef6cec983c
std: add windows FILE_DEVICE_ defines 2019-11-14 17:00:05 +11:00
Vexu f0c94d95dd
use @atomicStore in std lib 2019-11-13 00:52:15 +02:00
Luna d1eabe81a9 add sockaddr_un to os/bits/windows 2019-11-10 14:38:33 -03:00
Andrew Kelley 3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley aa0daea541
update more of the std lib to use `@as` 2019-11-08 15:57:25 -05:00
Andrew Kelley e0db54e89d
update the codebase to use `@as` 2019-11-08 15:57:24 -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 b5d84635f2 remove WaitOnAddress backend in std.ThreadParker 2019-11-07 15:46:57 -06:00
kprotty b535e86cc0 move SpinLock definitions around 2019-11-07 15:32:20 -06:00
Andrew Kelley c7fd414dab
Merge pull request #3618 from nrdmn/uefi
UEFI improvements
2019-11-06 23:19:46 -05:00
Nick Erdmann 78b54d9c96
std/os/uefi: protocol handling improvements 2019-11-07 03:06:06 +01:00
Nick Erdmann cef51eaffb
std/os/uefi: snp, mnp, ip6, and udp6 support 2019-11-07 02:53:53 +01:00
Nick Erdmann f4767186dd
std/os/uefi: loading images 2019-11-07 02:53:53 +01:00
kprotty 465ebf494d ThreadParker implementation 2019-11-05 15:58:58 -06:00
kprotty 0d4f4aad9e adaptive SpinLock 2019-11-05 08:16:08 -06:00
Andrew Kelley 081c62fc00
fix regression in std.os.dirent64 on linux 2019-10-31 13:56:15 -04:00
Tse 00382f6dae DragonFlyBSD tidyup 2019-10-31 13:53:32 -04:00
Andrew Kelley 61d5a0bf48
Merge branch 'std.net' 2019-10-30 21:30:16 -04:00
Andrew Kelley 6a15e8a7a7
add comments to disabled tests linking to the tracking issue 2019-10-30 21:29:45 -04:00
Tse 33cc204481 DragonFlyBSD support 2019-10-30 21:21:58 -04:00
Andrew Kelley 7b7ba51642
fix os.sockaddr being a union instead of a struct 2019-10-30 20:57:20 -04:00
Andrew Kelley c52ee6efca
canonicalize std.os IPPROTO constants 2019-10-30 20:41:28 -04:00
Andrew Kelley 0de862e8ba
make std.net more portable
* Delete `std.net.TmpWinAddr`. I don't think that was ever meant to
   be a real thing.
 * Delete `std.net.OsAddress`. This abstraction was not helpful.
 * Rename `std.net.Address` to `std.net.IpAddress`. It is now an extern
   union of IPv4 and IPv6 addresses.
 * Move `std.net.parseIp4` and `std.net.parseIp6` to the
   `std.net.IpAddress` namespace. They now return `IpAddress` instead of
   `u32` and `std.net.Ip6Addr`, which is deleted.
 * Add `std.net.IpAddress.parse` which accepts a port and parses either
   an IPv4 or IPv6 address.
 * Add `std.net.IpAddress.parseExpectingFamily` which additionally
   accepts a `family` parameter.
 * `std.net.IpAddress.initIp4` and `std.net.IpAddress.initIp6` are
   improved to directly take the address fields instead of a weird
   in-between type.
 * `std.net.IpAddress.port` is renamed to `std.net.IpAddress.getPort`.
 * Added `std.net.IpAddress.setPort`.
 * `os.sockaddr` struct on all targets is improved to match the
   corresponding system struct. Previously I had made it a union of
   sockaddr_in, sockaddr_in6, and sockaddr_un. The new abstraction for
   this is now `std.net.IpAddress`.
 * `os.sockaddr` and related bits are added for Windows.
 * `os.sockaddr` and related bits now have the `zero` fields default
   to zero initialization, and `len` fields default to the correct size.
   This is enough to abstract the differences across targets, and so
   no more switch on the target OS is needed in `std.net.IpAddress`.
 * Add the missing `os.sockaddr_un` on FreeBSD and NetBSD.
 * `std.net.IpAddress.initPosix` now takes a pointer to `os.sockaddr`.
2019-10-30 20:22:05 -04:00
Andrew Kelley 618ee5b63a fixes for macos and 32 bit arches 2019-10-30 14:43:55 -04:00
Andrew Kelley 24b3da871d
fix regressions 2019-10-30 12:49:37 -04:00
Andrew Kelley 67058b9b70
basic DNS address resolution for linux without libc 2019-10-29 02:19:22 -04:00
Andrew Kelley d5865f5319
move libc/linux bits around 2019-10-28 15:29:50 -04:00
Andrew Kelley f4c244b3d0
partial no-libc implementation of std.net.getAddressList 2019-10-28 15:29:50 -04:00
Andrew Kelley 4b80e376e3
std.net.getAddressList 2019-10-28 15:29:50 -04:00
Andrew Kelley 60cd11bd4b
get rid of std.os.foo.is_the_target
It had the downside of running all the comptime blocks and resolving
all the usingnamespaces of each system, when just trying to discover if
the current system is a particular one.

For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this
demonstrates the utility that #425 would provide.
2019-10-24 01:14:52 -04:00
Andrew Kelley 17eb24a7e4
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
  `@import("std").builtin`. The target-related types are moved
  to `std.Target`. This allows the data types to have methods, such as
  `std.Target.current.isDarwin()`.
 * `std.os.windows.subsystem` is moved to
   `std.Target.current.subsystem`.
 * Remove the concept of the panic package from the compiler
   implementation. Instead, `std.builtin.panic` is always the panic
   function. It checks for `@hasDecl(@import("root"), "panic")`,
   or else provides a default implementation.

This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 19:09:49 -04:00
Andrew Kelley e839250c51
Merge branch 'stratact-no-dir-allocators'
closes #2885
closes #2886
closes #2888
closes #3249
2019-10-21 23:54:29 -04:00
Andrew Kelley fc6f84f3f0 fix os.unlinkatW implementation 2019-10-21 20:58:53 -04:00
Andrew Kelley 9a82f00a4f
add freebsd AT_* bits 2019-10-21 20:50:47 -04:00
Andrew Kelley 98c4365b66 darwin: add AT_* bits 2019-10-21 19:39:30 -04:00
Andrew Kelley 87f632b08a fs.Dir.openDir: use empty object name for "." on Windows 2019-10-21 19:19:49 -04:00
Andrew Kelley ef67c49785
[wip] use NtDll APIs on Windows to implement std.fs.Dir 2019-10-21 14:18:01 -04:00
stratact e78d3750c5
Use 8192 sized buffers and remove allocator parameters 2019-10-19 14:04:51 -04:00
Nick Erdmann 8774b1d947
std/os/windows: remove subsystem detection for uefi 2019-10-18 19:49:02 +02:00
Andrew Kelley 2aec35525d
mipsel: fix padding on stat struct 2019-10-17 13:20:30 -04:00
Andrew Kelley 45e5841281
Merge pull request #3464 from nrdmn/uefi
UEFI improvements
2019-10-16 18:14:32 -04:00
Andrew Kelley 5181970807
improve docs and field names of Statx struct 2019-10-16 17:24:42 -04:00
Nick Erdmann e6eae25053
std/os/uefi: add documentation 2019-10-16 21:46:41 +02:00