about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-04-20 00:24:44 -0700
committerBrian Anderson <banderson@mozilla.com>2013-04-20 00:24:44 -0700
commit1f97e6d47f90f1ddfef2d3a888099bd95b0bb1df (patch)
treea3a688af2e971fd91993e00403d9ba01b4866d43 /src/rt
parent6a5c4f68c2f8c10bf439a39373f5c518ed2f58a1 (diff)
downloadrust-1f97e6d47f90f1ddfef2d3a888099bd95b0bb1df.tar.gz
rust-1f97e6d47f90f1ddfef2d3a888099bd95b0bb1df.zip
rt: Add rust_dbg_next_port for generating test port numbers
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_test_helpers.cpp11
-rw-r--r--src/rt/rustrt.def.in2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp
index 64966bd3454..7938d65acd2 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 = 9000;
+  scoped_lock with(dbg_port_lock);
+  uintptr_t this_port = next_port;
+  next_port += 1;
+  return this_port;
+}
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index 5a556ed2107..f84a73a394b 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -221,4 +221,4 @@ rust_uv_free_ip4_addr
 rust_uv_free_ip6_addr
 rust_call_nullary_fn
 rust_initialize_global_state
-
+rust_dbg_next_port