From 1f97e6d47f90f1ddfef2d3a888099bd95b0bb1df Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 20 Apr 2013 00:24:44 -0700 Subject: rt: Add rust_dbg_next_port for generating test port numbers --- src/rt/rust_test_helpers.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/rt/rust_test_helpers.cpp') 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; +} -- cgit 1.4.1-3-g733a5