about summary refs log tree commit diff
path: root/src/rt/rust_test_helpers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_test_helpers.cpp')
-rw-r--r--src/rt/rust_test_helpers.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp
index 64966bd3454..d82c39d6838 100644
--- a/src/rt/rust_test_helpers.cpp
+++ b/src/rt/rust_test_helpers.cpp
@@ -165,3 +165,14 @@ extern "C" CDECL TwoDoubles
 rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
     return u;
 }
+
+// Generates increasing port numbers for network testing
+extern "C" CDECL uintptr_t
+rust_dbg_next_port() {
+  static lock_and_signal dbg_port_lock;
+  static uintptr_t next_port = 9600;
+  scoped_lock with(dbg_port_lock);
+  uintptr_t this_port = next_port;
+  next_port += 1;
+  return this_port;
+}