Skip to content

Commit cb513c7

Browse files
committed
rt: Clean up to build with cl.exe
* Detect the #define _MSC_VER in addition to __WIN32__ * Don't include valgrind.h for windows * Remove unused `rust_valgrind_stack_{un,}register` functions * Add stub definition for `rust_running_on_valgrind` for windows * Conditionally define `rust_dbg_extern_empty_struct` as empty structures are not allowed by cl.exe apparently.
1 parent 40570eb commit cb513c7

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/rt/rust_builtin.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#include <assert.h>
1515
#include <stdlib.h>
1616

17-
#if !defined(__WIN32__)
17+
18+
#if !defined(_WIN32)
1819
#include <dirent.h>
1920
#include <pthread.h>
2021
#include <signal.h>
@@ -40,7 +41,9 @@
4041

4142
/* Foreign builtins. */
4243
//include valgrind.h after stdint.h so that uintptr_t is defined for msys2 w64
44+
#ifndef _WIN32
4345
#include "valgrind/valgrind.h"
46+
#endif
4447

4548
#ifndef _WIN32
4649
char*
@@ -84,12 +87,7 @@ rust_dirent_t_size() {
8487
}
8588
#endif
8689

87-
uintptr_t
88-
rust_running_on_valgrind() {
89-
return RUNNING_ON_VALGRIND;
90-
}
91-
92-
#if defined(__WIN32__)
90+
#if defined(_WIN32)
9391
int
9492
get_num_cpus() {
9593
SYSTEM_INFO sysinfo;
@@ -136,14 +134,13 @@ rust_get_num_cpus() {
136134
return get_num_cpus();
137135
}
138136

139-
unsigned int
140-
rust_valgrind_stack_register(void *start, void *end) {
141-
return VALGRIND_STACK_REGISTER(start, end);
142-
}
143-
144-
void
145-
rust_valgrind_stack_deregister(unsigned int id) {
146-
VALGRIND_STACK_DEREGISTER(id);
137+
uintptr_t
138+
rust_running_on_valgrind() {
139+
#ifdef _WIN32
140+
return 0;
141+
#else
142+
return RUNNING_ON_VALGRIND;
143+
#endif
147144
}
148145

149146
#if defined(__DragonFly__)

src/rt/rust_test_helpers.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ struct ManyInts {
135135
struct TwoU8s arg6;
136136
};
137137

138+
// MSVC doesn't allow empty structs or unions
139+
#ifndef _MSC_VER
138140
struct Empty {
139141
};
140142

@@ -148,6 +150,7 @@ rust_dbg_extern_empty_struct(struct ManyInts v1, struct Empty e, struct ManyInts
148150
assert(v1.arg6.one == v2.arg6.one + 1);
149151
assert(v1.arg6.two == v2.arg6.two + 1);
150152
}
153+
#endif
151154

152155
intptr_t
153156
rust_get_test_int() {

0 commit comments

Comments
 (0)