aboutsummaryrefslogtreecommitdiff
path: root/std/net.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-28 04:09:09 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-28 04:09:09 -0400
commitd7a539906d2dd49872abb161f3d3364c9641ccd2 (patch)
tree0d9c04fdc537326431a34ca2e7797c976fa4b91b /std/net.zig
parent2a49c876be76dc98996a3251310728ad32b22363 (diff)
parent1525e2c0561bb598b1e94ad9cdced5dd22e7d66d (diff)
downloadzig-d7a539906d2dd49872abb161f3d3364c9641ccd2.tar.gz
zig-d7a539906d2dd49872abb161f3d3364c9641ccd2.zip
Merge branch 'embed-lld'
Zig now depends on LLVM 5.0.0. For the latest version that supports LLVM 4.0.1, use 2a49c876be76dc98996a3251310728ad32b22363. Unfortunately we had to embed LLD into Zig due to some MACH-O related LLD bugs. One of them is already upstream and another is awaiting feedback on the llvm-dev mailing list. You can use cmake option -DZIG_FORCE_EXTERNAL_LLD=ON to still use external LLD if you want to live with the MACH-O bugs or if your system LLD is patched. Closes #273
Diffstat (limited to 'std/net.zig')
-rw-r--r--std/net.zig31
1 files changed, 15 insertions, 16 deletions
diff --git a/std/net.zig b/std/net.zig
index e5a4858819..53ed9d2606 100644
--- a/std/net.zig
+++ b/std/net.zig
@@ -1,5 +1,4 @@
const linux = @import("os/linux.zig");
-const errno = @import("os/errno.zig");
const assert = @import("debug.zig").assert;
const endian = @import("endian.zig");
@@ -21,10 +20,10 @@ const Connection = struct {
const send_err = linux.getErrno(send_ret);
switch (send_err) {
0 => return send_ret,
- errno.EINVAL => unreachable,
- errno.EFAULT => unreachable,
- errno.ECONNRESET => return error.ConnectionReset,
- errno.EINTR => return error.SigInterrupt,
+ linux.EINVAL => unreachable,
+ linux.EFAULT => unreachable,
+ linux.ECONNRESET => return error.ConnectionReset,
+ linux.EINTR => return error.SigInterrupt,
// TODO there are more possible errors
else => return error.Unexpected,
}
@@ -35,13 +34,13 @@ const Connection = struct {
const recv_err = linux.getErrno(recv_ret);
switch (recv_err) {
0 => return buf[0..recv_ret],
- errno.EINVAL => unreachable,
- errno.EFAULT => unreachable,
- errno.ENOTSOCK => return error.NotSocket,
- errno.EINTR => return error.SigInterrupt,
- errno.ENOMEM => return error.NoMem,
- errno.ECONNREFUSED => return error.ConnectionRefused,
- errno.EBADF => return error.BadFd,
+ linux.EINVAL => unreachable,
+ linux.EFAULT => unreachable,
+ linux.ENOTSOCK => return error.NotSocket,
+ linux.EINTR => return error.SigInterrupt,
+ linux.ENOMEM => return error.NoMem,
+ linux.ECONNREFUSED => return error.ConnectionRefused,
+ linux.EBADF => return error.BadFd,
// TODO more error values
else => return error.Unexpected,
}
@@ -50,9 +49,9 @@ const Connection = struct {
pub fn close(c: Connection) -> %void {
switch (linux.getErrno(linux.close(c.socket_fd))) {
0 => return,
- errno.EBADF => unreachable,
- errno.EINTR => return error.SigInterrupt,
- errno.EIO => return error.Io,
+ linux.EBADF => unreachable,
+ linux.EINTR => return error.SigInterrupt,
+ linux.EIO => return error.Io,
else => return error.Unexpected,
}
}
@@ -119,7 +118,7 @@ pub fn connectAddr(addr: &Address, port: u16) -> %Connection {
const connect_err = linux.getErrno(connect_ret);
if (connect_err > 0) {
switch (connect_err) {
- errno.ETIMEDOUT => return error.TimedOut,
+ linux.ETIMEDOUT => return error.TimedOut,
else => {
// TODO figure out possible errors from connect()
return error.Unexpected;