Commit Graph

314 Commits (284f6baf1c1884b2c5d17fd9724fdb5913e63e4e)

Author SHA1 Message Date
Greg V afe26bbcbd System call numbers on FreeBSD are machine-independent
But e.g. sbrk is only removed in new architectures (aarch64, riscv),
so keep it in x86_64
2018-10-20 15:15:01 +03:00
Greg V 1829c09303 Fix os/freebsd files 2018-10-20 15:15:01 +03:00
Andrew Kelley 3e72411db0
C ABI and compiler rt improvements for ARM
* add __multi3 compiler rt function. See #1290
* compiler rt includes ARM functions for thumb and aarch64 and
  other sub-arches left out. See #1526
* support C ABI for returning structs on ARM. see #1481
2018-10-13 15:18:00 -04:00
emekoi a22d9daaec added math.pow support for integer types. resolves #1637 (#1642)
added math.powi for integers; pow now handles ints
2018-10-10 10:50:23 -04:00
Andrew Kelley d40c4e7c89
Merge pull request #1429 from shawnl/arm64
initial arm64 support
2018-10-06 00:11:39 -04:00
Andrew Kelley d07413f9b7
fix missing .h files
closes #1634
2018-10-04 18:14:57 -04:00
Andrew Kelley 66cb75d114
std.Mutex: implement blocking mutexes on linux
closes #1463

Thanks to Shawn Landden for the original pull request.
This commit is based on that code.
2018-10-03 13:19:10 -04:00
Andrew Kelley 9d4eaf1e07
update std lib API for I/O
std.io.FileInStream -> std.os.File.InStream
std.io.FileInStream.init(file) -> file.inStream()
std.io.FileOutStream -> std.os.File.OutStream
std.io.FileOutStream.init(file) -> file.outStream()

remove a lot of error code possibilities from os functions

std.event.net.socketRead -> std.event.net.read
std.event.net.socketWrite -> std.event.net.write
add std.event.net.readv
add std.event.net.writev
add std.event.net.readvPosix
add std.event.net.writevPosix
add std.event.net.OutStream
add std.event.net.InStream

add std.event.io.InStream
add std.event.io.OutStream
2018-09-30 17:28:35 -04:00
Andrew Kelley 418b2e7d47
build: omit finding libxml2, zlib since no direct dependency 2018-09-30 16:56:06 -04:00
Andrew Kelley 57c4d38c55
rename std.event.tcp to std.event.net 2018-09-30 10:37:58 -04:00
emekoi e6446dfc86 fixed native target detection 2018-09-30 09:27:53 -04:00
Andrew Kelley e242f6a609
Release 0.3.0 2018-09-28 09:03:40 -04:00
Andrew Kelley f4a0658585 rely on gcc for static builds on macos 2018-09-27 22:27:52 -04:00
Andrew Kelley fe524a1fa5 build: add support for ZIG_STATIC on MacOS 2018-09-27 15:09:14 -04:00
Andrew Kelley 492821781d
add workaround for `llvm-config --system-libs`
not handling static libs correctly
2018-09-19 18:28:50 -04:00
Andrew Kelley 4b2719b51d
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-18 15:05:47 -04:00
emekoi 68c1d05917 compiling on mingw is now supported (#1542)
* compiles on mingw-w64
* fixed error in os_file_overwrite on windows
* fixed windows hello_world example
2018-09-18 00:13:17 -04:00
Andrew Kelley 4c6f1e614a
remove `zig build --init`. add `zig init-lib` and `zig init-exe`
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.

both now have test coverage with the new "cli tests" file.

closes #1035
2018-09-17 17:11:18 -04:00
Andrew Kelley a2abdb185f
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-16 10:51:58 -04:00
Andrew Kelley a1132ffe0f stage1: build blake code with -std=c99 2018-09-11 17:29:18 -04:00
Andrew Kelley 5ee5933ade
stage1 caching: zig no longer uses zig-cache 2018-09-10 17:30:45 -04:00
Andrew Kelley c9474faa4e
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-10 12:30:57 -04:00
Andrew Kelley fbe5737c84
stage1: always optimize blake and softfloat even in debug mode 2018-09-10 09:46:15 -04:00
Andrew Kelley 173fc842c4
basic compiler id hash working 2018-09-09 18:38:41 -04:00
Shawn Landden 342cff28f5 initial arm64 support 2018-09-08 03:52:28 +00:00
Andrew Kelley 2d4b95900e
stage1: import blake2b implementation
from master branch of blake2 reference implementation
320c325437539ae91091ce62efec1913cd8093c2
2018-09-05 23:23:11 -04:00
Andrew Kelley ba7836ea48 stage1: fix build on macos 2018-09-05 12:10:53 -04:00
Andrew Kelley 9a123697e3
fix compile error on gcc 7.3.0
Only set -Werror for debug builds, and only for zig itself, not for
embedded LLD.

See #1474
2018-09-05 10:18:12 -04:00
Andrew Kelley ac3cf0775f
Merge pull request #1474 from ziglang/issue-1357
Downgrade new g++-8.0 error to warning
2018-09-05 09:05:01 -04:00
Marc Tiehuis ef2b8d4574 Downgrade new g++-8.0 error to warning
Allows building in Debug mode. Closes #1357.
2018-09-05 20:43:14 +12:00
Andrew Kelley dbde8254d0
Merge remote-tracking branch 'origin/master' into llvm7 2018-09-04 11:58:31 -04:00
Andrew Kelley 2bd2a8ea34
Merge pull request #1441 from ziglang/poly1305-x25519
Add poly1305 and x25519 crypto primitives
2018-09-04 10:34:46 -04:00
Andrew Kelley 92f7474359 switch most windows calls to use W versions instead of A
See #534
2018-09-02 23:25:04 -04:00
Marc Tiehuis 65b89f598c Add poly1305 and x25519 crypto primitives
These are translated from [monocypher](https://monocypher.org/) which
has fairly competitive performance while remaining quite simple.

Initial performance comparision:

Zig:
 Poly1305: 1423 MiB/s
 X25519:   8671 exchanges per second

Monocypher:
 Poly1305: 1567 MiB/s
 X25519:   10539 exchanges per second

There is room for improvement and no real effort has been made at all in
optimization beyond a direct translation.
2018-08-30 18:02:19 +12:00
Andrew Kelley f1b71053de use RtlCaptureStackBackTrace on windows 2018-08-29 16:35:51 -04:00
Andrew Kelley 41723f842c Merge branch 'windows-coff-issue721' of https://github.com/Sahnvour/zig into Sahnvour-windows-coff-issue721 2018-08-28 17:32:32 -04:00
Shawn Landden 444edd9aed std.crypto: add chaCha20
v3
2018-08-27 19:44:11 -07:00
Andrew Kelley 7109035b78 Merge remote-tracking branch 'origin/master' into llvm7 2018-08-25 21:57:28 -04:00
Andrew Kelley c4d31c8323 build: update embedded LLD build files 2018-08-04 18:09:19 -04:00
Andrew Kelley e3ae2cfb52 add std.event.RwLock and a few more std changes
* add std.event.RwLock and std.event.RwLocked
 * std.debug.warn does its printing locked
 * add std.Mutex, however it's currently implemented as a spinlock
 * rename std.event.Group.cancelAll to std.event.Group.deinit and change
   the docs and assumptions.
 * add std.HashMap.clone
2018-08-01 16:26:37 -04:00
Andrew Kelley cc45527333 introduce std.event.fs for async file system functions
only works on linux so far
2018-07-30 13:44:36 -04:00
Andrew Kelley 5a919dd82d Merge remote-tracking branch 'origin/master' into self-hosted-libc-hello-world 2018-07-23 14:32:13 -04:00
Andrew Kelley 93e78ee722 self-hosted can compile libc hello world 2018-07-22 23:28:53 -04:00
Andrew Kelley 20f286f22a re-organize std lib darwin files 2018-07-22 00:04:24 -04:00
Sahnvour 2ec9a11646 Very much WIP base implementation for #721.
Currently does:
- read COFF executable file
- locate and load corresponding .pdb file
- expose .pdb content as streams (PDB format)
2018-07-21 20:30:11 +02:00
kristopher tate 501dd5f284 CMakeLists.txt: add darwin_socket.zig;
Tracking issue #1271;
thanks @Hejsil;
2018-07-22 01:47:53 +09:00
Andrew Kelley 58c5f94a99 self-hosted: share C++ code for finding libc on windows 2018-07-20 23:38:13 -04:00
Andrew Kelley 1d85b588ea self-hosted: progress on IR for supporting libc hello world
* add c int types
 * some more ir stubs
2018-07-19 00:08:47 -04:00
Andrew Kelley a8a1b5af07 fix build on windows
* move getAppDataDir and utf16leToUtf8 from self-hosted to std lib
 * fix std.event.Loop on windows
2018-07-18 10:07:22 -04:00
Andrew Kelley 97bfeac13f self-hosted: create tmp dir for .o files and emit .o file for fn 2018-07-16 20:52:50 -04:00
Andrew Kelley 9751a0ae04 std.atomic: use spinlocks
the lock-free data structures all had ABA problems and
std.atomic.Stack had a possibility to load an unmapped memory address.
2018-07-11 19:38:01 -04:00
Andrew Kelley 9bdcd2a495 add std.event.Future
This is like a promise, but it's for multiple getters, and
uses an event loop.
2018-07-11 16:00:06 -04:00
Andrew Kelley 574e31f0a0 self-hosted: first passing test
* introduce std.atomic.Int
 * add src-self-hosted/test.zig which is tested by the main test suite
   - it fully utilizes the multithreaded async/await event loop so the
     tests should Go Fast
 * `stage2/bin/zig build-obj test.zig` is able to spit out an error if 2 exported
   functions collide
 * ability for `zig test` to accept `--object` and `--assembly`
   arguments
 * std.build: TestStep supports addLibPath and addObjectFile
2018-07-10 20:18:43 -04:00
Andrew Kelley 8fba0a6ae8 introduce std.event.Group for making parallel async calls 2018-07-10 15:17:01 -04:00
Andrew Kelley b6eb404831 organize std.event into directories 2018-07-09 22:22:44 -04:00
Andrew Kelley 3f4b77f561
Merge pull request #1177 from jayschwa/fix-out-of-src-builds
Fix version detection for out-of-source builds
2018-06-30 12:01:47 -04:00
Marc Tiehuis 951512f5ae compiler_rt: Add CMake entries 2018-06-30 21:58:59 +12:00
Marc Tiehuis 53fef94b9f compiler_rt: Add missing install targets 2018-06-30 21:58:59 +12:00
Jay Weisskopf 25bbb1a8ff Fix version detection for out-of-source builds
Git was called in the build directory and not the source directory.
This works fine when the build directory resides within the source
repository, but doesn't work for out-of-source builds. Example:

```
~/zigbuild$ cmake ../zig
fatal: not a git repository (or any of the parent directories): .git
Configuring zig version 0.2.0+
```

Use Git's `-C <path>` flag to always point to the source directory so
that it doesn't matter where the build directory lives.
2018-06-29 22:22:04 -04:00
Andrew Kelley 0874a5ba77 std.atomic.queue - document limitation and add MPSC queue 2018-06-29 14:45:42 -04:00
Ben Noordhuis fd75e73ee9 add f16 type
Add support for half-precision floating point operations.

Introduce `__extendhfsf2` and `__truncsfhf2` in std/special/compiler_rt.

Add `__gnu_h2f_ieee` and `__gnu_f2h_ieee` as aliases that are used in
Windows builds.

The logic in std/special/compiler_rt/extendXfYf2.zig has been reworked
and can now operate on 16 bits floating point types.

`extendXfYf2()` and `truncXfYf2()` are marked `inline` to work around
a not entirely understood stack alignment issue on Windows when calling
the f16 versions of the builtins.

closes #1122
2018-06-27 16:20:04 +02:00
Andrew Kelley 5f38d6e2e9 add casting docs, __extenddftf2, and __extendsftf2 2018-06-21 14:44:35 -04:00
Andrew Kelley c7804277bf `@floatToInt` now has safety-checked undefined behavior
when the integer part does not fit in the destination integer type

 * Also fix incorrect safety triggered for integer casting an
   `i32` to a `u7`. closes #1138
 * adds compiler-rt function: `__floatuntidf`
2018-06-19 16:06:10 -04:00
Andrew Kelley 48de57d824 add basic std lib code for loading dynamic libraries
this is going to only work for very basic libraries;
I plan to slowly add more features over time to support more
complicated libraries
2018-06-16 17:01:23 -04:00
Jay Weisskopf b3a3e2094e Make `zig version` compliant with SemVer (#1113)
The git revision is build metadata and should be appended with a plus sign.

https://semver.org/#spec-item-10
2018-06-15 14:06:56 -04:00
Marc Tiehuis 9110140514 Add i128 compiler-rt div/mul support 2018-06-13 22:25:04 +12:00
Marc Tiehuis dc8bda7e02 Add arbitrary-precision integer to std
A few notes on the implementation:

 - Any unsigned power of two integer type less than 64 bits in size is supported
 as a Limb type.
 - The algorithms used are kept simple for the moment. More complicated
 algorithms are generally only more useful as integer sizes increase a
 lot and I don't expect our current usage to be used for this purpose
 just yet.
 - All branches (practically) have been covered by tests.

See 986a2b3243/bench
for rough performance comparison numbers.

Closes #364.
2018-06-10 18:24:34 +12:00
Andrew Kelley 3625df25d6
build: add flag to LLD to fix gcc 8 build (#1013)
* build: add flag to LLD to fix gcc 8 build
* build: add -Wno-unknown-warning-option to work around older gcc
2018-05-15 16:21:47 -04:00
Andrew Kelley 0cb65b266a separate std.zig.parse and std.zig.render 2018-05-07 22:07:50 -04:00
Andrew Kelley 41e1cd185b std.SegmentedList implementation 2018-05-07 01:04:43 -04:00
Marc Tiehuis 0afc6a9886 Add json decoder
- streaming json decoder
 - dynamic tree/value decoder
2018-05-04 17:56:20 +12:00
Andrew Kelley 4ac36d094c add std.atomic.Stack and std.atomic.Queue 2018-04-28 16:11:32 -04:00
Marc Tiehuis d5e99cc05e Add initial complex-number support
- Library type instead of builtin
 - All C complex functions implemented

Partial WIP: Needs more tests for edge cases.
2018-04-24 19:18:31 +12:00
Andrew Kelley 21767144fc linux: support VDSO for clock_gettime
also fix a compiler crash when using cmpxchg with nullable pointer
2018-04-22 18:11:50 -04:00
Andrew Kelley 0dcadc61b4 Merge branch 'std.os.time' of https://github.com/tgschultz/zig into tgschultz-std.os.time 2018-04-22 13:24:25 -04:00
tgschultz 8b66dd8c7d Added unstaged changes. 2018-04-18 13:55:42 -05:00
Marc Tiehuis c7cb5c31e5 Add exp/norm distributed random float generation 2018-04-16 20:06:50 +12:00
Andrew Kelley b5459eb987 add @sqrt built-in function
See #767
2018-04-15 13:26:58 -04:00
Andrew Kelley ee3e2790aa cmake defaults stage1 to install in build directory 2018-04-10 20:57:37 -04:00
Andrew Kelley e85a10e9f5 async tcp server proof of concept 2018-04-09 00:52:45 -04:00
Andrew Kelley 0d22a00f6f *WIP* async/await TCP server 2018-04-08 18:26:24 -04:00
Marc Tiehuis c34ce2cbc6 Add common hash/checksum functions
- SipHash64, SipHash128
 - Crc32 (fast + small variants)
 - Adler32
 - Fnv1a (32, 64 and 128 bit variants)
2018-04-06 23:10:54 +12:00
Marc Tiehuis 8938429ea1 Add Hmac function (#890) 2018-04-04 10:31:10 -04:00
Andrew Kelley b01c50d6fa find libc and zig std lib at runtime
this removes the following configure options:
 * ZIG_LIBC_LIB_DIR
 * ZIG_LIBC_STATIC_LIB_DIR
 * ZIG_LIBC_INCLUDE_DIR
 * ZIG_DYNAMIC_LINKER
 * ZIG_EACH_LIB_RPATH
 * zig's reliance on CMAKE_INSTALL_PREFIX

these options are still available as command line options, however,
the default will attempt to execute the system's C compiler to
collect system defaults for these values.

closes #870
2018-03-30 17:10:54 -04:00
Andrew Kelley f586acabdc add ZIG_STATIC cmake option
it's not compatible with glibc but it works with musl
2018-03-30 13:20:13 -04:00
Marc Tiehuis 0fd0f6fd1f Rewrite Rand functions
We now use a generic Rand structure which abstracts the core functions
from the backing engine.

The old Mersenne Twister engine is removed and replaced instead with
three alternatives:

 - Pcg32
 - Xoroshiro128+
 - Isaac64

These should provide sufficient coverage for most purposes, including a
CSPRNG using Isaac64. Consumers of the library that do not care about
the actual engine implementation should use DefaultPrng and DefaultCsprng.
2018-03-30 01:50:58 +13:00
Wander Lairson Costa 543952eb87 Include libxml2 and zlib as required libraries
libxml2 is a required library, but we only find out that when the build
fails to link against it, if it is not present. The same for zlib.

We use find_library to find these two libraries and print nice fail
messages if they are not found.
2018-03-20 18:15:02 +00:00
Andrew Kelley f073923ea0 Release 0.2.0 2018-03-15 09:15:05 -04:00
Andrew Kelley 5bc4f1e3f1 xml2 workaround is relevant for linux too 2018-03-10 18:23:08 -05:00
Andrew Kelley e4fd3fd52b workaround for llvm-config missing xml2 2018-03-10 14:48:41 -05:00
Andrew Kelley 5a7a0e8518 update to SoftFloat-3e
closes #823
2018-03-09 15:06:06 -05:00
Andrew Kelley 4955c4b8f9 update C headers to clang 6.0.0rc3 2018-02-23 13:15:16 -05:00
Andrew Kelley 9cfd7dea19 Merge remote-tracking branch 'origin/master' into llvm6 2018-02-23 12:56:41 -05:00
Ben Noordhuis ab48934e9c add support for stack traces on macosx
Add basic address->symbol resolution support.  Uses symtab data from the
MachO image, not external dSYM data; that's left as a future exercise.

The net effect is that we can now map addresses to function names but
not much more.  File names and line number data will have to wait until
a future pull request.

Partially fixes #434.
2018-02-19 23:11:11 +01:00
Andrew Kelley ef6260b3a7 Merge remote-tracking branch 'origin/master' into llvm6 2018-02-11 23:49:20 -05:00
Andrew Kelley 46aa416c48 std.os and std.io API update
* move std.io.File to std.os.File
 * add `zig fmt` to self hosted compiler
 * introduce std.io.BufferedAtomicFile API
 * introduce std.os.AtomicFile API
 * add `std.os.default_file_mode`
 * change FileMode on posix from being a usize to a u32
 * add std.os.File.mode to return mode of an open file
 * std.os.copyFile copies the mode from the source file instead of
   using the default file mode for the dest file
 * move `std.os.line_sep` to `std.cstr.line_sep`
2018-02-10 21:02:24 -05:00
Andrew Kelley 1fb308ceee self hosted compiler: move tokenization and parsing to std lib 2018-02-09 13:08:02 -05:00
Andrew Kelley aa043a6339 Merge remote-tracking branch 'origin/master' into llvm6 2018-02-07 17:27:30 -05:00
Andrew Kelley 44d8d654a0 fix test failure, organize code, add new compile error 2018-02-05 09:26:39 -05:00
Ben Noordhuis 73ee434c8c Use /dev/urandom and sysctl(RANDOM_UUID) on Linux.
Add fallback paths for when the getrandom(2) system call is not
available.  Try /dev/urandom first and sysctl(RANDOM_UUID) second.

The sysctl issues a warning in the system logs with some kernels but
that seems like an acceptable tradeoff for the fallback of a fallback.
2018-02-04 18:58:36 +01:00