Commit Graph

1914 Commits

Author SHA1 Message Date
Shritesh Bhattarai
8e700bf92a wasi: import environ_get and environ_sizes_get 2019-04-30 16:35:27 -05:00
daurnimator
fd056752da
std: add sendmmsg on linux 2019-04-30 16:47:09 +10:00
Shritesh Bhattarai
01365be82f WASI: implement argsAlloc and argsFree (#2364)
* wasi: change URL to canon WASI-core.md

* wasi: import args_get and args_sizes_get

* wasi: Implement argsAlloc and argsFree

* test return value for wasi arg syscalls

* wasi: return unexpectedErrorPosix in argsAlloc

* wasi: Add TODO for ArgIterator
2019-04-29 21:54:30 -04:00
LemonBoy
b1a61a6d51 compiler-rt: Add __mulodi4 2019-04-29 18:55:20 -04:00
Andrew Kelley
d2328ac71a
Merge pull request #2372 from LemonBoy/aeabi_idiv
compiler-rt: Add __divsi3, __aeabi_idiv
2019-04-29 18:54:21 -04:00
Andrew Kelley
e3452ba21b
json tests do not need this prefix anymore 2019-04-29 14:04:31 -04:00
Andrew Kelley
da28811c50
enable more json tests
I think it was a mistake that these weren't getting automatically run by
the test suite.
2019-04-29 14:02:19 -04:00
Andrew Kelley
4b6f350369
DirectAllocator: move if > 0 condition above @memcpy
Minor improvement to 3c13aa17 as noted by daurnimator
2019-04-29 13:48:15 -04:00
Shawn Landden
3c13aa178b std.heap: do not excessively call mmap, and munmap in direct allocator 2019-04-29 13:47:24 -04:00
LemonBoy
4e241263ff compiler-rt: Add __divmodsi4, __aeabi_idivmod 2019-04-29 19:17:48 +02:00
LemonBoy
738562e990 compiler-rt: Add __divsi3, __aeabi_idiv 2019-04-29 19:17:48 +02:00
LemonBoy
fbcc559cdb Make io offsets/sizes u64 instead of usize
Decouple the concepts of address-space size and file size.

Closes #637
2019-04-28 18:07:40 +02:00
Ryan Liptak
205e501e42 std.fmt: add max_depth to avoid infinite recursion from self-references 2019-04-27 11:20:10 -04:00
daurnimator
bc1840e18f Revert "std: Add mem.nativeIntToBig and mem.nativeIntToLittle"
This reverts commit 211f0a2226.

The functions `mem.nativeToBig` and `mem.nativeToLittle` already existed.
2019-04-27 11:18:53 -04:00
emekoi
66f3ef06e8 fixed syntax error 2019-04-27 11:16:33 -04:00
Andrew Kelley
2d6520d5d4
zig fmt is built directly into stage1 rather than child process
Previously, `zig fmt` on the stage1 compiler (which is what we currently
ship) would perform what equates to `zig run std/special/fmt_runner.zig`

Now, `zig fmt` is implemented with the hybrid zig/C++ strategy outlined
by #1964.

This means Zig no longer has to ship some of the stage2 .zig files, and
there is no longer a delay when running `zig fmt` for the first time.
2019-04-26 20:46:28 -04:00
Andrew Kelley
ac3946620c
Merge pull request #2357 from squeek502/heap-shrink-large-align
DirectAllocator: reduce the amount of redundant memcpy calls on Windows
2019-04-26 19:34:24 -04:00
Andrew Kelley
28071ac637
self-hosted translate-c emits a hello world AST
Also breaking std lib API change: the return value of
std.zig.parse returns `*ast.Tree` rather than `ast.Tree`.

See #1964
2019-04-26 15:43:36 -04:00
Andrew Kelley
c82acdbb9e
clean up test output
After 4df2f3d74f test names have the word "test" in them so the
redundant word is removed from test runner. Also move the prefix/suffix
to where it logically belongs in the fully qualified symbol name.
2019-04-26 15:10:13 -04:00
Ryan Liptak
afc33f00ee heap: fixup style of realloc memory copies 2019-04-25 13:41:19 -07:00
Ryan Liptak
57f545eed8 std.heap.DirectAllocator: reduce the amount of redundant memcpy calls on Windows
Previously the memory would be copied to a different aligned address in some cases where the old offset could have been used. This fixes it so that it will always try to use the old offset when possible, and only uses a different offset if the old one is truly invalid (not aligned or not enough space to store the alloc at the old offset).
2019-04-25 13:35:45 -07:00
Andrew Kelley
17ffe166c2
add preliminary windows support to std.io.COutStream 2019-04-25 00:24:25 -04:00
Andrew Kelley
976080462c
translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00
Andrew Kelley
56e07622c6
Merge pull request #2312 from squeek502/heap-shrink-large-align
fix heap allocators when shrinking an object but growing its alignment
2019-04-24 23:44:28 -04:00
Shawn Landden
8ef7f6febb remove Shebang (#!) support
Closes:  #2165
2019-04-24 23:34:19 -04:00
vegecode
733c547a65 compiler-rt: Add missing import of test for comparesf2 2019-04-24 21:16:03 -04:00
vegecode
01168e1577 compiler-rt: add aeabi_dcmp, comparedf2 2019-04-24 21:15:39 -04:00
LemonBoy
e4825dbd77 Other 2019-04-24 20:54:17 +02:00
LemonBoy
12eff09ff4 Expose Elf32_Dyn and Elf64_Dyn 2019-04-24 20:54:05 +02:00
LemonBoy
074ddf1ac6 Implementation of dl_phdr_info 2019-04-24 20:53:46 +02:00
LemonBoy
374d16793f Go one instruction before the return address
The return address may not point to an area covered by the debug infos
so we hope for the best and decrement the address so that it points to
the caller instruction.
2019-04-23 10:05:46 +02:00
LemonBoy
b095e33667 Fix silly typo 2019-04-23 09:57:57 +02:00
LemonBoy
57ec183c09 Fix reading of signed leb128 values 2019-04-23 09:57:22 +02:00
Ryan Liptak
8ce130de3c Bump up FixedBufferAllocator test memory to account for new tests 2019-04-22 02:25:57 -07:00
Ryan Liptak
b3598163df std.heap.DirectAllocator: Fix aligned reallocs on Windows 2019-04-22 02:20:01 -07:00
daurnimator
211f0a2226 std: Add mem.nativeIntToBig and mem.nativeIntToLittle
To be used where `htons`, `htonl`, etc. would be used in C.
It's useful to have a function that returns a number directly for use in initialisers.
2019-04-21 14:04:01 -04:00
daurnimator
217b95da31
std: add msghdr_const
As `iovec_const` is to `iovec`, `msghdr_const` is to `msghdr`
2019-04-21 21:53:24 +10:00
daurnimator
9babcac7a6
std: improve msghdr definition 2019-04-21 21:50:48 +10:00
Ryan Liptak
66020856b2 fix heap allocators when shrinking an object but growing its alignment 2019-04-20 23:56:39 -07:00
vegecode
bb25f212b3 compiler-rt: add aeabi_fcmp, comparesf2 2019-04-21 00:12:21 -04:00
tgschultz
22f5e5fd3e Fixes DirectAllocator Windows implementation to call HeapFree when new_size == 0 2019-04-20 14:04:09 -04:00
Andrew Kelley
9b83fe6b4c
fixup and zig fmt 2019-04-20 13:48:38 -04:00
Andrew Kelley
907a7068ce
Merge branch 'dwarfy' of https://github.com/LemonBoy/zig into LemonBoy-dwarfy 2019-04-20 13:32:59 -04:00
LemonBoy
c2542bb7b7 Recover symbol infos from DWARF sections 2019-04-20 10:35:39 +02:00
Ryan Liptak
1030cc97ca fix DirectAllocator not unmapping unused pages on large alignments
Fixes #2306
2019-04-20 02:21:42 -04:00
Raul Leal
d44d2784e6 zig-fmt: allow comptime blocks in containers (#2308)
* zig-fmt: allow comptime blocks in containers
* add test for comptime block in container
2019-04-19 15:27:42 -04:00
LemonBoy
0286be127e Fix parseFormValueConstant
Signed/unsigned confusion made the code fail an assertion sometimes.
2019-04-19 19:59:14 +02:00
Andrew Kelley
89763c9a0d
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.

Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.

Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.

Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.

As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).

This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.

This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.

See #1964
2019-04-16 19:12:20 -04:00
Andrew Kelley
4c03746926
Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."
This reverts commit 71bb8cd537.

This broke the CI on Windows.
2019-04-16 19:11:37 -04:00
Andrew Kelley
52caf311bb
Merge pull request #2286 from shritesh/wasm_alloc
WasmAllocator: WebAssembly Memory Allocator
2019-04-16 13:27:56 -04:00
Shritesh Bhattarai
0c28a18d96 WasmAllocator: cleanup 2019-04-16 12:23:45 -05:00
Sahnvour
71bb8cd537 DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory. 2019-04-16 13:18:21 -04:00
Shritesh Bhattarai
4235982fe6 fmt wasm_allocator 2019-04-16 01:42:11 -05:00
Shritesh Bhattarai
aa3f31ac0a wasm: add WasmAllocator 2019-04-16 01:40:16 -05:00
Shritesh Bhattarai
f2119f9961 wasm: WasmAllocator that uses fixed 64kb pages 2019-04-15 21:21:46 -05:00
Andrew Kelley
0a280b6062
update std.os.page_size for WebAssembly 2019-04-15 21:20:41 -04:00
Shritesh Bhattarai
f5d84250a3 wasi: switch to "standard" wasi_unstable module fn 2019-04-15 18:44:33 -04:00
Shritesh Bhattarai
22960a5fdf wasi: better comments 2019-04-13 22:45:31 -05:00
Shritesh Bhattarai
a2d8f03092 support extern "wasi" functions 2019-04-13 22:28:58 -05:00
Shritesh Bhattarai
93528be6b1 wasi: sigabrt at panic 2019-04-13 21:54:50 -05:00
Shritesh Bhattarai
fe9cd0b4bc wasi: use __wasi_proc_exit instead of posix.exit 2019-04-13 21:36:53 -05:00
Shritesh Bhattarai
72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Andrew Kelley
3ce024dd85
A bunch of fixes for the DWARF parser (#2254)
* Correct parsing of DWARF line_info section

* Fix reading of udata/sdata encoded attributes

* Add definition for DW_AT_alignment

Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.

* Fix reading of reference attributes

* Distinguish between absolute/relative addresses
2019-04-11 14:34:13 -04:00
Matthew Iannucci
27cd830ec8 Add initial support for iOS targets (#2237)
* Add iOS C int sizes... try to hack in iOS DebugInfo

* Get rid of ios link check for now

* Remove macos linkversion check
2019-04-11 13:15:17 -04:00
LemonBoy
51eb4ebec1 Distinguish between absolute/relative addresses 2019-04-11 15:41:42 +02:00
LemonBoy
38492b2ea4 Fix reading of reference attributes 2019-04-11 10:36:15 +02:00
LemonBoy
29ec409b52 Add definition for DW_AT_alignment
Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.
2019-04-11 10:36:15 +02:00
LemonBoy
795b3e9b68 Fix reading of udata/sdata encoded attributes 2019-04-11 10:36:15 +02:00
Marc Tiehuis
78af62a19a Pack big.Int sign and length fields
This effectively takes one-bit from the length field and uses it as the
sign bit. It reduces the size of an Int from 40 bits to 32 bits on a
64-bit arch.

This also reduces std.Rational from 80 bits to 64 bits.
2019-04-11 19:36:35 +12:00
Marc Tiehuis
87d8ecda46 Fix math.big.Int divN/gcdLehmer and fuzz-test failures 2019-04-11 19:36:35 +12:00
Marc Tiehuis
30788a98b1 Handle zero-limb trailing div case in big.Int 2019-04-11 19:36:35 +12:00
Marc Tiehuis
d3e1f32362 Small fixes for big.Rational and corrections for gcdLehmer
The int div code still causes some edge cases to fail right now.
2019-04-11 19:36:35 +12:00
Marc Tiehuis
b3ecdfd7bf Fix big.Int toString maybe-null allocator 2019-04-11 19:36:35 +12:00
Marc Tiehuis
5f4fcd5030 Add initial big.Rational type 2019-04-11 19:36:35 +12:00
Marc Tiehuis
ea1d2a2409 Add read-only, non-allocating Int for internal constants
A constant Int is one which has a value of null for its allocator field.
It cannot be resized or have its limbs written. Any attempt made to
write to it will be caught with a runtime panic.
2019-04-11 19:36:35 +12:00
Andrew Kelley
a4c7e4c4eb __muloti4 does not need the ABI workaround on Windows
Fixes 128-bit integer multiplication on Windows.

closes #2250
2019-04-10 22:33:33 -04:00
Andrew Kelley
a71bfc249d compiler-rt: better way to do the ABI required on Windows
This removes the compiler_rt.setXmm0 hack. Instead, for
the functions that use i128 or u128 in their parameter and
return types, we use `@Vector(2, u64)` which generates
the LLVM IR `<2 x i64>` type that matches what Clang
generates for `typedef int ti_int __attribute__ ((mode (TI)))`
when targeting Windows x86_64.
2019-04-10 18:47:14 -04:00
LemonBoy
60e2a04322 Correct parsing of DWARF line_info section 2019-04-10 23:30:41 +02:00
Andrew Kelley
52934851f2
compiler_rt: @divTrunc rather than @divFloor in muloti4 2019-04-10 16:29:10 -04:00
vegecode
aff2e47821 compiler-rt: correct use_thumb_1 flag
The flag is for generating correct arm-thumb interwork veneers in the
assembly code __aeabi_{memcpy,memset,etc} functions.

Armv6m only does thumb code generation regardless of whether arm or
thumb is selected and armv6t2 uses the newer thumb 2 set. All other
versions that zig supports pre-armv7 need the veneers and hence the
flag. Armv5 is actually armv5t.

Relevant code from clang/lib/Basic/Targets/Arm.cpp

```c
bool ARMTargetInfo::isThumb() const {
  return ArchISA == llvm::ARM::ISAKind::THUMB;
  }

bool ARMTargetInfo::supportsThumb() const {
  return CPUAttr.count('T') || ArchVersion >= 6;
}

bool ARMTargetInfo::supportsThumb2() const {
  return CPUAttr.equals("6T2") ||
    (ArchVersion >= 7 && !CPUAttr.equals("8M_BASE"));
}
```

Also see

http://www.llvm.org/svn/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td
2019-04-10 12:35:16 -04:00
Andrew Kelley
dea1027f97
doc comments for parameters in std.mem.Allocator 2019-04-09 17:43:49 -04:00
Ryan Liptak
6a78b315b2 Fix std.HashMap.remove returning incorrect KV
Now returns a copy of the removed kv instead of a pointer to the removed kv. The removed kv gets overwritten when shifting the hash map after the removal, so returning a pointer to it will have another kv's values in it after the return.

This bug had some nasty downstream effects in things like BufSet and BufMap where delete would free a still in-use KV and leave the actually removed KV un-free'd.
2019-04-07 15:47:09 -04:00
Shritesh Bhattarai
66fab05eba build: usageAndErr clean exit (#2194)
* build: usageAndErr clean exit
2019-04-05 18:38:11 -04:00
Shritesh Bhattarai
895e6eabc2 Fix getCurrentId test for pthreads (#2197)
* Fix getCurrentId test for pthreads
2019-04-05 18:12:46 -04:00
vegecode
d72239d339 Add divdf3 to compiler_rt
Also adds __aeabi_ddiv for arm32 targets
2019-04-05 18:10:19 -04:00
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
846f72b57c
zig build: support single-threaded builds
and fix the zig test suite not setting the --single-threaded flag
2019-04-05 14:54:37 -04:00
Shritesh Bhattarai
2f236e6efb fmt: support trailing comma after var_args 2019-04-05 12:27:13 -04:00
Shritesh Bhattarai
6cc2d3938e support comptime_int in formatInt{,Value} 2019-04-05 11:11:04 -04:00
vegecode
c24a49a1a7 Fixes to divsf3 (#2186)
* Fixes to divsf3

Embarrassingly failed to notice a section that was unchanged from where
it was copied from mulXf3.zig. The test cases for this function series
div{s,d,t}f3 are very incomplete and don't exercise all code paths.

Remove unnecessary switch from divsf3 left during development from when
I tried to make it generic to support f32, f64, and f128 in one go.

Make runtime safety dependent on whether a test is being run.

* divsf3: switch plus to minus
2019-04-05 11:04:46 -04:00
Shawn Landden
aecbd1892a Simplify math.isnan
We can just rely on the builtin behavior.
2019-04-05 11:03:57 -04:00
Shritesh Bhattarai
8e6ff8d615 fmt: format multi line only on trailing comma (#2184)
* fmt: format multi line only on trailing comma
2019-04-04 19:33:32 -04:00
Andrew Kelley
be0f656c21
fix @divFloor returning incorrect value and add __modti3
Closes #2152
See #1290
2019-04-04 15:45:37 -04:00
vegecode
12c4ab3927 Add divsf3 to compiler rt 2019-04-04 15:38:09 -04:00
Andrew Kelley
947c87b558
threads: fix using unmapped memory in some cases
as pointed out in #musl IRC, the memory for the fs register address
value needs to be taken into account in the mmap call.
2019-04-04 01:36:01 -04:00
hryx
e827b9661b zig fmt: Prevent for-else on same line when body is interrupted by LF 2019-04-04 01:31:39 -04:00
hryx
cec8c8678a zig fmt: Fix regression in for-else (#2178) 2019-04-04 01:31:39 -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
Ruslan Prokopchuk
70ae3222b5 handle LibExeObjStep.disable_gen_h
It is sometimes useful to skip generating of the header file (e.g. https://github.com/ziglang/zig/issues/2173), and zig compiler provides an option `--disable-gen-h` to control that behaviour. However, setting `lib.disable_gen_h = true` in a typical `build.zig` didn't append the option to arguments. This commit fixes it and adds a convenient `setDisableGenH` setter.
2019-04-03 18:31:25 -04:00
tgschultz
fe33d8ea14 Changes as suggested by andrewrk 2019-04-03 20:05:24 +00:00
tgschultz
ba774c5697 (De)serializer now uses enum instead of bool to determine packing mode (byte/bit).
Optional is initialized in a more straight-forward way by deserializer.
2019-04-03 15:47:46 +00:00
Andrew Kelley
ddb8aa73f5
more regression fixes 2019-04-02 18:31:18 -04:00
Andrew Kelley
3c27d9c25a
Merge pull request #2147 from emekoi/fix1940
added error for implicit cast from *const T to *[1]T.
2019-04-01 11:35:03 -04:00
Andrew Kelley
3199792ade
Merge pull request #2150 from vegecode/armv7m-compiler-rt
Armv7m compiler rt
2019-04-01 11:31:57 -04:00
hryx
c76d51de97 zig fmt: Allow one-line for loops 2019-04-01 11:31:00 -04:00
Shritesh Bhattarai
d645500883 fmt: fix first line comment indent in struct init 2019-03-31 22:33:32 -04:00
vegecode
bfbfb7b3b0 Remove inline keywords in addXf3.zig pending #2154 2019-03-31 21:00:36 -05:00
hryx
0563e8e1d4 Always write a multiline struct literal if a field expr is multiline 2019-03-31 21:09:56 -04:00
emekoi
b7aa289ae4 fixed broken casts in std 2019-03-31 16:47:34 -05:00
vegecode
937ff0cb6a Add all __aeabi functions (C versions) who alias currently existing functions to compiler-rt 2019-03-31 15:54:02 -05:00
vegecode
779137be41 Add __aeabi_{f,d}neg and __neg{s,d,X}f2 to compiler-rt 2019-03-31 15:54:02 -05:00
vegecode
38c2093500 Add __aeabi_{f,d}{add,sub} and __{add,sub}{s,d}f3 to compiler-rt 2019-03-31 15:54:02 -05:00
vegecode
310f91fb4f Add __aeabi_mem{cmp,clr,set,cpy,move} to compiler-rt 2019-03-31 15:54:02 -05:00
vegecode
e89b704293 Add memcmp to builtins 2019-03-31 15:54:02 -05:00
hryx
a4afacd182 Veritcally align array literal columns 2019-03-31 14:27:10 -04:00
Andrew Kelley
90a78866db
Merge pull request #2112 from shritesh/param_decl_doc_comments
Add doc_comments to param decl
2019-03-30 19:22:28 -04:00
Shritesh Bhattarai
b0d89cfe3f fmt: Fix param decl test 2019-03-30 14:58:18 -05:00
Shritesh Bhattarai
efa751c339 Add doc_comments to param decl 2019-03-30 14:50:08 -05:00
Rohlem
5703ab1d0c fix std.ascii type error and inverted logic
previously:
```
...\lib\zig\std\ascii.zig:203:20: error: unable to perform binary not operation on type 'comptime_int'
        return c | ~0b00100000;
                   ^
```
2019-03-29 12:18:42 -04:00
Rohlem
a824a8c687 add std.ascii to std.std test "std" 2019-03-29 12:18:42 -04:00
Shawn Landden
d494a5f4cf fix tests for math.mulWide 2019-03-29 12:17:48 -04:00
Shawn Landden
85d1885375 std.mulWide() whose return is twice as wide 2019-03-28 15:51:10 -04:00
Shawn Landden
65e234adfd fix build on arm64 2019-03-27 01:14:29 +00:00
Shritesh Bhattarai
85575704a4 Use linux.exit_group if not single threaded 2019-03-26 17:49:20 -04:00
Shritesh Bhattarai
5942797000 fmt: check for extra newline at end of file
`anything_changed` checks if `source_index` == `source.len`
Fixes #2074
2019-03-26 13:26:00 -04:00
Shawn Landden
51be449a57 std.ascii: respond to review
This won't generate as much mode in debug mode, as it doesn't check for overflow.
2019-03-26 12:00:55 -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
5eaead6a56
implement allowzero pointer attribute
closes #1953

only needed for freestanding targets.

also adds safety for `@intToPtr` when the address is zero.
2019-03-25 12:55:45 -04:00
Andrew Kelley
d0551db5cd
introduce the enum literal type
see #683
2019-03-24 00:44:18 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
89953ec83d
character literals: allow unicode escapes
also make the documentation for character literals more clear.
closes #2089

see #2097
2019-03-23 17:35:21 -04:00
Andrew Kelley
d83836825f
add mulXf3 to compiler-rt
this adds the following functions to compiler-rt:

 * `__mulsf3`
 * `__muldf3`
 * `__multf3`

See #1290
2019-03-22 17:46:49 -04:00
Shawn Landden
b76398c993 std: add ascii with C ASCII character classes
Does NOT look at the locale the way the C functions do.

       int isalnum(int c);
       int isalpha(int c);
       int iscntrl(int c);
       int isdigit(int c);
       int isgraph(int c);
       int islower(int c);
       int isprint(int c);
       int ispunct(int c);
       int isspace(int c);
       int isupper(int c);
       int isxdigit(int c);

       int isascii(int c);
       int isblank(int c);

       int toupper(int c);
       int tolower(int c);

Tested to match glibc (when using C locale) with this program:

const c = @cImport({
    // See https://github.com/ziglang/zig/issues/515
    @cDefine("_NO_CRT_STDIO_INLINE", "1");
    @cInclude("stdio.h");
    @cInclude("string.h");
    @cInclude("ctype.h");
});

const std = @import("std");
const ascii = std.ascii;
const abort = std.os.abort;

export fn main(argc: c_int, argv: **u8) c_int {
    var i: u8 = undefined;
    i = 0;
    while (true) {
        if (ascii.isAlNum(i) != (c.isalnum(i) > 0)) { abort(); }
        if (ascii.isAlpha(i) != (c.isalpha(i) > 0)) { abort(); }
        if (ascii.isCtrl(i) != (c.iscntrl(i) > 0)) { abort(); }
        if (ascii.isDigit(i) != (c.isdigit(i) > 0)) { abort(); }
        if (ascii.isGraph(i) != (c.isgraph(i) > 0)) { abort(); }
        if (ascii.isLower(i) != (c.islower(i) > 0)) { abort(); }
        if (ascii.isPrint(i) != (c.isprint(i) > 0)) { abort(); }
        if (ascii.isPunct(i) != (c.ispunct(i) > 0)) { abort(); }
        if (ascii.isSpace(i) != (c.isspace(i) > 0)) { abort(); }
        if (ascii.isUpper(i) != (c.isupper(i) > 0)) { abort(); }
        if (ascii.isXDigit(i) != (c.isxdigit(i) > 0)) { abort(); }
        if (i == 255) { break; }
        i += 1;
    }

    _ = c.printf(c"Success!\n");
    return 0;
}
2019-03-22 16:25:56 -04:00
Andrew Kelley
3c7555cb67
Merge remote-tracking branch 'origin/llvm8' 2019-03-20 13:34:07 -04:00
Andrew Kelley
2fdf69bc40
Merge pull request #2079 from Sahnvour/issue-2050
Fixes c_ABI tests on windows
2019-03-20 00:11:11 -04:00
Andrew Kelley
ac34841270
build.zig: allow run() on non-native target artifacts 2019-03-19 17:08:50 -04:00
Andrew Kelley
af9ac0d548
better buffer length for formatIntUnsigned
see #1358
2019-03-19 10:11:28 -04:00
Andrew Kelley
a581f4f0e2
Merge remote-tracking branch 'origin/master' into llvm8 2019-03-18 20:03:23 -04:00
Andrew Kelley
7dfbeca13e
libc: separate linux headers from musl/glibc 2019-03-18 13:47:59 -04:00
Sahnvour
ae9b90cf6e print a message instead of returning an error when debug info comes from a source file not found (for example compiled on another computer) 2019-03-16 15:34:14 +01:00
Sahnvour
704dfaaabf avoid reading LineBlockFragmentHeader at all if the address is not in range, thus simplifying code and improving speed of execution 2019-03-16 15:34:14 +01:00
Sahnvour
094d40fb1a allow pdb modules to have no C13 data, this happens if the module is stripped 2019-03-16 15:34:14 +01:00
Sahnvour
0d4a5c40bc correct padding handling between std.pdb.ModInfo entries in DbiStream 2019-03-16 15:34:14 +01: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
Akuli
b1c8c79733 Add /lib/x86_64-linux-gnu or similar to default system library search paths
this makes compiling with libraries like zlib and ncurses easier
2019-03-14 14:51:24 -04:00
Andrew Kelley
080dd27157
breaking: fix @typeInfo handling of global error set type
`builtin.TypeInfo.ErrorSet` is now `?[]Error`
instead of `struct{errors:[]Error}`.

closes #1936
2019-03-14 11:57:56 -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
5d2edac12d
breaking: remove --static; add -dynamic
`--static` is no longer an option. Instead, Zig makes things as static
as possible by default. `-dynamic` can be used to choose a dynamic
library rather than a static one.

`--enable-pic` is a new option. Usually it will be enabled
automatically, but in the case of build-exe with no dynamic libraries
on Linux or freestanding, Zig chooses off by default.

closes #1703
closes #1828
2019-03-13 19:50:41 -04:00
Andrew Kelley
d213708333
this empty import workaround no longer necessary 2019-03-13 14:13:09 -04:00