Commit Graph

72 Commits (0a9672fb86b84658f8780f57e769be45e41f3034)

Author SHA1 Message Date
Andrew Kelley da549a72e1 zig fmt 2020-06-20 18:39:15 -04:00
Ryan Liptak 62cfc68d2f Use std.ComptimeStringMap in the C tokenizer 2020-05-26 23:10:08 -07:00
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
nia 14a954f350 Add arc4random_buf() in NetBSD libc, use it to implement getrandom() 2020-05-01 17:22:27 +01: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
LemonBoy 070ace4b22 std: Fix more NetBSD bits
Fix some more libc definitions.
2020-04-01 12:11:19 +02:00
LemonBoy 3ccf99c0bd std: Slim duplicate logic for some calls 2020-03-24 19:47:18 +01:00
LemonBoy 761602e3e8 std: Use getdents on all the BSDs
* Use the correct versioned libc calls to avoid nasty surprises
2020-03-23 18:54:14 +01:00
LemonBoy 27344464ed std: Add missing C defines for NetBSD 2020-03-23 18:47:40 +01: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
Michael Dusan d31b65e762 std: fix sendfile on macOS and FreeBSD
- fix std.os.sendfile/FreeBSD use correct in/out fd_t
- fix std.os.sendfile/macOS use correct in/out fd_t
- undo 1141bfb21b (no longer needed)
- fix c.freebsd.sendfile use off_t value
- fix c.freebsd.sendfile decl correct in/out fd_t
- fix c.darwin.sendfile decl correct in/out fd_t

fix signature param names
2020-03-05 20:46:28 -05:00
Andrew Kelley 859fc856d3
fix macosx and freebsd build failures 2020-03-03 02:57:11 -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
Terin Stock bd287dd194
std: implement sendfile on linux
This changset adds a `sendfile(2)` syscall bindings to the linux bits
component. Where available, the `sendfile64(2)` syscall will be
transparently called.

A wrapping function has also been added to the std.os to transform
errno returns to Zig errors.

Change-Id: I86769fc4382c0771e3656e7b21137bafd99a4411
2020-03-02 12:54:50 -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
Vexu b15958c557 fix c tokenizer bug 2020-02-14 18:57:57 -05:00
Vexu fa377dbd15 fix c tokenizer bug 2020-02-13 12:21:28 -05:00
Vexu ae5ba369e1 translate-c float fixes 2020-02-10 11:02:29 -05:00
Andrew Kelley 40b1fecace
Merge pull request #4363 from Vexu/trans-std-c
Use std.c.tokenizer in translate-c
2020-02-05 14:29:39 -05:00
Vexu 1f49460dcb
fix regressions in comments and string prefixes 2020-02-05 08:35:30 +02:00
Vexu 35c40f0a70
fix regressions 2020-02-02 10:49:51 +02:00
LemonBoy 3640c682a2 Run `zig fmt` 2020-02-01 11:32:53 +01: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
Vexu abd1a7c91c
std-c add todos to unfinished parsing functioins 2020-01-29 12:12:28 +02:00
LemonBoy d5c2a20d8e Unify the two DWARF interpreters
* Let's consolidate the special-cased DWARF interpreter for OSX with the
  general purpose one

* Drop the assumption that all the debug data is contained in a single
  contiguous slice of memory. This is a good news for freestanding
  targets and paves the way for supporting compressed debug sections.
2020-01-27 09:46:20 -05:00
Vexu ad327fed05
std-c redo scoping, do string concatanation in parser 2020-01-19 20:44:55 +02:00
daurnimator 72ec445677 std: turn EAI_ constants into a non-exhaustive enum 2020-01-18 17:46:44 -05:00
Vexu 28daddae81
std-c todos and small fixes 2020-01-14 16:18:32 +02:00
Vexu 4c0776b2a5
std-c parse switch 2020-01-11 21:48:12 +02:00
LemonBoy 5ab5de89c0 New @export() handling
Use a struct as second parameter to be future proof (and also allows to
specify default values for the parameters)

Closes #2679 as it was just a matter of a few lines of code.
2020-01-09 13:43:06 -05:00
Vexu e21ea5bd95
std-c parser loops 2020-01-08 00:00:14 +02:00
Vexu 83b4163591
std-c parser declaratorIsFunction and small fixes 2020-01-07 23:25:38 +02:00
Vexu 8b713ce889
std-c parser add options 2020-01-07 22:43:44 +02:00
Vexu dbc0457068
std-c declaration parsing 2020-01-07 20:15:57 +02:00
Vexu 4184d4c66a
std-c parser record and enum specifiers 2020-01-07 19:05:46 +02:00
Vexu df12c1328e
std-c parser typing improvements 2020-01-07 16:05:13 +02:00
Vexu 3ed6d7d245
std-c parser declarator 2020-01-06 20:06:17 +02:00
Vexu d5d52af26e
std-c parse pointer 2020-01-06 00:06:33 +02:00
Vexu 5feeff7123
std-c improve error reporting and decl parsing 2020-01-05 20:25:52 +02:00
Vexu 795a503999
std-c tokenizer always add newline token 2020-01-05 20:25:51 +02:00
Vexu f934f9b419
std-c parser fndef and static assert 2020-01-05 20:25:51 +02:00
Vexu 46f292982d
std-c parser DeclSpec 2020-01-05 20:25:51 +02:00
Vexu 25f7f66b8f
std-c type parsing 2020-01-05 20:25:51 +02:00
Vexu dccf1247b2
std-c ifstmt compoundstmt and errors 2020-01-05 20:25:51 +02:00
Vexu a20c0b31de
std-c parser and ast organization 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
Vexu 2183c4bb44
std-c tokenizer string concatenation 2020-01-05 20:25:50 +02:00
Vexu a5d1fb1e49
std-c tokenizer line continuation, tests and fixes 2020-01-05 20:25:50 +02:00