Skip to content

Commit

Permalink
std.os: add INVALID_SOCKET (#12081)
Browse files Browse the repository at this point in the history
This constant returns an invalid `socket_t` that can be used as a sentinel
value.
  • Loading branch information
yyny authored Aug 24, 2022
1 parent d852894 commit 0f01e81
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/std/os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ pub const RelativePathWasi = struct {
};

pub const socket_t = if (builtin.os.tag == .windows) windows.ws2_32.SOCKET else fd_t;
pub const INVALID_SOCKET = if (builtin.os.tag == .windows) windows.ws2_32.INVALID_SOCKET else @as(socket_t, -1);

/// See also `getenv`. Populated by startup code before main().
/// TODO this is a footgun because the value will be undefined when using `zig build-lib`.
Expand Down

0 comments on commit 0f01e81

Please sign in to comment.