30 Commits

Author SHA1 Message Date
Andrew Kelley
02a4e5a4bf
Merge pull request #6385 from LemonBoy/callocator
std: Make C allocator respect the required alignment
2020-11-18 20:16:57 -08:00
LemonBoy
53433cdea2 Implement a fallback mechanism for posix_memalign
Do the alignment dance by ourselves whenever posix_memalign is not
available.
Don't try to use malloc as it has too many edge cases, figuring out
whether a block of memory is manually aligned by the mechanism above or
is directly coming from malloc becomes too hard to be valuable.
2020-11-05 16:10:15 +01:00
LemonBoy
0e95fa455c std: Split kernel&libc definitions of stat struct
There's no guarantee for the kernel definition to be ABI compatible with
the libc one (and vice versa).
There's also no guarantee of ABI compatibility between musl/glibc.

Fun, isn't it?
2020-11-05 09:38:50 +01:00
Jakub Konka
4f50958407 Clean up exporting of symbols on Darwin 2020-10-28 10:36:19 +01:00
Frank Denis
6ddb05d996 Darwin has arc4random(), too 2020-10-18 18:24:36 +02:00
Andrew Kelley
a4828f6d0f std.c (darwin) update to new opaque syntax
This was an undetected conflict between

76a195473dac059a842fed2a6ba581ca99947d2b and
95a37373e9f576854956c2909cc128b5b6388ec6
2020-10-08 22:45:39 -07:00
Andrew Kelley
76a195473d
Merge pull request #6516 from LemonBoy/fastfilecopy
std: Make file copy ops use zero-copy mechanisms
2020-10-08 20:14:47 -04:00
LemonBoy
03762da2af New review round 2020-10-07 11:13:26 +02:00
LemonBoy
0f248e0988 std: Make file copy ops use zero-copy mechanisms
Use copy_file_range on Linux (if available), fcopyfile on Darwin,
sendfile on *BSDs (and on Linux kernels without copy_file_range).
2020-10-03 12:31:17 +02:00
Loris Cro
f841ea77e2 make symlink buffer null-terminated
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-10-02 19:33:14 +02:00
Jakub Konka
1698e6d7a7 Link against libSystem when generating Mach-O exe
This is required when generating an exe on macOS.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Andrew Kelley
9cfcd0c296
Merge pull request #6103 from Vexu/extern
Disallow extern variables with initializers.
2020-08-20 18:35:31 -04:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Vexu
717e2a365d
correct llvm linkage conversion
when weakly exporting external declaration we need to pass LLVMExternalWeakLinkage
2020-08-20 17:12:26 +03:00
Vexu
d25674a51e
disallow extern variables with initializers 2020-08-20 11:35:33 +03:00
Jakub Konka
c63b23d684 Use fstatat on macOS (otherwise uses 32bit) 2020-06-24 21:00:21 +02: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
LemonBoy
3ccf99c0bd std: Slim duplicate logic for some calls 2020-03-24 19:47:18 +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 1141bfb21b82f8d3fc353e968a591f2ad9aaa571 (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
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
daurnimator
72ec445677 std: turn EAI_ constants into a non-exhaustive enum 2020-01-18 17:46:44 -05: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
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
daurnimator
6e635c6406
std: close is OSX specific 2019-11-05 02:16:30 +11:00
Andrew Kelley
618ee5b63a fixes for macos and 32 bit arches 2019-10-30 14:43:55 -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
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00