aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/socket.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-05-16 18:30:46 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-05-16 19:07:45 +0200
commit5eb9927aae076200bb7ba3f22c33b0a7c97c5643 (patch)
treef80210439a5d8995ebf189bce7f2e141fcb1caec /libphobos/src/std/socket.d
parent682e587f1021241758f7dfe0b22651008622a312 (diff)
downloadgcc-5eb9927aae076200bb7ba3f22c33b0a7c97c5643.zip
gcc-5eb9927aae076200bb7ba3f22c33b0a7c97c5643.tar.gz
gcc-5eb9927aae076200bb7ba3f22c33b0a7c97c5643.tar.bz2
d: Merge upstream dmd 60bfa0ee7, druntime 94bd5bcb, phobos 3a1cd9a01.
D front-end changes: - Import dmd v2.100.0. - Add bit fields to D, enabled via the -fpreview=bitfields switch. - Removed the -ftransition=markdown and -frevert=markdown switches. - Added new trait `__traits(classInstanceAlignment)' to provide the required data alignment for classes. - The check for `pragma(crt_constructor)' and `pragma(crt_destructor)' linkage has been relaxed to allow all `void()' signatures. - ImportC parser now recognizes the `typeof(...)' operator. D runtime changes: - Import druntime v2.100.0. Phobos changes: - Import phobos v2.100.0. - To comply with dip1000, `std.socket.Socket` methods now accept only `scope' arrays. - The `fill', `alignSize', `align2', and `align4' methods of `std.outbuffer.OutBuffer' have been extended to allow specifying a custom value when pre-filling or padding the buffer. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 60bfa0ee7. * dmd/VERSION: Update version to v2.100.0. * d-builtins.cc (d_init_versions): Update for new front-end interface. * d-codegen.cc (d_decl_context): Use resolvedLinkage to get declaration linkage. (build_struct_literal): Track offset in bits. * d-gimplify.cc (d_gimplify_modify_expr): Check both operands for a bit-field reference. * d-lang.cc (d_handle_option): Handle -fpreview=bitfields, remove -frevert=markdown and -ftransition=vmarkdown. (d_post_options): Set flag_rtti and flag_exceptions if -fno-druntime was seen on command-line. (d_parse_file): Update for new front-end interface. (d_type_promotes_to): Use resolvedLinkage to get declaration linkage. * decl.cc (make_thunk): Likewise. * expr.cc (ExprVisitor::visit (CatAssignExp *)): Remove lowering for appending of an element or array to another array. * lang.opt (fpreview=bitfields): New option. (frevert=markdown): Remove. (ftransition=vmarkdown): Remove. * types.cc (layout_aggregate_members): Ignore anonymous fields in total count. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 94bd5bcb. * libdruntime/Makefile.am (ALL_DRUNTIME_INSTALL_DSOURCES): Add $(DRUNTIME_DSOURCES_ELF). (ALL_DRUNTIME_SOURCES): Likewise. (DRUNTIME_DSOURCES_ELF): New variable. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 3a1cd9a01. * testsuite/libphobos.init_fini/custom_gc.d: Update test.
Diffstat (limited to 'libphobos/src/std/socket.d')
-rw-r--r--libphobos/src/std/socket.d70
1 files changed, 38 insertions, 32 deletions
diff --git a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d
index 915159f..6ec7985 100644
--- a/libphobos/src/std/socket.d
+++ b/libphobos/src/std/socket.d
@@ -122,6 +122,12 @@ version (StdUnittest)
writefln("Ignoring std.socket(%d) test failure (likely caused by flaky environment): %s", line, e.msg);
}
}
+
+ // Without debug=std_socket, still compile the slow tests, just don't run them.
+ debug (std_socket)
+ private enum runSlowTests = true;
+ else
+ private enum runSlowTests = false;
}
/// Base exception thrown by `std.socket`.
@@ -1698,7 +1704,7 @@ public:
}
});
- debug (std_socket)
+ if (runSlowTests)
softUnittest({
// test failing reverse lookup
const InternetAddress ia = new InternetAddress("255.255.255.255", 80);
@@ -2633,7 +2639,7 @@ private:
@safe unittest
{
- debug (std_socket)
+ if (runSlowTests)
softUnittest({
import std.datetime.stopwatch;
import std.typecons;
@@ -3000,7 +3006,7 @@ public:
* Returns: The number of bytes actually sent, or `Socket.ERROR` on
* failure.
*/
- ptrdiff_t send(const(void)[] buf, SocketFlags flags) @trusted
+ ptrdiff_t send(scope const(void)[] buf, SocketFlags flags) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
@@ -3014,7 +3020,7 @@ public:
}
/// ditto
- ptrdiff_t send(const(void)[] buf)
+ ptrdiff_t send(scope const(void)[] buf)
{
return send(buf, SocketFlags.NONE);
}
@@ -3026,7 +3032,7 @@ public:
* Returns: The number of bytes actually sent, or `Socket.ERROR` on
* failure.
*/
- ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) @trusted
+ ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
@@ -3042,7 +3048,7 @@ public:
}
/// ditto
- ptrdiff_t sendTo(const(void)[] buf, Address to)
+ ptrdiff_t sendTo(scope const(void)[] buf, Address to)
{
return sendTo(buf, SocketFlags.NONE, to);
}
@@ -3050,7 +3056,7 @@ public:
//assumes you connect()ed
/// ditto
- ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) @trusted
+ ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags) @trusted
{
static if (is(typeof(MSG_NOSIGNAL)))
{
@@ -3065,7 +3071,7 @@ public:
//assumes you connect()ed
/// ditto
- ptrdiff_t sendTo(const(void)[] buf)
+ ptrdiff_t sendTo(scope const(void)[] buf)
{
return sendTo(buf, SocketFlags.NONE);
}
@@ -3077,7 +3083,7 @@ public:
* Returns: The number of bytes actually received, `0` if the remote side
* has closed the connection, or `Socket.ERROR` on failure.
*/
- ptrdiff_t receive(void[] buf, SocketFlags flags) @trusted
+ ptrdiff_t receive(scope void[] buf, SocketFlags flags) @trusted
{
version (Windows) // Does not use size_t
{
@@ -3094,7 +3100,7 @@ public:
}
/// ditto
- ptrdiff_t receive(void[] buf)
+ ptrdiff_t receive(scope void[] buf)
{
return receive(buf, SocketFlags.NONE);
}
@@ -3106,7 +3112,7 @@ public:
* Returns: The number of bytes actually received, `0` if the remote side
* has closed the connection, or `Socket.ERROR` on failure.
*/
- ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) @trusted
+ ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from) @trusted
{
if (!buf.length) //return 0 and don't think the connection closed
return 0;
@@ -3129,7 +3135,7 @@ public:
/// ditto
- ptrdiff_t receiveFrom(void[] buf, ref Address from)
+ ptrdiff_t receiveFrom(scope void[] buf, ref Address from)
{
return receiveFrom(buf, SocketFlags.NONE, from);
}
@@ -3137,7 +3143,7 @@ public:
//assumes you connect()ed
/// ditto
- ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) @trusted
+ ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags) @trusted
{
if (!buf.length) //return 0 and don't think the connection closed
return 0;
@@ -3158,7 +3164,7 @@ public:
//assumes you connect()ed
/// ditto
- ptrdiff_t receiveFrom(void[] buf)
+ ptrdiff_t receiveFrom(scope void[] buf)
{
return receiveFrom(buf, SocketFlags.NONE);
}
@@ -3169,7 +3175,7 @@ public:
* Returns: The number of bytes written to `result`.
* The length, in bytes, of the actual result - very different from getsockopt()
*/
- int getOption(SocketOptionLevel level, SocketOption option, void[] result) @trusted
+ int getOption(SocketOptionLevel level, SocketOption option, scope void[] result) @trusted
{
socklen_t len = cast(socklen_t) result.length;
if (_SOCKET_ERROR == .getsockopt(sock, cast(int) level, cast(int) option, result.ptr, &len))
@@ -3217,7 +3223,7 @@ public:
}
/// Set a socket option.
- void setOption(SocketOptionLevel level, SocketOption option, void[] value) @trusted
+ void setOption(SocketOptionLevel level, SocketOption option, scope void[] value) @trusted
{
if (_SOCKET_ERROR == .setsockopt(sock, cast(int) level,
cast(int) option, value.ptr, cast(uint) value.length))
@@ -3647,55 +3653,55 @@ class UdpSocket: Socket
{
checkAttributes!q{@trusted}; assert(0);
}
- @trusted ptrdiff_t send(const(void)[] buf, SocketFlags flags)
+ @trusted ptrdiff_t send(scope const(void)[] buf, SocketFlags flags)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t send(const(void)[] buf)
+ @safe ptrdiff_t send(scope const(void)[] buf)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to)
+ @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t sendTo(const(void)[] buf, Address to)
+ @safe ptrdiff_t sendTo(scope const(void)[] buf, Address to)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags)
+ @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t sendTo(const(void)[] buf)
+ @safe ptrdiff_t sendTo(scope const(void)[] buf)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted ptrdiff_t receive(void[] buf, SocketFlags flags)
+ @trusted ptrdiff_t receive(scope void[] buf, SocketFlags flags)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t receive(void[] buf)
+ @safe ptrdiff_t receive(scope void[] buf)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from)
+ @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t receiveFrom(void[] buf, ref Address from)
+ @safe ptrdiff_t receiveFrom(scope void[] buf, ref Address from)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags)
+ @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags)
{
checkAttributes!q{@trusted}; assert(0);
}
- @safe ptrdiff_t receiveFrom(void[] buf)
+ @safe ptrdiff_t receiveFrom(scope void[] buf)
{
checkAttributes!q{@safe}; assert(0);
}
- @trusted int getOption(SocketOptionLevel level, SocketOption option, void[] result)
+ @trusted int getOption(SocketOptionLevel level, SocketOption option, scope void[] result)
{
checkAttributes!q{@trusted}; assert(0);
}
@@ -3711,7 +3717,7 @@ class UdpSocket: Socket
{
checkAttributes!q{@trusted};
}
- @trusted void setOption(SocketOptionLevel level, SocketOption option, void[] value)
+ @trusted void setOption(SocketOptionLevel level, SocketOption option, scope void[] value)
{
checkAttributes!q{@trusted};
}
@@ -3793,11 +3799,11 @@ Socket[2] socketPair() @trusted
///
@safe unittest
{
- immutable ubyte[] data = [1, 2, 3, 4];
+ immutable ubyte[4] data = [1, 2, 3, 4];
auto pair = socketPair();
scope(exit) foreach (s; pair) s.close();
- pair[0].send(data);
+ pair[0].send(data[]);
auto buf = new ubyte[data.length];
pair[1].receive(buf);