Skip to content

Commit 632a4c9

Browse files
jamortonbrson
authored andcommitted
Refactor includes structure, getting rid of rust_internal.h
Many changes to code structure are included: - removed TIME_SLICE_IN_MS - removed sychronized_indexed_list - removed region_owned - kernel_owned move to kernel.h, task_owned moved to task.h - global configs moved to rust_globals.h - changed #pragma once to standard guard in rust_upcall.h - got rid of memory.h
1 parent 704ca04 commit 632a4c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+311
-412
lines changed

src/rt/arch/i386/context.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#include "context.h"
2-
3-
#include "../../rust.h"
41

5-
#include <stdio.h>
6-
#include <stdlib.h>
7-
#include <assert.h>
2+
#include "context.h"
3+
#include "../../rust_globals.h"
84

95
extern "C" uint32_t CDECL swap_registers(registers_t *oregs,
106
registers_t *regs)

src/rt/arch/x86_64/context.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#include "context.h"
2-
3-
#include "../../rust.h"
41

5-
#include <stdio.h>
6-
#include <stdlib.h>
7-
#include <assert.h>
2+
#include "context.h"
3+
#include "../../rust_globals.h"
84

95
extern "C" void CDECL swap_registers(registers_t *oregs,
106
registers_t *regs)

src/rt/boxed_region.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#include <assert.h>
1+
2+
23
#include "boxed_region.h"
3-
#include "rust_internal.h"
4+
#include "rust_globals.h"
5+
#include "rust_task.h"
46

57
// #define DUMP_BOXED_REGION
68

src/rt/circular_buffer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* A simple resizable circular buffer.
33
*/
44

5-
#include "rust_internal.h"
5+
#include "circular_buffer.h"
6+
#include "rust_globals.h"
7+
#include "rust_kernel.h"
68

79
circular_buffer::circular_buffer(rust_kernel *kernel, size_t unit_sz) :
810
kernel(kernel),

src/rt/circular_buffer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#ifndef CIRCULAR_BUFFER_H
66
#define CIRCULAR_BUFFER_H
77

8+
#include "rust_globals.h"
9+
#include "rust_kernel.h"
10+
811
class
912
circular_buffer : public kernel_owned<circular_buffer> {
1013
static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 8;

src/rt/memory.h

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,8 @@
22
#ifndef MEMORY_H
33
#define MEMORY_H
44

5-
// FIXME: It would be really nice to be able to get rid of this.
6-
inline void *operator new[](size_t size, rust_task *task, const char *tag) {
7-
return task->malloc(size, tag);
8-
}
5+
#include "rust_task.h"
96

10-
template <typename T>
11-
inline void *task_owned<T>::operator new(size_t size, rust_task *task,
12-
const char *tag) {
13-
return task->malloc(size, tag);
14-
}
15-
16-
template <typename T>
17-
inline void *task_owned<T>::operator new[](size_t size, rust_task *task,
18-
const char *tag) {
19-
return task->malloc(size, tag);
20-
}
21-
22-
template <typename T>
23-
inline void *task_owned<T>::operator new(size_t size, rust_task &task,
24-
const char *tag) {
25-
return task.malloc(size, tag);
26-
}
27-
28-
template <typename T>
29-
inline void *task_owned<T>::operator new[](size_t size, rust_task &task,
30-
const char *tag) {
31-
return task.malloc(size, tag);
32-
}
33-
34-
template <typename T>
35-
inline void *kernel_owned<T>::operator new(size_t size, rust_kernel *kernel,
36-
const char *tag) {
37-
return kernel->malloc(size, tag);
38-
}
397

408

419
#endif /* MEMORY_H */

src/rt/memory_region.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#include "rust_internal.h"
1+
2+
#include "sync/sync.h"
23
#include "memory_region.h"
4+
#include "rust_env.h"
35

46
#if RUSTRT_TRACK_ALLOCATIONS >= 3
57
#include <execinfo.h>

src/rt/memory_region.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#ifndef MEMORY_REGION_H
1010
#define MEMORY_REGION_H
1111

12+
#include "rust_globals.h"
1213
#include "sync/lock_and_signal.h"
14+
#include "util/array_list.h"
1315

1416
// There are three levels of debugging:
1517
//

src/rt/rust.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#include "rust_internal.h"
1+
2+
#include "rust_globals.h"
3+
#include "rust_kernel.h"
24
#include "rust_util.h"
35
#include "rust_scheduler.h"
4-
#include <cstdio>
56

67
struct
78
command_line_args : public kernel_owned<command_line_args>

src/rt/rust.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/rt/rust_box_annihilator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include "rust_internal.h"
1+
2+
#include "rust_globals.h"
3+
#include "rust_task.h"
24
#include "rust_shape.h"
35

46
class annihilator : public shape::data<annihilator,shape::ptr> {

src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* Native builtins. */
22

3-
#include "rust_internal.h"
43
#include "rust_sched_loop.h"
54
#include "rust_task.h"
65
#include "rust_util.h"
76
#include "rust_scheduler.h"
87
#include "sync/timer.h"
98
#include "rust_abi.h"
9+
#include "rust_port.h"
1010

1111
#ifdef __APPLE__
1212
#include <crt_externs.h>

src/rt/rust_cc.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
// Rust cycle collector. Temporary, but will probably stick around for some
22
// time until LLVM's GC infrastructure is more mature.
33

4-
#include "rust_debug.h"
5-
#include "rust_internal.h"
6-
#include "rust_shape.h"
7-
#include "rust_task.h"
8-
#include <cassert>
9-
#include <cstdio>
10-
#include <cstdlib>
114
#include <map>
125
#include <set>
136
#include <vector>
14-
#include <stdint.h>
157
#include <ios>
168

9+
#include "rust_globals.h"
10+
#include "rust_cc.h"
11+
#include "rust_debug.h"
12+
#include "rust_shape.h"
13+
#include "rust_task.h"
14+
1715
// The number of allocations Rust code performs before performing cycle
1816
// collection.
1917
#define RUST_CC_FREQUENCY 5000

src/rt/rust_debug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Routines useful when debugging the Rust runtime.
22

3+
#include "rust_globals.h"
34
#include "rust_abi.h"
45
#include "rust_debug.h"
5-
#include "rust_internal.h"
6+
#include "rust_task.h"
67

78
#include <iostream>
89
#include <string>
910
#include <sstream>
10-
#include <stdint.h>
1111

1212
namespace {
1313

src/rt/rust_env.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// that might come from the environment is loaded here, once, during
44
// init.
55

6-
#include "rust_internal.h"
6+
#include "rust_env.h"
77

88
// The environment variables that the runtime knows about
99
#define RUST_THREADS "RUST_THREADS"

src/rt/rust_env.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2+
#ifndef RUST_ENV_H
3+
#define RUST_ENV_H
4+
5+
#include "rust_globals.h"
6+
17
struct rust_env {
28
size_t num_sched_threads;
39
size_t min_stack_size;
@@ -11,3 +17,5 @@ struct rust_env {
1117

1218
rust_env* load_env();
1319
void free_env(rust_env *rust_env);
20+
21+
#endif

src/rt/rust_globals.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
#include <string.h>
2626
#include <fcntl.h>
2727
#include <math.h>
28+
#include <assert.h>
2829

29-
#include "rust.h"
3030
#include "rand.h"
3131
#include "uthash.h"
32-
#include "rust_env.h"
3332

3433
#if defined(__WIN32__)
3534
extern "C" {
@@ -52,6 +51,28 @@ extern "C" {
5251
#error "Platform not supported."
5352
#endif
5453

54+
#ifdef __i386__
55+
// 'cdecl' ABI only means anything on i386
56+
#ifdef __WIN32__
57+
#ifndef CDECL
58+
#define CDECL __cdecl
59+
#endif
60+
#ifndef FASTCALL
61+
#define FASTCALL __fastcall
62+
#endif
63+
#else
64+
#define CDECL __attribute__((cdecl))
65+
#define FASTCALL __attribute__((fastcall))
66+
#endif
67+
#else
68+
#define CDECL
69+
#define FASTCALL
70+
#endif
71+
72+
/* Controls whether claims are turned into checks */
73+
/* Variable name must be kept consistent with trans.rs */
74+
extern "C" int check_claims;
75+
5576
#define CHECKED(call) \
5677
{ \
5778
int res = (call); \
@@ -64,4 +85,16 @@ extern "C" {
6485
} \
6586
}
6687

88+
#define PTR "0x%" PRIxPTR
89+
90+
// This accounts for logging buffers.
91+
static size_t const BUF_BYTES = 2048;
92+
93+
// The error status to use when the process fails
94+
#define PROC_FAIL_CODE 101
95+
96+
// A cond(ition) is something we can block on. This can be a channel
97+
// (writing), a port (reading) or a task (waiting).
98+
struct rust_cond { };
99+
67100
#endif /* RUST_GLOBALS_H */

0 commit comments

Comments
 (0)