Skip to content

Commit 7cd6816

Browse files
committed
rt: Move test functions to rust_test_helpers.cpp
1 parent 39e2ab5 commit 7cd6816

File tree

3 files changed

+107
-87
lines changed

3 files changed

+107
-87
lines changed

mk/rt.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ RUNTIME_CXXS_$(1) := \
7676
rt/boxed_region.cpp \
7777
rt/arch/$$(HOST_$(1))/context.cpp \
7878
rt/arch/$$(HOST_$(1))/gpr.cpp \
79-
rt/rust_android_dummy.cpp
79+
rt/rust_android_dummy.cpp \
80+
rt/rust_test_helpers.cpp
8081

8182
RUNTIME_CS_$(1) := rt/linenoise/linenoise.c rt/linenoise/utf8.c
8283

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -589,50 +589,6 @@ rust_log_console_off() {
589589
log_console_off(task->kernel->env);
590590
}
591591

592-
extern "C" CDECL lock_and_signal *
593-
rust_dbg_lock_create() {
594-
return new lock_and_signal();
595-
}
596-
597-
extern "C" CDECL void
598-
rust_dbg_lock_destroy(lock_and_signal *lock) {
599-
assert(lock);
600-
delete lock;
601-
}
602-
603-
extern "C" CDECL void
604-
rust_dbg_lock_lock(lock_and_signal *lock) {
605-
assert(lock);
606-
lock->lock();
607-
}
608-
609-
extern "C" CDECL void
610-
rust_dbg_lock_unlock(lock_and_signal *lock) {
611-
assert(lock);
612-
lock->unlock();
613-
}
614-
615-
extern "C" CDECL void
616-
rust_dbg_lock_wait(lock_and_signal *lock) {
617-
assert(lock);
618-
lock->wait();
619-
}
620-
621-
extern "C" CDECL void
622-
rust_dbg_lock_signal(lock_and_signal *lock) {
623-
assert(lock);
624-
lock->signal();
625-
}
626-
627-
typedef void *(*dbg_callback)(void*);
628-
629-
extern "C" CDECL void *
630-
rust_dbg_call(dbg_callback cb, void *data) {
631-
return cb(data);
632-
}
633-
634-
extern "C" CDECL void rust_dbg_do_nothing() { }
635-
636592
extern "C" CDECL void
637593
rust_dbg_breakpoint() {
638594
BREAKPOINT_AWESOME;
@@ -844,48 +800,6 @@ rust_readdir() {
844800

845801
#endif
846802

847-
// These functions are used in the unit tests for C ABI calls.
848-
849-
extern "C" CDECL uint32_t
850-
rust_dbg_extern_identity_u32(uint32_t u) {
851-
return u;
852-
}
853-
854-
extern "C" CDECL uint64_t
855-
rust_dbg_extern_identity_u64(uint64_t u) {
856-
return u;
857-
}
858-
859-
struct TwoU64s {
860-
uint64_t one;
861-
uint64_t two;
862-
};
863-
864-
extern "C" CDECL TwoU64s
865-
rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
866-
return u;
867-
}
868-
869-
struct TwoDoubles {
870-
double one;
871-
double two;
872-
};
873-
874-
extern "C" CDECL TwoDoubles
875-
rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
876-
return u;
877-
}
878-
879-
extern "C" CDECL double
880-
rust_dbg_extern_identity_double(double u) {
881-
return u;
882-
}
883-
884-
extern "C" CDECL char
885-
rust_dbg_extern_identity_u8(char u) {
886-
return u;
887-
}
888-
889803
extern "C" rust_env*
890804
rust_get_rt_env() {
891805
rust_task *task = rust_get_current_task();

src/rt/rust_test_helpers.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Helper functions used only in tests
12+
13+
#include "rust_sched_loop.h"
14+
#include "rust_task.h"
15+
#include "rust_util.h"
16+
#include "rust_scheduler.h"
17+
#include "sync/timer.h"
18+
#include "sync/rust_thread.h"
19+
#include "rust_abi.h"
20+
21+
// These functions are used in the unit tests for C ABI calls.
22+
23+
extern "C" CDECL uint32_t
24+
rust_dbg_extern_identity_u32(uint32_t u) {
25+
return u;
26+
}
27+
28+
extern "C" CDECL uint64_t
29+
rust_dbg_extern_identity_u64(uint64_t u) {
30+
return u;
31+
}
32+
33+
struct TwoU64s {
34+
uint64_t one;
35+
uint64_t two;
36+
};
37+
38+
extern "C" CDECL TwoU64s
39+
rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
40+
return u;
41+
}
42+
43+
struct TwoDoubles {
44+
double one;
45+
double two;
46+
};
47+
48+
extern "C" CDECL TwoDoubles
49+
rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
50+
return u;
51+
}
52+
53+
extern "C" CDECL double
54+
rust_dbg_extern_identity_double(double u) {
55+
return u;
56+
}
57+
58+
extern "C" CDECL char
59+
rust_dbg_extern_identity_u8(char u) {
60+
return u;
61+
}
62+
63+
extern "C" CDECL lock_and_signal *
64+
rust_dbg_lock_create() {
65+
return new lock_and_signal();
66+
}
67+
68+
extern "C" CDECL void
69+
rust_dbg_lock_destroy(lock_and_signal *lock) {
70+
assert(lock);
71+
delete lock;
72+
}
73+
74+
extern "C" CDECL void
75+
rust_dbg_lock_lock(lock_and_signal *lock) {
76+
assert(lock);
77+
lock->lock();
78+
}
79+
80+
extern "C" CDECL void
81+
rust_dbg_lock_unlock(lock_and_signal *lock) {
82+
assert(lock);
83+
lock->unlock();
84+
}
85+
86+
extern "C" CDECL void
87+
rust_dbg_lock_wait(lock_and_signal *lock) {
88+
assert(lock);
89+
lock->wait();
90+
}
91+
92+
extern "C" CDECL void
93+
rust_dbg_lock_signal(lock_and_signal *lock) {
94+
assert(lock);
95+
lock->signal();
96+
}
97+
98+
typedef void *(*dbg_callback)(void*);
99+
100+
extern "C" CDECL void *
101+
rust_dbg_call(dbg_callback cb, void *data) {
102+
return cb(data);
103+
}
104+
105+
extern "C" CDECL void rust_dbg_do_nothing() { }

0 commit comments

Comments
 (0)